Static builds fail while dev-server works fine, getCode() is undefined error
See original GitHub issueDescribe the bug
I am having an issue with Storybook failing to make a successful static build using build-storybook
-command while start-storybook
-command is working as expected.
I noticed when change the file @storybook/core/dist/server/common/babel.js
in such manner that the createProdPresets
-method doesn’t return the babel-preset-minify
the build is succesful. For example, like this:
function createProdPresets() {
return [
// [
// require.resolve('babel-preset-minify'), {
// builtIns: false,
// mangle: false
// }
// ]
];
}
The following errors is given by Storybook when building:
➜ yarn run storybook:build
yarn run v1.21.1
$ build-storybook -o other/public/storybook
info @storybook/react v5.3.0-rc.4
info
info clean outputDir..
info => Copying prebuild dll's..
info => Building manager..
info => Loading manager config..
info => Loading presets
info => Loading custom manager config.
info => Compiling manager..
ERR! => Failed to build the manager
ERR! ./.storybook/addons.js
ERR! Module build failed (from ./node_modules/babel-loader/lib/index.js):
ERR! TypeError: /Users/weyertdeboer/experiment/.storybook/addons.js: Cannot read property 'getCode' of undefined
ERR! at NodePath.getSource (/Users/weyertdeboer/experiment/node_modules/@babel/traverse/lib/path/introspection.js:150:27)
ERR! at PluginPass.Program (/Users/weyertdeboer/experiment/node_modules/babel-plugin-minify-simplify/lib/index.js:490:41)
ERR! at newFn (/Users/weyertdeboer/experiment/node_modules/@babel/traverse/lib/visitors.js:179:21)
ERR! at NodePath._call (/Users/weyertdeboer/experiment/node_modules/@babel/traverse/lib/path/context.js:55:20)
ERR! at NodePath.call (/Users/weyertdeboer/experiment/node_modules/@babel/traverse/lib/path/context.js:42:17)
ERR! at NodePath.visit (/Users/weyertdeboer/experiment/node_modules/@babel/traverse/lib/path/context.js:90:31)
ERR! at TraversalContext.visitQueue (/Users/weyertdeboer/experiment/node_modules/@babel/traverse/lib/context.js:112:16)
ERR! at TraversalContext.visitSingle (/Users/weyertdeboer/experiment/node_modules/@babel/traverse/lib/context.js:84:19)
ERR! at TraversalContext.visit (/Users/weyertdeboer/experiment/node_modules/@babel/traverse/lib/context.js:140:19)
ERR! at Function.traverse.node (/Users/weyertdeboer/experiment/node_modules/@babel/traverse/lib/index.js:84:17)
ERR! at traverse (/Users/weyertdeboer/experiment/node_modules/@babel/traverse/lib/index.js:66:12)
ERR! at transformFile (/Users/weyertdeboer/experiment/node_modules/@babel/core/lib/transformation/index.js:119:29)
ERR! at runSync (/Users/weyertdeboer/experiment/node_modules/@babel/core/lib/transformation/index.js:48:5)
ERR! at runAsync (/Users/weyertdeboer/experiment/node_modules/@babel/core/lib/transformation/index.js:35:14)
ERR! at /Users/weyertdeboer/experiment/node_modules/@babel/core/lib/transform.js:34:34
ERR! at processTicksAndRejections (internal/process/task_queues.js:75:11)
ERR! @ multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./.storybook/addons.js ./node_modules/@storybook/core/dist/client/manager/index.js main[1]
(node:45258) UnhandledPromiseRejectionWarning: [object Object]
(node:45258) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:45258) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
To Reproduce Still working on a reproducible case
Expected behavior
I would expect that running build-storybook
-command would succeed without errors just like running the start-storybook
-command
Code snippets If applicable, add code samples to help explain your problem.
System:
Environment Info:
System:
OS: macOS 10.15.2
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
Node: 12.14.0 - ~/.nodenv/versions/12.14.0/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.4 - ~/.nodenv/versions/12.14.0/bin/npm
Browsers:
Chrome: 79.0.3945.88
Firefox: 70.0.1
Safari: 13.0.4
npmPackages:
@storybook/addon-a11y: next => 5.3.0-rc.4
@storybook/addon-actions: next => 5.3.0-rc.4
@storybook/addon-console: ^1.2.1 => 1.2.1
@storybook/addon-contexts: next => 5.3.0-rc.4
@storybook/addon-info: next => 5.3.0-rc.4
@storybook/addon-jest: next => 5.3.0-rc.4
@storybook/addon-notes: next => 5.3.0-rc.4
@storybook/addon-viewport: next => 5.3.0-rc.4
@storybook/react: next => 5.3.0-rc.4
Additional context
I am using a customised version of kcd-scripts
which adds TypeScript support for babel
and webpack
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
@shamin I have made a PR for it 😃 And Happy New Year 😃
Unfortunately the addition of
simplify: false
in thebabel-preset-minify
options in v5.3.0-rc.7 doesn’t resolve a similar issue for me.Removing
builtIns: false
does allow the static build of my Storybook though.