question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Static builds fail while dev-server works fine, getCode() is undefined error

See original GitHub issue

Describe 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:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
weyertcommented, Dec 31, 2019

@shamin I have made a PR for it 😃 And Happy New Year 😃

0reactions
apefrowncommented, Jan 2, 2020

Unfortunately the addition of simplify: false in the babel-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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error in webpack during build but not dev: "ERROR in static ...
It occurred when I ran npm run build , but everything worked fine using the webpack dev server ( npm run dev )....
Read more >
Errors | Node.js v19.3.0 Documentation
Creates a .stack property on targetObject , which when accessed returns a string representing the location in the code at which Error.captureStackTrace() ......
Read more >
Parcel
A build tool for the rest of us. ... Parcel starts with a great development experience, from starting a new project, to iterating...
Read more >
create react app env variables not loading - You.com
In react-scripts 0.8.2 this was working without a problem. Fonts were loading correctly. When I check the loaded css, I see that url()...
Read more >
All Problems Tagged With Whatever - Code Grepper
Get code examples instantly right from your google search results with the Grepper Chrome Extension.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found