Skip to content
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

Core: ES modules output target for iframe-webpack-config #5531

Closed
web-padawan opened this issue Feb 9, 2019 · 6 comments
Closed

Core: ES modules output target for iframe-webpack-config #5531

web-padawan opened this issue Feb 9, 2019 · 6 comments

Comments

@web-padawan
Copy link
Contributor

web-padawan commented Feb 9, 2019

Is your feature request related to a problem? Please describe.
The problem is that certain browser standards (specifically, Custom Elements) need native ES2015 classes to work properly. Otherwise, when transpiled to ES5, special shim is needed to prevent issues like #3497 to happen. This is actually already used by @storybook/polymer:
https://github.com/storybooks/storybook/blob/bbcbf7c4d41b979498c0dafc260d24b4c2dc2d94/app/polymer/src/client/preview/globals.js#L2

At the same time, Chrome, Safari and Firefox support ES modules natively, and the tools like Vue CLI already allow to produce "modern" and "legacy" builds to serve module and nomodule bundles.
Same set of browsers also natively supports Custom Elements specification (+ hopefully Edge soon).

What I'm suggesting is to integrate the webpack plugin which our team has been evaluating and it generally solves the described problem really well, especially when using with HtmlWebpackPlugin.

Describe the solution you'd like
Use webpack-babel-multi-target-plugin to provide ES module bundle for evergreen browsers supporting modules, and nomodule bundle as a fallback for older browsers.

Describe alternatives you've considered
The custom plugin could be implemented for using in Storybook only, but that's like extra effort.

Are you able to assist bring the feature to reality?
I can help with integrating the plugin as I mentioned in #4958 (comment)
But I would need some guidance from the maintainers.

Additional context
I have created a very basic example of using webpack-babel-multi-target plugin here:
https://github.com/web-padawan/webpack-wc-demo

This will fix #3497 and will make implementation of #4958 a very straightforward task.

@daKmoR
Copy link
Contributor

daKmoR commented Feb 11, 2019

another benefit of this would be that currently if you have any es6 code in your node_modules then it does not get transpiled as there is an exclude for all inside node_modules...

using above mentioned plugin also goes through each package and checks if it needs transpilation and applies it if needed (e.g. there is a "module" in package.json)

So there would be no global exclude for node_modules anymore... (which currently requires some strange workarounds with regex and stuff 🙈)

@web-padawan
Copy link
Contributor Author

Tagging @DanielSchaffer who is the author of the plugin I'm suggesting to integrate.

Also, note there is a proposal for the plugin API changes, which might make sense in scope of integrating the plugin to Storybook core: DanielSchaffer/webpack-babel-multi-target-plugin#21

@stale
Copy link

stale bot commented Mar 4, 2019

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!

@stale stale bot added the inactive label Mar 4, 2019
@web-padawan
Copy link
Contributor Author

I'm still interested but haven't got any time to take a closer look. Will try to do it this week.

@stale
Copy link

stale bot commented Mar 25, 2019

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!

@stale stale bot added the inactive label Mar 25, 2019
@stale
Copy link

stale bot commented Apr 24, 2019

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!

@stale stale bot closed this as completed Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants