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
Webpack v5 Upgrade - start-storybook works but build-storybook fails
#13893
Comments
|
Hey @lanesawyer! Storybook doesn't currently support Webpack 5. You can check out the ongoing progress in #13808 I'm going to close this up because the webpack 5 epic is #9216 |
|
I encounter exactly this when trying to follow https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324 Reproduction: https://github.com/JetBrains/ring-ui/tree/webpack-5 npm install
npm run bootstrap
npm run build |
|
@Hypnosphi OK I figured it out. The problem is that you're using a custom addon (called a preset in your codebase, but we're calling everything addons now -- the documentation and presets repo haven't caught up yet), and that uses webpack. Since Storybook uses There are also some hoisting-related issues ( |
|
@shilman I see. I think I'll just extract custom-header into a separate lerna package with its own dependencies |
|
@lanesawyer Did you manage to solve the issue you had regarding the build-storybook ? I'm having the exact same problem and I tried so many different alpha versions including #14044 but none works |
|
@lanesawyer @marjisound very interested in identifying the failure modes, so if you (or anybody else) is experiencing this issue and have a repro repo I'd be happy to take a look |
|
We are running into this issue in the https://gitlab.com/riovir/vue-app-scaffolding repository which can be used as a reproduction. It currently breaks on the v11.6.0 tag. Reproduction recipe:
Your prior suggestion to install the |
|
@jessevanassen thanks for the repro! however, i'm having trouble getting it: |
|
EDIT: I've added a line to bump Storybook to its latest version. (Original sample was still at BETA 5.) You may want to use the https format of the repo: Hope it helps! |
|
@riovir thanks for this. i haven't gotten to the bottom of it yet, but my guess is it's a hoisting issue. I reinstalled with |
Thanks @shilman We actually managed to fix the But now we are having a new issue on both build-storybook & start-storybook for ts-loader module build |
|
The majority of the times that I've had erratic Some of this might be better in the webpack 5 thread, but ive built both the preview and manager with webpack 5 with relatively few changes (though that use case is limited to the react framework) One thing I would definitely search for is multiple versions of With just a clean install of with addons and so on, you can end up with many more. If you are running entirely on webpack 5 (as would seem to be the case for you @marjisound), I would suggest identifying locations where things are doubled up or more For example with Any single instance of one of these can trigger errors like you've seen if you're trying to use a webpack5 only build env As a side note, the packages were populated with yarn |
|
@marjisound's |
|
I'm also experiencing this issue unfortunately |
|
Some additional information from my end, I currently have the following (dev) dependencies: "dependencies": {
"html-react-parser": "^1.2.4",
"react-spring": "^8.0.27",
"styled-components": "^5.2.3",
"uuid": "^8.3.2"
},
"devDependencies": {
"@babel/core": "^7.13.14",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-proposal-object-rest-spread": "^7.13.8",
"@babel/preset-env": "^7.13.12",
"@babel/preset-react": "^7.13.13",
"@babel/preset-typescript": "^7.13.0",
"@commitlint/cli": "^12.1.1",
"@commitlint/config-conventional": "^12.1.1",
"@iteratec/semantic-release-bitbucket": "^1.1.1",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/commit-analyzer": "^8.0.1",
"@semantic-release/git": "^9.0.0",
"@semantic-release/npm": "^7.0.9",
"@semantic-release/release-notes-generator": "^9.0.2",
"@storybook/addon-a11y": "^6.2.5",
"@storybook/addon-actions": "^6.2.5",
"@storybook/addon-docs": "^6.2.5",
"@storybook/addon-knobs": "^6.2.5",
"@storybook/addon-links": "^6.2.5",
"@storybook/addon-storyshots": "^6.2.5",
"@storybook/addon-storysource": "^6.2.5",
"@storybook/addon-viewport": "^6.2.5",
"@storybook/core": "^6.2.5",
"@storybook/preset-typescript": "^3.0.0",
"@storybook/react": "^6.2.5",
"@storybook/source-loader": "^6.2.5",
"@types/jest": "^26.0.22",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"@types/react-helmet": "^6.1.0",
"@types/react-test-renderer": "^17.0.1",
"@types/styled-components": "^5.1.9",
"@types/uuid": "^8.3.0",
"@types/webpack": "^4.41.27",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"audit-ci": "^3.2.0",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.2",
"babel-plugin-require-context-hook": "^1.0.0",
"babel-plugin-styled-components": "^1.12.0",
"commitizen": "^4.2.3",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.23.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-jest": "^24.3.4",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.23.1",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "^4.3.8",
"jest": "^26.6.3",
"jest-styled-components": "^7.0.3",
"prettier": "^2.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-is": "^17.0.2",
"react-test-renderer": "^17.0.2",
"rimraf": "^3.0.2",
"semantic-release": "^17.4.2",
"serverless": "^1.83.3",
"serverless-s3-deploy": "^0.9.0",
"typescript": "^4.2.4",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12"
}I'm in the process of updating of all my dependencies, this is the result of @semantic-release/npm 7.0.9 7.1.0 7.1.0 @codedazur/react-components
@types/webpack 4.41.27 4.41.27 5.28.0 @codedazur/react-components
husky 4.3.8 4.3.8 6.0.0 @codedazur/react-components
react-spring 8.0.27 8.0.27 9.0.0 @codedazur/react-components
webpack 4.46.0 4.46.0 5.31.0 @codedazur/react-components
webpack-cli 3.3.12 3.3.12 4.6.0 @codedazur/react-componentsWith this setup everything is working fine. Now let's try to update to Webpack 5:
Added the following part to my core: {
builder: "webpack5",
}After this when I try to start Storybook I get the following error: 10% building 0/14 entries 1/14 dependencies 0/0 modules(node:23201) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'createSnapshot' of undefined
at /Users/daviddelusenet/Development/react-components/node_modules/html-webpack-plugin/lib/webpack5/file-watcher-api.js:13:36
at new Promise (<anonymous>)
at Object.createSnapshot (/Users/daviddelusenet/Development/react-components/node_modules/html-webpack-plugin/lib/webpack5/file-watcher-api.js:12:10)
at /Users/daviddelusenet/Development/react-components/node_modules/html-webpack-plugin/lib/cached-child-compiler.js:219:35
(node:23201) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:23201) [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.
99% done plugins webpack-hot-middlewarewebpack built preview 0f13fed3c7c293f9d2aa in 25450ms
(node:23201) UnhandledPromiseRejectionWarning: TypeError: compilation.getAssetPath is not a function
at /Users/daviddelusenet/Development/react-components/node_modules/html-webpack-plugin/index.js:169:25
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/daviddelusenet/Development/react-components/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:25:1)
at AsyncSeriesHook.lazyCompileHook (/Users/daviddelusenet/Development/react-components/node_modules/tapable/lib/Hook.js:154:20)
at Compiler.emitAssets (/Users/daviddelusenet/Development/react-components/node_modules/@storybook/core-server/node_modules/webpack/lib/Compiler.js:491:19)
at onCompiled (/Users/daviddelusenet/Development/react-components/node_modules/@storybook/core-server/node_modules/webpack/lib/Watching.js:51:19)
at /Users/daviddelusenet/Development/react-components/node_modules/@storybook/core-server/node_modules/webpack/lib/Compiler.js:681:15
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/daviddelusenet/Development/react-components/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1)
at AsyncSeriesHook.lazyCompileHook (/Users/daviddelusenet/Development/react-components/node_modules/tapable/lib/Hook.js:154:20)
at /Users/daviddelusenet/Development/react-components/node_modules/@storybook/core-server/node_modules/webpack/lib/Compiler.js:678:31
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/daviddelusenet/Development/react-components/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:7:1)
at AsyncSeriesHook.lazyCompileHook (/Users/daviddelusenet/Development/react-components/node_modules/tapable/lib/Hook.js:154:20)
at /Users/daviddelusenet/Development/react-components/node_modules/@storybook/core-server/node_modules/webpack/lib/Compilation.js:1423:35
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/daviddelusenet/Development/react-components/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:7:1)
at AsyncSeriesHook.lazyCompileHook (/Users/daviddelusenet/Development/react-components/node_modules/tapable/lib/Hook.js:154:20)
at /Users/daviddelusenet/Development/react-components/node_modules/@storybook/core-server/node_modules/webpack/lib/Compilation.js:1414:32
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/daviddelusenet/Development/react-components/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:7:1)
(node:23201) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)After some Googling I found this issue and running And when I try to build Storybook I get the following error: /Users/daviddelusenet/Development/react-components/node_modules/webpack/lib/javascript/JavascriptModulesPlugin.js:113
throw new TypeError(
^
TypeError: The 'compilation' argument must be an instance of Compilation
at Function.getCompilationHooks (/Users/daviddelusenet/Development/react-components/node_modules/webpack/lib/javascript/JavascriptModulesPlugin.js:113:10)
at /Users/daviddelusenet/Development/react-components/node_modules/terser-webpack-plugin/dist/index.js:571:67
at SyncHook.eval [as call] (eval at create (/Users/daviddelusenet/Development/react-components/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:85:1)
at SyncHook.lazyCompileHook (/Users/daviddelusenet/Development/react-components/node_modules/tapable/lib/Hook.js:154:20)
at Compiler.newCompilation (/Users/daviddelusenet/Development/react-components/node_modules/@storybook/core-server/node_modules/webpack/lib/Compiler.js:631:26)
at /Users/daviddelusenet/Development/react-components/node_modules/@storybook/core-server/node_modules/webpack/lib/Compiler.js:667:29
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/daviddelusenet/Development/react-components/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
at AsyncSeriesHook.lazyCompileHook (/Users/daviddelusenet/Development/react-components/node_modules/tapable/lib/Hook.js:154:20)
at Compiler.compile (/Users/daviddelusenet/Development/react-components/node_modules/@storybook/core-server/node_modules/webpack/lib/Compiler.js:662:28)
at /Users/daviddelusenet/Development/react-components/node_modules/@storybook/core-server/node_modules/webpack/lib/Compiler.js:321:11
at Array.<anonymous> (/Users/daviddelusenet/Development/react-components/node_modules/@storybook/core-server/node_modules/webpack/lib/Compiler.js:534:20)
at Storage.finished (/Users/daviddelusenet/Development/react-components/node_modules/@storybook/core-server/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /Users/daviddelusenet/Development/react-components/node_modules/@storybook/core-server/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
at callback (/Users/daviddelusenet/Development/react-components/node_modules/graceful-fs/polyfills.js:295:20)
at FSReqCallback.oncomplete (fs.js:167:21)Please let me know if you need any more information. |
|
I ran into a similar problem and had to install both So in the previous comment by @daviddelusenet, the first stacktrace includes the following on the second line. Installing The last snippet in that same comment includes the following on the second line. This indicates that Hope this helps anyone ✌🏼 |
This solved the problem for us too |
|
Just to chime in, I have hit precisely the same issue as @Hypnosphi has above using webpack 5.33.2 |
|
Same issue for me as @Hypnosphi has above using |
|
Same issue with webpack 5. Is there any workaround around ? |
|
This is your answer: https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324#upgrade |
|
@milosrs I have tried this |
|
@LeoRosse Delete |
|
Still not working for me with your procedure @milosrs . I never had |
|
same as @SimTheFool for me @milosrs .. I haven't created the project with create react app and I tried with |
|
What are the versions of your storybook and addons? |
|
I got those plugins in package.json after installing storybook in the way you recommended. |
|
Same for me! |
|
I cant help you since I |
|
I didn't have |
|
I install terser-webpack-plugin by way of |
|
Hi, it's been several days since i stuck with the issue, i tried all the solution but no luck. will be please help me out. issue is : start-storybook works but build-storybook failsstart-storybook works smooth with add-ons as well. but build-storybook fails, if i add any of the addons in .storybook.main.ts error is:
and also if i remove addons then also its fails and throw an error:
my configurations are: its a web component package library by open-wc generator. then i upgraded that to latest storybook for sass support. everything is working except build-storybook project dependencies and dev-dependencies are:
and main.js is: `const path = require('path'); module.exports = { and my-preset is: `const path = require('path'); module.exports = { }, |
|
I think this has to do with the storybook init installing both the webpack 4 and webpack 5 packages. The dependency for terser-webpack-plugin in webpack 4 is trumping the one in webpack 5 so it is breaking when trying to build with webpack 5. Manually installling terser-webpack-plugin then fixes the dependency but I think the ultimate fix should be for Storybook to remove all of the webpack 4 packages for users using webpack 5. |
|
In my case the same lines (suggested by @PascalPixel) helpme to fix the error on build:
I guess it has to do with dependencies. in my case use, React, Typescript, and react-doc-gen This is the result of |
|
I've (FINALLY) found a solution to this problem, hope it helps to somebody! Cheers! :) |
|
I encountered a similar issue with the terser pluggin ( Storybook v7.0.0-alpha.47 + Angular 13 ), my workarround was to apply the following change in the webpackFinal parameter of |
Any updates? I encountered the same issue. |
Describe the bug
I recently upgrade my project to Webpack v5. The
start-storybookcommand works just fine, but when I runbuild-storybook, I get the following error:I saw a similar error with the
html-webpack-plugin, so it may just be that Storybook 6 is incompatable with Webpack 5, but it's strange thatstart-storybookworks whilebuild-storybookfails.To Reproduce
Use Storybook with Webpack v5.
Expected behavior
I would expect that a working
start-storybookimplies thatbuild-storybookworks as well. It's a bit confusing to have my normal Storybook workflow work perfectly but the build tools are unable to build. How doesstart-storybookactually work if it's not building the Storybook?System
Environment Info:
System:
OS: Windows 10 10.0.18363
CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Binaries:
Node: 14.15.1 - C:\Program Files\nodejs\node.EXE
npm: 7.5.3 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 88.0.4324.150
Edge: Spartan (44.18362.449.0)
npmPackages:
@storybook/addon-actions: ^6.1.11 => 6.1.11
@storybook/addon-links: ^6.1.11 => 6.1.11
@storybook/addons: ^6.1.11 => 6.1.11
@storybook/preset-typescript: ^3.0.0 => 3.0.0
@storybook/react: ^6.1.11 => 6.1.11
@storybook/storybook-deployer: ^2.8.7 => 2.8.7
The text was updated successfully, but these errors were encountered: