Can't resolve 'core-js/modules/es.string.replace' with Storybook 6.0.0-rc.13
See original GitHub issueDescribe the bug
I’m using myString.replace(regex)
in a custom addon with Storybook 6.0.0-rc.13 and getting the following error during the build process.
Can't resolve 'core-js/modules/es.string.replace' error when building.
This has happened with earlier RCs as well, but did work fine with 6.0.0-rc.0 so I’m guessing it’s related to the version of core-js being used under the covers.
Thanks in advance for any help on resolving this!
To Reproduce Steps to reproduce the behavior:
- Create a custom addon with a .jsx file in it
- Add a string.replace call into the .jsx file code:
let content = 'my content';
let output = content.replace(/^['"]|['"]$/g, '');
- Add the addon into main.js:
module.exports = {
stories: ['../src/**/*.stories.*'],
addons: [
'./my-addon/register'
]
}
- Build and run the project (npm start in my project) and the error appears.
Expected behavior Successful build
Screenshots
Code snippets
Here’s a simplified example of the code causing the error. If I remove the replace()
call the build works.
let content = 'some value';
return {
'data-link': content.replace(/^['"]|['"]$/g, '') // this line causes the build error (if removed the build works)
},
}
System:
Environment Info:
System: OS: macOS 10.15.5 CPU: (16) x64 Intel® Core™ i9-9900K CPU @ 3.60GHz Binaries: Node: 12.18.1 - ~/.nvm/versions/node/v12.18.1/bin/node Yarn: 1.22.4 - ~/.nvm/versions/node/v12.18.1/bin/yarn npm: 6.14.6 - ~/.nvm/versions/node/v12.18.1/bin/npm Browsers: Chrome: 84.0.4147.89 Edge: 84.0.522.40 Firefox: 73.0.1 Safari: 13.1.1 npmPackages: @storybook/addon-actions: 6.0.0-rc.13 => 6.0.0-rc.13 @storybook/addon-console: ^1.2.1 => 1.2.1 @storybook/addon-docs: 6.0.0-rc.13 => 6.0.0-rc.13 @storybook/addon-knobs: 6.0.0-rc.13 => 6.0.0-rc.13 @storybook/addon-links: 6.0.0-rc.13 => 6.0.0-rc.13 @storybook/addon-storysource: 6.0.0-rc.13 => 6.0.0-rc.13 @storybook/addons: 6.0.0-rc.13 => 6.0.0-rc.13 @storybook/preset-create-react-app: ^3.1.4 => 3.1.4 @storybook/react: 6.0.0-rc.13 => 6.0.0-rc.13
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:18 (5 by maintainers)
Top GitHub Comments
Step1: And in package.json like this: “@storybook/preset-create-react-app”: “^3.1.4”,
Step2: Add it in .storybook/main.js
just do it.
I had the same issue with stroybook v6 + React + Typescript and this solved my issue
.storybook/main.js
And .storybook/.babelrc
{ "presets": [ "babel-preset-react-app" ] }
And package.json
"babel-preset-react-app": "^9.1.2",