New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WCJS] Consider adding dynamic import based loader #63
Comments
|
The polyfills shouldn't be bundled with your app, but loaded via script tags as documented. There's no benefit from attempting to bundle. |
|
@justinfagnani Webpack's dependency graph doesn't really work with the webcomponents-loader.js file since it's not requiring anything else. I was thinking along the lines of making use of webpack specific code splitting feature for the polyfill. That's the whole point of using webcomponents-loader.js to not bundle unnecessary polyfills. |
|
BTW: You can load v1.0.1 with webpack. v1.0.2 and after won't work. wcjs supporting webpack dynamic imports makes it so you don't have to do a bunch of wcjs custom code in your app/component. |
|
I'd like to see a version of these polyfills that works better with popular tools like Webpack as well. Webpack and Babel are quite capable of only including the polyfills you need with a combination of There are other options it seems worthwhile to explore also. @abraham's post above sounds like it could be a great solution. Especially re-emphasizing that dynamic imports aren't just a Webpack thing, they're a potential standard (https://github.com/tc39/proposal-dynamic-import) at Stage 3. I can also imagine it being nice if you were able to use Webpack to split a script similar to Seems like some of these options could have all the same benefits as As it currently is, the average framework and Webpack user who is using many future features very seamlessly elsewhere in their application has to pay a lot of special attention to use Web Components, and there are somewhat intractable issues that sound like they stem from the Web Component polyfills themselves needing polyfills like In fact, if I could get some help with the reverse engineering ASAP, I'd be willing to take a stab at that, because I'm feeling pretty blocked and I'm not really into the idea of ditching my entire direction to rewrite my components in Angular or React. Which, if I don't get all these bumps in the road smoothed out soon, I'm going to have to do. |
|
A few things I've noticed so far that make what I envision challenging:
import '@webcomponents/webcomponentsjs/src/symbol.js'; // what's this needed for re: "web components"?
import '@webcomponents/webcomponentsjs/src/flag-parser.js'; // what's this needed for re: "web components"?
import '@webcomponents/url/url.js'; // what's this needed for re: "web components"?
import '@webcomponents/webcomponentsjs/src/baseuri.js'; // what's this needed for re: "web components"?
import '@webcomponents/webcomponentsjs/src/unresolved.js'; // what's this needed for re: "web components"?
|
|
For what my $.02 is worth, with tools like webpack becoming more popular and npm being the place to go for frontend JavaScript now, being able to just Having ES2015+ (e.g. Could documentation be added for those who are using something like webpack? Option 1: npm + webpack
Options 2: UNPKG
Happy to contribute some docs if you like!
|
|
There is a Webpack starter pack from Vaadin that shows how they can be combined: https://github.com/web-padawan/polymer3-webpack-starter Does that answer your questions on how to use the tools together? |
|
Looking at web-padawan/polymer3-webpack-starter, it seems to simply be copying the webcomponentjs polyfills to be served locally by a blocking script tag. It's no different from the standard webcomponentjs approach other than the path is different. |
|
@abraham you are right, currently approach is the same. It does make sense because of some nits, e.g. bootstrapping Honestly, having |
|
I'd say that while, yes, that documentation is useful, without rethinking the way these polyfills are implemented documentation is a salve. From my perspective, the issue isn't "I don't know how to use this with Webpack." I know several ways to use this with Webpack. The issue is that I can't use them in the typical way--and, worse, I can't take advantage of the value-adds of Webpack and other commonly paired tools like Babel. With Webpack, all the ...And thereby avoid using any polyfills you don't need or duplicating them. Which is one of the biggest challenges I see in the current implementation. There are assumptions such as: if you need to polyfill Take lit-element as an example; if I were using it, I'd need to address that But I'm not using lit-element and I can't get rid of the It's not only an issue of "blocking script size." While that is certainly an issue I care about, it's not the only issue. There's also the issue of overall application size. There's also an issue of collisions between different polyfills. There's also the issue of bugs arising around the use of these unnecessary polyfills, such as webcomponents/webcomponentsjs#983 webcomponents/webcomponentsjs#976 webcomponents/webcomponentsjs#972 webcomponents/webcomponentsjs#968 webcomponents/webcomponentsjs#942. There's also the issue of giving your users what they need and expect, instead of what they don't need and don't expect--which I consider to be both a usability and security concern. I'll be honest, I am heavily biased toward the web platform. I want to see web components recognized as having all the potential I know they have--potential that is often scoffed at by the audience these problems impact and frustrate. Knowing this makes me take those problems more seriously than I might otherwise. I speak for myself, but I also speak for how I see the bigger picture, here. While I realize these polyfills are often preoccupied with supporting Polymer, they're also the defacto web component polyfills, period. |
Use responseURL to compute redirectedUrl
|
just a sample of using dynamic imports (only tested in development with IE 11 and latest chrome) |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Really? Won't fix? Webpack is pretty much the de facto standard for web tooling, and making this work with the common standard would do a lot for moving things forward with the community |
I intend to use webcomponents-loader.js within my project which uses Webpack and webpack has its own dependency graph which requires explicit declarative
importeverything we need to use within the application and that means the current file structure doesn't get copied out as is which is the expectation for the current loader to work. However, I still want the polyfills to be loaded dynamically as I hope that most of the people in future who use the program will have latest browsers, so this will lead to major size reduction and load the polyfills only when needed.Webpack's dynamic import can be used here and a new file created for the purpose of webpack can help solve the issues. I would like to know the thoughts of the polyfill maintainers if they are willing to accept it in this repo or if I should create a fork since it's something very build tool specific, since the dynamic imports are in stage 3 of the TC39 proposal maybe it's not that much specific to webpack now.
The text was updated successfully, but these errors were encountered: