-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
3.3.6: ERROR in ./node_modules/@storybook/addon-knobs/src/react/index.js Module parse failed: Unexpected token (25:9) #2704
Comments
We |
Might be a babel configuration issue. Seems like Object spread might be disabled on your babel config for some reason? |
We don't have babel at all. |
Actually 25:9 points to the start of a JSX tag |
Are you suggesting storybook is now BYO babel? Did that happen from 3.2 to 3.3 and it only surfaces now in 3.3.6 when |
yes, I don't think it really matters what symbol it is - there could be all kinds of things in the ES6 source - the question is why it suddenly pulls in es6 source, where it should use the dist. |
I wonder if it is related to #2680 (comment) - @Hypnosphi WDYT? |
@joscha That is not really the goal. Though adding babel to your setup would solve the immediate problem you have, there's the question whether this is a good idea. We expose our src to enable users to bundle more efficiently and run with the native features, like async/await etc. BUT our src contains JSX, and this is not valid JS. I think we need to address this on our side. AKA not publish our source, but instead an JS:next version of it (transpiling the JSX). |
Definitely not, we are fully Typescript, babel is needed nowhere :)
That makes sense, but do you have any idea why it would suddenly use that? My understanding is that the |
@joscha Why it choose to use the src over dist, is because of this in the
I'm pretty sure, webpack will decide which file to use when bundling. |
That was my first hunch as well, but I believe that not to be correct because the webpack target is |
@joscha how does your webpack config for storybook look like? Is there a chance you lose the first loader from base config? Oh nevermind, it isn’t configured to transpile node_modules anyway. I think we should just revert all the |
Unfortunately, it kinda is, but only in the sense that you need |
I think that would be good, then at least we wouldn't break existing behaviour.
I think that is unfortunate, it makes the assumption that people using storybook will use babel. That is definitely not always the case. Also, this babel would need to be configured, right? How would a consumer with no babel in the rest of the codebase configure such a babel? By inheriting loaders from the default webpack config? In any case, I think this needs some documentation for upgraders from 3.2 to 3.3.x. |
Not really, you only need the package to be present
Sure: #2709 |
The weirdest part about it is that Is there a chance that you use some webpack |
I have the same exact issue with 3.4.0-alpha.1 I also am using 100% TypeScript based React app. The project was created with create react app typescript and then ejected. And if @joscha Have you seen any good Storybook alternatives? Unfortunately this isn't the first configuration issue I have had trying to use Storybooks with TypeScript and I am losing confidence that they will be resolved. It seems that as of late things are centered around compliance with Angular. |
Using exact version of 3.3.3 doesn't have this issue. |
As bizarre as it is, I am inclined to agree with @Hypnosphi that it seems like the problem is @joscha / @TroySchmidt any chance of a reproduction or some information on what your webpack config for storybook looks like? Specifically your |
@TroySchmidt obviously as more and more different types of apps are supported things will slip through the cracks (still don't even quite know which crack has been slipped through in this case!). Always keen to have more eyes and helpers to test and resolve issues with different combinations of configuration in the weird and wonderful world of JS! |
This seems to work as a temporary workaround, haven't tested extensively. config.plugins.push(
new webpack.NormalModuleReplacementPlugin(/^react$/, resource => {
if (!/addon-knobs/.test(resource.context)) return;
resource.request = require.resolve("react");
}),
); |
I wish I was smarter in the innards of Webpack and what is happening. The only special Webpack I have to work with typescript is it imports the Webpack from storybook and appends a loader for TypeScript ts-loader. |
So I managed to create a repository to reproduce this issue: I believe the issue is caused when the Webpack resolve module setting is overridden: If you set I think the proper way to override this setting in a custom Webpack config would be something like this: config.resolve.modules = ["node_modules", path.resolve(__dirname, "../src")]; |
Yes, you definitely should use an absolute path for this option |
That fixed it!! I remember what happened now. The path include wasn't there on the Webpack configuration example when I added it so I removed the path.resolve from the push onto |
@TroySchmidt sorry, I can't find a |
@Hypnosphi hahaha I just looked again and updated the comment while you were typing that response. I looked at the history and the |
we have a |
I wonder where this is coming from. Is there a documentation issue somewhere? Let's try to fix it. |
making
so I think it would just be a problem for upgraders where it previously worked by accident (e.g. we never intended to have |
I am using nextjs, which means I have no src folder :'(!!! |
Issue details
When updating from 3.3.5 to 3.3.6, this error appears:
It seems to be related to the
src
folder being exposed, via #2678.When
rm -rf node_modules/@storybook/addon-knobs/src/
this fixes the problem.Strangely none of the other add-ons seem affected:
Steps to reproduce
just start storybook
Please specify which version of Storybook and optionally any affected addons that you're running
via
yarn list | grep @storybook
The text was updated successfully, but these errors were encountered: