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

Default webpack excludes .jsx files in 'node_modules' from being compiled by Webpack #1119

Closed
danielduan opened this issue May 24, 2017 · 4 comments

Comments

@danielduan
Copy link
Member

If I have a set of JSX modules in an npm package and I want to import them to use in a story, I get an error that says I need the appropriate loader. In our default webpack config, we exclude node_modules from our JSX loader.

https://github.com/storybooks/storybook/blob/master/app/react/src/server/config/webpack.config.js#L37
https://github.com/storybooks/storybook/blob/master/app/react/src/server/config/utils.js#L5

Most component modules like Airbnb's React Datepicker actually transpile to ES5 when exporting to CommonJS so both the original JSX and the ES5 version are available. If we import the transpiled ES5 file, we lose the ability to use react-docgen to provide automatic documentation generation.

The question is, should I just reconfigure the loader on my end or is it beneficial if I remove the excludePaths from .jsx in our default config in our codebase?

@ndelangen
Copy link
Member

Really good question! I would like to ask more webpack experts on this matter.

@shilman
Copy link
Member

shilman commented May 27, 2017

Definitely NOT a webpack expert, but I would be concerned about the performance implications of this change. Have noticed (I think! Have not tested rigorously!) increased build times when I remove excludePaths, etc. So we would probably want to make sure that's not the case before loosening anything up.

@Gongreg
Copy link
Member

Gongreg commented May 30, 2017

Iirc according to webpack it is a bad idea to include node_modules to the compilation (as shilman said because of performance and compilation time issues). Users should manually include those node modules that they want to be compiled.

@danielduan
Copy link
Member Author

I'm gonna close this issue since I think it's better to leave as is than to remove the excluded node_modules.

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