question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 https://github.com/storybooks/storybook/issues/4958#issuecomment-462071607 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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
daKmoRcommented, 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 🙈)

0reactions
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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Output an ES module using webpack - Stack Overflow
Firstly I would like to state the difference between the commonJS and commonJS2. CommonJS doesn't support the use of module.exports ...
Read more >
How to transpile ES modules with webpack and Node.js
Webpack bundles our code and outputs a transpiled version down to the target as specified in the configuration file. In our webpack ...
Read more >
Build with ES modules | ArcGIS Maps SDK for JavaScript 4.25
ES modules are an official, standardized module system for working with modern JavaScript that has been adopted by all the major browsers. The...
Read more >
Documentation - Modules - TypeScript
Module Output Target: What should my emitted JavaScript module look like? ES Module Syntax. A file can declare a main export via export...
Read more >
Publishing NPM Packages as Native ES Modules - Medium
Node.js has had native support for ES modules since version 14, ... be babel.config.cjs for the main es module output (and anything else ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found