storybook: [CRA] dynamic Import don't work
Describe the bug
If using dynamic import, throw error Support for the experimental syntax 'dynamicImport' isn't currently enabled. But in CRA don’t have the error.
To Reproduce Steps to reproduce the behavior:
- Create a new project with CRA and SB
- Use dynamic import
- See error
System:
- OS: [MacOS]
- Framework: CRA 2.0.5
- Version: [e.g. 4.0.4]
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 24 (20 by maintainers)
As a workaround, you can create
.babelrcin the.storybookdir with something like this:(Maybe some other plugins/presets will be needed)
@Hypnosphi , WYT about adding this by default ? looks like CRA uses it
Came across this today - took some digging, but eventually found a solution.
The bug is actually in webpack, which storybook uses.
It is this: https://github.com/webpack/webpack/issues/8656
The solution is to install the correct version of
acornMaybe worth doing the whole
rm -rf node_modules && rm package-lock.jsonthing as well.For completeness, here is the .babelrc file that worked with our project:
.babelrc
and relevant devdeps from
package.json:Released in alpha: https://github.com/storybooks/storybook/releases/tag/v4.1.0-alpha.8
Hi @igor-dv, This code exists in one of my components:
Which yielded this error:
I’ve tried adding the recommended plugins to a babelrc file and running storybook v4.1.0-alpha.8, the error persists.
This issue persists in both alpha and with .babelrc added. Any update on this?