-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[Polymer] Bundling ES5 shim breaks ES6 elements #3497
Comments
@seaneking , do you have a reproduction somewhere? |
Of the ES5 shim throwing with an ES6 class? Sure, pens:
|
Maybe I am missing something in the problem. In the polymer example here we do have components with es6 syntax (https://github.com/storybooks/storybook/blob/release/3.4/examples/polymer-cli/src/simple-button.html) And everything is working. |
Is the default webpack config transpiling them? |
Yes. Also, we have a babel step in it. Do you use an extended webpack config mode? |
Yeah (typescript), but the same issue would apply if you were to target evergreens only with your Babel config (ie: don't transpile). Same use-cases as outlined in initial issue. |
I see. |
You can try to remove this shim from the extended webpack config entry: {
manager: [require.resolve('./polyfills'), managerPath],
preview: [
require.resolve('./polyfills'), // <- replace this with a patched one
require.resolve('./globals'),
`${require.resolve('webpack-hot-middleware/client')}?reload=true`,
],
}, polyfills.js looks like this: import '@webcomponents/webcomponentsjs/webcomponents-lite';
import '@webcomponents/webcomponentsjs/custom-elements-es5-adapter'; // <-
import 'core-js/es6/symbol';
import 'core-js/fn/array/iterator';
import 'airbnb-js-shims';
import 'babel-polyfill'; you need to replace the |
Ah okay awesome. Is that documented somewhere? Must have missed it, tried to look for a way to do that before making this issue. If not, would be good to note it in the Not sure how those polyfills are treated in storybook, but worth noting that the es5 shim cannot be transpiled, or it breaks. FWIW still think the shim should be unbundled before 4.0 of the Polymer setup goes public, since it's a destructive 'polyfill' ( |
Tried this (had to update to |
This particular extension is not documented. But extending webpack config in common is documented, so it depends on the users' imagination of how to handle this =). But you are welcome to PR it to docs 😉
I can't advocate about this since hardly familiar with the polymer adoption / best practices, so would be nice to hear the pros and cons, and what actually people do.
Mind share the error ? CC. @stijnkoopal, if you have any thought. |
Haha I think that's a liberal use of 'imagination', since to fix it you'd have to dig through the src of
Fair enough - IMO it's generally an antipattern to bundle polyfills, especially when those polyfills aren't passive, ie: they require trade-offs or cause incompatibilities, which is certainly the case with the shim (not so much with webcomponentsjs). It's a nasty hack that is unfotunately required for transpiled classes, but it's destructive and fragile. But as long as there's an easy way to opt-out I guess it's not a big deal. Oh and FWIW not specific to Polymer, all this applies to web components in general (Stencil, SkateJS, etc).
Sorry false alarm, nuking my node_modules seems to have fixed it. Can't get my stories working for some reason anyway, and I suspect it's to do with |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook! |
This has not been solved yet, a story can't be created from a simple ES6 class, which prevents also the usage of other features like |
@jackblackCH let's continue discussion in the new issue #5531 which describes potential fix. |
Bug or support request summary
@storybook/polymer
currently bundles the webcomponents es5 shim (in the<head>
of the preview iframe) which makes it impossible to use storybook with untranspiled elements, since the shim throws on ES6 classes. Should leave it to the user to include the shim, and just put a note in the README.Use cases this breaks:
FWIW should also probably bundle
webcomponents-loader.js
rather thanwebcomponents-lite
, which feature detects what polyfills are needed (ie: none on Chrome). Or just not bundle the polyfills either, again leaving it to the user.Steps to reproduce
@storybook/polymer
Please specify which version of Storybook and optionally any affected addons that you're running
@storybook/polymer
4.0.0-alpha.3Using with
@polymer/lit-element
(Polymer 3), but same use cases would apply to Polymer 2.x.Affected platforms
The text was updated successfully, but these errors were encountered: