-
Notifications
You must be signed in to change notification settings - Fork 938
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Components don't build properly with PolymerLabs/lit-element-build-rollup #257
Comments
Related to: PolymerLabs/lit-element-build-rollup#6 |
Just to clear something up ... I think you have 2 different issues here. The That's separate to why the app might not be rendering. |
@CaptainCodeman - you are right on the rollup warnings being separate (they also turn up on the open-wc build, I see) |
(Copying my comment from #323 here)
|
@aomarks When can we expect NPM component releases including this fix? Thanks! |
Just released 0.8.0 with this change in it. Enjoy! |
@aomarks I filed a separate issue against the wicg-inert repo (see above) that appears to be a dependency for certain components. Does it make sense to reopen this issue until the dependency issue is resolved as you'll likely need to update package.json for any affected components? For example, mwc-drawer won't function within a Rollup bundle until this is resolved. |
I'm not sure I understand what is causing the bug. @aomarks can you explain it to me? |
This repo (MWC) uses JavaScript modules, and we import wicg-inert as a JavaScript module (see https://github.com/material-components/material-components-web-components/blob/b1d1640c9c3b27ec0f3c9054c1b2a158f23a891a/packages/drawer/src/mwc-drawer-base.ts#L23). However wicg-inert is distributed as an AMD module (not a JavaScript module), so it has the standard AMD initialization boilerplate at the top of the file, which includes a reference to a top-level In JavaScript modules, top-level IMO the solution here is that wicg-inert should either not be compiled to an AMD module at all (especially since it doesn't export anything), or there needs to be a second JavaScript module output, with the package.json |
I'll re-open this until the wicg-inert issue is fixed and we bump the dependency here. |
I think we're distributed as a UMD module so, AMD if it's available, or CommonJS, else global. I think the second option of using the |
@aomarks I can confirm the new wicg-inert version works with Rollup bundling. Thanks @robdodson. |
Thanks for fixing and releasing @robdodson! NPM install should already pick up the new version (users may need to delete |
btw I think this lead to an issue where folks using webpack were expecting a transpiled version to come through in the It seems like there might be a de facto standard of sorts where folks transpile the guts of a module but leave the import/export syntax in place. If I were transpile inert to ES5 but leave the import/export syntax would that negatively affect y'all? |
It won't break anything in MWC, but it will probably slightly increase bundle size (since transpiled classes are larger), and it makes the code a little less debuggable in the browser. I don't think this module actually has any imports/exports, it's all side-effects. (But if it did, shipping ES5 transpiled code but with module syntax seems pretty odd, because you don't get the benefit of it working out-of-the-box in older browsers, but you also remove the possibility of serving smaller/faster code to modern browsers). Sounds like this should have been a breaking change (totally my bad too, since we discussed it and I didn't know about this kind of use case), but TBH I don't think the fact that certain webpack configurations expect the "module" field to contain ES5 code is a compelling reason to shy away from publishing ES2015 to NPM. IMO if a user needs to support older browsers, they should have a build process that transpiles all their code, including dependencies, to ES5. |
Reproduce:
https://github.com/PolymerLabs/lit-element-build-rollup
npm install @material/mwc-button
& import/add inmy-element
(The element version is 0.5.0)
Two things happen:
and 2. the app never renders - but throws an error in the console:
Using the rollup script from
https://open-wc.org/building/building-rollup.html
works with the mwc-elements.Also, other elements done with
lit-element
work (with the PolymerLabs/lit-element-build-rollup script).Theory: The TypeScript compiler creates extra 'boilerplate' code for properties that is not compatible with the simple rollup script.
'captaincodeman' (polymer slack) suggested adding this to the typescript config of the components (I didn't have a chance to try yet):
The text was updated successfully, but these errors were encountered: