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

Cannot import umd/commonjs bundle in stories #5778

Closed
ryancat opened this issue Feb 26, 2019 · 7 comments
Closed

Cannot import umd/commonjs bundle in stories #5778

ryancat opened this issue Feb 26, 2019 · 7 comments

Comments

@ryancat
Copy link

ryancat commented Feb 26, 2019

Describe the bug
Tried to import an umd bundle in stories file and got warning in webpack (v4) that cannot find exports from the bundle.

Further investigation leads to "no exports provided" for the umd bundle when webpack tries to bundle the stories. Compare to other cases where I import from source code, I found webpack is using harmony-module.js instead of module.js to process the module, which causing the umd bundle put exported stuff on global (window) instead of the exports object passed in.

The umd bundle is not a harmony (es6) module. It seems in this case webpack mistakenly think this is a harmony module. Since this is not happening in a different codebase, and I think storybook seems mixing its own webpack dependencies to the one on the host directory, I feel there maybe something wrong in how storybook use webpack.

To Reproduce
Steps to reproduce the behavior:

  1. Create a umd bundle with webpack 4
  2. In stories file, import something from that bundle.
  3. now run start-storybook

Expected behavior
Code compiles and I can get the things I imported from the bundle

System:

  • OS: MacOS
  • Version: 4.1.12
@stale
Copy link

stale bot commented Mar 20, 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 20, 2019
@agro286
Copy link

agro286 commented Mar 22, 2019

anything new here? i ran into the same problem

@stale stale bot removed the inactive label Mar 22, 2019
@ryancat
Copy link
Author

ryancat commented Mar 25, 2019

I think this problem may be gone after I upgrade to storybook v5.

@stale
Copy link

stale bot commented Apr 15, 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 Apr 15, 2019
@vdh
Copy link
Contributor

vdh commented May 9, 2019

So I managed to solve this issue by configuring sourceType to unambiguous in Babel (https://babeljs.io/docs/en/options#sourcetype) so that my UMD file wasn't treated as an ES6 module.

It was odd that I only encountered this in Storybook. In my normal setup, Webpack automatically hooks into the AMD define part of UMD modules. I assume there's something subtle happening between the different implicit Webpack / Babel configs…?

@stale stale bot removed the inactive label May 9, 2019
@stale
Copy link

stale bot commented May 30, 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 May 30, 2019
@stale
Copy link

stale bot commented Jun 29, 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!

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

4 participants