storybook@6 throws a core-js error
See original GitHub issueWith storybook 6, my very basic typescript setup throws errors about core-js polyfills every time.
Module not found: Error: Can't resolve 'core-js/modules/web.dom-collections.iterator'
this is thrown from ‘generated-stories-entry’. i can see earlier in the webpack output that the polyfill was built:
[./node_modules/@storybook/core/dist/server/common/polyfills.js] 120 bytes {vendors~main} [built]
which afaik is where you include core-js.
with storybook 5, this works just fine. its a clean setup from today, npm i -D @storybook/html
(5 or 6) and this config:
module.exports = {
stories: ['../src/**/*.stories.ts'],
webpackFinal: (config) => {
config.module.rules.push({
test: /\.ts$/,
use: [
{loader: require.resolve('ts-loader')}
]
});
config.resolve.extensions.push('.ts');
return config;
}
};
I think this is because there are multiple core-js versions in my node_modules and storybook is resolving the wrong one (somehow). if i look at the one inside storybook’s packages, its got the right files.
this isn’t something i should have to ‘fix’ though IMO, as so many dependencies use core-js it seems like a very likely situation for many to bump into. my guess is you can fix it by installing core-js as a direct dependency but thats also far from ideal.
EDIT:
Temporary workaround
If you’ve come across this issue while searching, we do not yet have a solution merged in (this issue will close when we do). However, there is a workaround: simply install core-js@3 as a direct dependency (npm i -D core-js@3
).
If that doesn’t work for you, please do comment so we are aware in case there are some other edge cases.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:63
- Comments:73 (25 by maintainers)
Top GitHub Comments
just a reminder that now that you published 6.0 officially, this is still a problem.
it is very awkward having to install
core-js
directly in each repo we use storybook for. do you have any suggested fix on your end for this? anything we can contribute to help?Zoinks!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.2.0-alpha.0 containing PR #13055 that references this issue. Upgrade today to the
@next
NPM tag to try it out!Closing this issue. Please re-open if you think there’s still more to do.