Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: wrap-require migration causing an error when upgrading storybook from 7.0.20 -> 7.1.1 #23637

Closed
dannyk3941 opened this issue Jul 27, 2023 · 0 comments · Fixed by #23644
Assignees

Comments

@dannyk3941
Copy link

Describe the bug

We have a npm monorepo setup with workspaces but we only have 1 package with HTML storybook set up. Our plan for the near future is to add more workspaces with other frameworks and also create storybooks for those workspaces. During upgrade from 7.0.20 to 7.1.1, if we run the migration for wrap-require, starting storybook fails and outputs this error:

@storybook/cli v7.1.1

ERR! SyntaxError: Cannot use import statement outside a module
ERR!     at Object.compileFunction (node:vm:352:18)
ERR!     at wrapSafe (node:internal/modules/cjs/loader:1033:15)
ERR!     at Module._compile (node:internal/modules/cjs/loader:1069:27)
ERR!     at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
ERR!     at Object.newLoader (/[compname-redacted]/design-system/node_modules/esbuild-register/dist/node.js:2262:9)
ERR!     at Object.extensions..js (/[compname-redacted]/design-system/node_modules/esbuild-register/dist/node.js:4807:24)
ERR!     at Module.load (node:internal/modules/cjs/loader:981:32)
ERR!     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
ERR!     at Module.require (node:internal/modules/cjs/loader:1005:19)
ERR!     at require (node:internal/modules/cjs/helpers:102:18)
ERR!  SyntaxError: Cannot use import statement outside a module
ERR!     at Object.compileFunction (node:vm:352:18)
ERR!     at wrapSafe (node:internal/modules/cjs/loader:1033:15)
ERR!     at Module._compile (node:internal/modules/cjs/loader:1069:27)
ERR!     at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
ERR!     at Object.newLoader (/[compname-redacted]/design-system/node_modules/esbuild-register/dist/node.js:2262:9)
ERR!     at Object.extensions..js (/[compname-redacted]/design-system/node_modules/esbuild-register/dist/node.js:4807:24)
ERR!     at Module.load (node:internal/modules/cjs/loader:981:32)
ERR!     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
ERR!     at Module.require (node:internal/modules/cjs/loader:1005:19)
ERR!     at require (node:internal/modules/cjs/helpers:102:18)

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

npm ERR! Lifecycle script `storybook` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: @cbpds/[email protected] 
npm ERR!   at location: /[compname-redacted]/design-system/packages/vanilla

Testing this further, upgrading the workspace without running the wrap-require migration works fine, including adding another workspace with storybook, but I wanted see if there was any insight as storybook monorepo support is important for this project. We don't use Nx or Turborepo for our monorepo.

To Reproduce

https://github.com/US-CBP/design-system

  1. Clone repo
  2. Run npm install
  3. Run npm vanilla-build
  4. Run cd packages/vanilla
  5. Run npx storybook@latest upgrade
  6. Choose "yes" to wrap-require
  7. Run npm run storybook

System

Environment Info:

  System:
    OS: macOS 13.4.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v16.16.0/bin/npm
  Browsers:
    Chrome: 115.0.5790.114
    Edge: 115.0.1901.183
    Safari: 16.5.1
  npmPackages:
    @storybook/html: ^7.1.1 => 7.1.1

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants