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

Storybook 6.4 build failing with Angular 13.1 #16977

Closed
dkimmich-onventis opened this issue Dec 10, 2021 · 94 comments
Closed

Storybook 6.4 build failing with Angular 13.1 #16977

dkimmich-onventis opened this issue Dec 10, 2021 · 94 comments

Comments

@dkimmich-onventis
Copy link

Describe the bug
Angular 13.1 was released yesterday, however when trying to build Storybook 6.4 with Angular 13.1, there is an error thrown:

ERR! TypeError: getTypescriptWorkerPlugin is not a function
ERR!     at /sb-angular13.1-repro/node_modules/@storybook/angular/dist/ts3.9/server/angular-cli-webpack-13.x.x.js:79:206
ERR!     at /sb-angular13.1-repro/node_modules/@angular-devkit/build-angular/src/utils/webpack-browser-config.js:72:16
ERR!     at generateWebpackConfig (/sb-angular13.1-repro/node_modules/@angular-devkit/build-angular/src/utils/webpack-browser-config.js:61:40)
ERR!     at async generateBrowserWebpackConfigFromContext (/sb-angular13.1-repro/node_modules/@angular-devkit/build-angular/src/utils/webpack-browser-config.js:123:20)
ERR!     at async generateI18nBrowserWebpackConfigFromContext (/sb-angular13.1-repro/node_modules/@angular-devkit/build-angular/src/utils/webpack-browser-config.js:70:20)
ERR!  TypeError: getTypescriptWorkerPlugin is not a function
ERR!     at /sb-angular13.1-repro/node_modules/@storybook/angular/dist/ts3.9/server/angular-cli-webpack-13.x.x.js:79:206
ERR!     at /sb-angular13.1-repro/node_modules/@angular-devkit/build-angular/src/utils/webpack-browser-config.js:72:16
ERR!     at generateWebpackConfig (/sb-angular13.1-repro/node_modules/@angular-devkit/build-angular/src/utils/webpack-browser-config.js:61:40)
ERR!     at async generateBrowserWebpackConfigFromContext (/sb-angular13.1-repro/node_modules/@angular-devkit/build-angular/src/utils/webpack-browser-config.js:123:20)
ERR!     at async generateI18nBrowserWebpackConfigFromContext (/sb-angular13.1-repro/node_modules/@angular-devkit/build-angular/src/utils/webpack-browser-config.js:70:20)

To Reproduce
Basically you just need to run npx sb@next repro and select angular. It's already broken then.

https://github.com/dsimon-onventis/sb-angular13.1

System
Environment Info:

System:
OS: Linux 5.10 Ubuntu 20.04.3 LTS (Focal Fossa)
CPU: (8) x64 Intel(R) Core(TM) i5-8365U CPU @ 1.60GHz
Yarn: 3.1.1 - /usr/bin/yarn
npm: 8.2.0 - ~/.npm-global/bin/npm
Browsers:
Chrome: 96.0.4664.93
npmPackages:
@storybook/addon-actions: ^6.4.9 => 6.4.9
@storybook/addon-docs: ^6.4.9 => 6.4.9
@storybook/addon-essentials: ^6.4.9 => 6.4.9
@storybook/addon-links: ^6.4.9 => 6.4.9
@storybook/angular: ^6.4.9 => 6.4.9
@storybook/builder-webpack5: ^6.4.9 => 6.4.9
@storybook/manager-webpack5: ^6.4.9 => 6.4.9

@leon
Copy link

leon commented Dec 10, 2021

Same here.
The problem is that in angular 13.1 the function getTypescriptWorkerPlugin changed names to getDevServerConfig

I was able to get it running by replacing all occurances of getTypescriptWorkerPlugin
in the file

node_modules/@storybook/angular/dist/ts3.9/server/angular-cli-webpack-13.x.x.js

or in the original repo

leon added a commit to leon/storybook that referenced this issue Dec 10, 2021
getTypescriptWorkerPlugin changed names to getDevServerConfig

storybookjs#16977
@DonnyVerduijn
Copy link

DonnyVerduijn commented Dec 11, 2021

This doesn't seem to be the only issue. I'm also stumbling upon the following error:

Error: /home/donny/angular-test-app/my-app/src/app/stories/Button.stories.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at /home/donny/angular-test-app/my-app/node_modules/@ngtools/webpack/src/ivy/loader.js:60:26
    at processResult (/home/donny/angular-test-app/my-app/node_modules/webpack/lib/NormalModule.js:751:19)
    at /home/donny/angular-test-app/my-app/node_modules/webpack/lib/NormalModule.js:853:5
    at /home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:399:11
    at /home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:251:18
    at context.callback (/home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:124:13)
    at /home/donny/angular-test-app/my-app/node_modules/@ngtools/webpack/src/ivy/loader.js:60:17

Searched for equivalent errors, but couldn't find anything related, so i assume this problem has not existed before?

rfprod added a commit to rfprod/nx-ng-starter that referenced this issue Dec 12, 2021
- [x] make storybook build optional, it needs patching;
see
storybookjs/storybook#16977;
@danielritter
Copy link

This doesn't seem to be the only issue. I'm also stumbling upon the following error:

Error: /home/donny/angular-test-app/my-app/src/app/stories/Button.stories.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at /home/donny/angular-test-app/my-app/node_modules/@ngtools/webpack/src/ivy/loader.js:60:26
    at processResult (/home/donny/angular-test-app/my-app/node_modules/webpack/lib/NormalModule.js:751:19)
    at /home/donny/angular-test-app/my-app/node_modules/webpack/lib/NormalModule.js:853:5
    at /home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:399:11
    at /home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:251:18
    at context.callback (/home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:124:13)
    at /home/donny/angular-test-app/my-app/node_modules/@ngtools/webpack/src/ivy/loader.js:60:17

Searched for equivalent errors, but couldn't find anything related, so i assume this problem has not existed before?

The same here

@danielbater
Copy link

This doesn't seem to be the only issue. I'm also stumbling upon the following error:

Error: /home/donny/angular-test-app/my-app/src/app/stories/Button.stories.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at /home/donny/angular-test-app/my-app/node_modules/@ngtools/webpack/src/ivy/loader.js:60:26
    at processResult (/home/donny/angular-test-app/my-app/node_modules/webpack/lib/NormalModule.js:751:19)
    at /home/donny/angular-test-app/my-app/node_modules/webpack/lib/NormalModule.js:853:5
    at /home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:399:11
    at /home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:251:18
    at context.callback (/home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:124:13)
    at /home/donny/angular-test-app/my-app/node_modules/@ngtools/webpack/src/ivy/loader.js:60:17

Searched for equivalent errors, but couldn't find anything related, so i assume this problem has not existed before?

Also experience the same issue.

@Biaapoletto
Copy link

This doesn't seem to be the only issue. I'm also stumbling upon the following error:

Error: /home/donny/angular-test-app/my-app/src/app/stories/Button.stories.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at /home/donny/angular-test-app/my-app/node_modules/@ngtools/webpack/src/ivy/loader.js:60:26
    at processResult (/home/donny/angular-test-app/my-app/node_modules/webpack/lib/NormalModule.js:751:19)
    at /home/donny/angular-test-app/my-app/node_modules/webpack/lib/NormalModule.js:853:5
    at /home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:399:11
    at /home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:251:18
    at context.callback (/home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:124:13)
    at /home/donny/angular-test-app/my-app/node_modules/@ngtools/webpack/src/ivy/loader.js:60:17

Searched for equivalent errors, but couldn't find anything related, so i assume this problem has not existed before?

Also experience the same issue.

Same here!

@joewIST
Copy link

joewIST commented Dec 17, 2021

This doesn't seem to be the only issue. I'm also stumbling upon the following error:

Error: /home/donny/angular-test-app/my-app/src/app/stories/Button.stories.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at /home/donny/angular-test-app/my-app/node_modules/@ngtools/webpack/src/ivy/loader.js:60:26
    at processResult (/home/donny/angular-test-app/my-app/node_modules/webpack/lib/NormalModule.js:751:19)
    at /home/donny/angular-test-app/my-app/node_modules/webpack/lib/NormalModule.js:853:5
    at /home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:399:11
    at /home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:251:18
    at context.callback (/home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:124:13)
    at /home/donny/angular-test-app/my-app/node_modules/@ngtools/webpack/src/ivy/loader.js:60:17

Searched for equivalent errors, but couldn't find anything related, so i assume this problem has not existed before?

Also experience the same issue.

Same here!

Same here

@mandarini
Copy link
Contributor

mandarini commented Dec 17, 2021

Same problem here, TypeError: getTypescriptWorkerPlugin is not a function :(

@angular/core: 13.1.1
@storybook/angular: 6.4.9

@shilman
Copy link
Member

shilman commented Dec 18, 2021

Yee-haw!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.5.0-alpha.4 containing PR #17032 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Dec 18, 2021
@vincentpalita
Copy link

vincentpalita commented Dec 18, 2021

@shilman I updated to the 6.5.0-alpha.4 version and now I have another issue now that has already been reported a while ago (#14734)

Do you know what could cause that issue? I have a standard configuration with only one addon: @storybook/addon-essentials
Also I am using @nrwl/storybook to serve/build. It was running well before upgrading to angular 13.1 (with angular 13.0.1).

Thanks for the help there!

Starting type checking service...
/Users/vincent/frontend/node_modules/webpack/lib/javascript/JavascriptModulesPlugin.js:141
                        throw new TypeError(
         ^
TypeError: The 'compilation' argument must be an instance of Compilation
    at Function.getCompilationHooks (/Users/vincent/frontend/node_modules/webpack/lib/javascript/JavascriptModulesPlugin.js:141:10)
    at SourceMapDevToolModuleOptionsPlugin.apply (/Users/vincent/frontend/node_modules/webpack/lib/SourceMapDevToolModuleOptionsPlugin.js:50:27)
    at /Users/vincent/frontend/node_modules/webpack/lib/SourceMapDevToolPlugin.js:163:53
    at Hook.eval (eval at create (/Users/vincent/frontend/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:297:1)
    at Hook.CALL_DELEGATE [as _call] (/Users/vincent/frontend/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/Hook.js:14:14)
    at Compiler.newCompilation (/Users/vincent/frontend/node_modules/@storybook/builder-webpack5/node_modules/webpack/lib/Compiler.js:1055:26)
    at /Users/vincent/frontend/node_modules/@storybook/builder-webpack5/node_modules/webpack/lib/Compiler.js:1099:29
    at _next0 (eval at create (/Users/vincent/frontend/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:23:1)
    at eval (eval at create (/Users/vincent/frontend/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:35:1)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

@jasonbyrne
Copy link

Still not working for me:
Error: node_modules/@types/webpack/index.d.ts:1115:33 - error TS2707: Generic type 'SyncBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

@mauiworketc
Copy link

@shilman I updated to the 6.5.0-alpha.4 version and now I have another issue now that has already been reported a while ago (#14734)

Do you know what could cause that issue? I have a standard configuration with only one addon: @storybook/addon-essentials Also I am using @nrwl/storybook to serve/build. It was running well before upgrading to angular 13.1 (with angular 13.0.1).

Thanks for the help there!

Starting type checking service...
/Users/vincent/frontend/node_modules/webpack/lib/javascript/JavascriptModulesPlugin.js:141
                        throw new TypeError(
         ^
TypeError: The 'compilation' argument must be an instance of Compilation
    at Function.getCompilationHooks (/Users/vincent/frontend/node_modules/webpack/lib/javascript/JavascriptModulesPlugin.js:141:10)
    at SourceMapDevToolModuleOptionsPlugin.apply (/Users/vincent/frontend/node_modules/webpack/lib/SourceMapDevToolModuleOptionsPlugin.js:50:27)
    at /Users/vincent/frontend/node_modules/webpack/lib/SourceMapDevToolPlugin.js:163:53
    at Hook.eval (eval at create (/Users/vincent/frontend/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:297:1)
    at Hook.CALL_DELEGATE [as _call] (/Users/vincent/frontend/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/Hook.js:14:14)
    at Compiler.newCompilation (/Users/vincent/frontend/node_modules/@storybook/builder-webpack5/node_modules/webpack/lib/Compiler.js:1055:26)
    at /Users/vincent/frontend/node_modules/@storybook/builder-webpack5/node_modules/webpack/lib/Compiler.js:1099:29
    at _next0 (eval at create (/Users/vincent/frontend/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:23:1)
    at eval (eval at create (/Users/vincent/frontend/node_modules/@storybook/builder-webpack5/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:35:1)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

getting this too

@unitario
Copy link

This doesn't seem to be the only issue. I'm also stumbling upon the following error:

Error: /home/donny/angular-test-app/my-app/src/app/stories/Button.stories.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at /home/donny/angular-test-app/my-app/node_modules/@ngtools/webpack/src/ivy/loader.js:60:26
    at processResult (/home/donny/angular-test-app/my-app/node_modules/webpack/lib/NormalModule.js:751:19)
    at /home/donny/angular-test-app/my-app/node_modules/webpack/lib/NormalModule.js:853:5
    at /home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:399:11
    at /home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:251:18
    at context.callback (/home/donny/angular-test-app/my-app/node_modules/loader-runner/lib/LoaderRunner.js:124:13)
    at /home/donny/angular-test-app/my-app/node_modules/@ngtools/webpack/src/ivy/loader.js:60:17

Searched for equivalent errors, but couldn't find anything related, so i assume this problem has not existed before?

Also experience the same issue.

Same here!

Same here

Same here. After installing 6.5.0-alpha.4.

@danielbater
Copy link

@shilman Unfortunately still an issue please consider re-opening. More comments of mine can be found here.

@mleimer
Copy link

mleimer commented Dec 21, 2021

Any chance to provide this as a hotfix instead of the next 6.5.x release cycle?
When using 6.5.0-alpha.4 I also experience the same issue as @DonnyVerduijn

@snowfrogdev
Copy link

Also running into the same issue.

@danielbater
Copy link

Added more information here.

@shilman
Copy link
Member

shilman commented Dec 23, 2021

@mleimer I'd be happy to patch back a fix once things have stabilized

@shilman shilman reopened this Dec 23, 2021
@meriturva
Copy link

@joewIST i have fixed that issue just working with angular.json file and using storybook version 6.4.12. Could you share your angular.json to see if I could help you fix it?

@joewIST
Copy link

joewIST commented Jan 13, 2022

this is the nx library's entry in angular.json:

"shared-ui": { "projectType": "library", "root": "libs/shared/ui", "sourceRoot": "libs/shared/ui", "prefix": "shared-ui", "architect": { "build": { "builder": "@nrwl/angular:ng-packagr-lite", "outputs": ["dist/libs/shared/ui"], "options": { "project": "libs/shared/ui/ng-package.json", "styles": ["node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css"] }, "configurations": { "production": { "tsConfig": "libs/shared/ui/tsconfig.lib.prod.json" }, "development": { "tsConfig": "libs/shared/ui/tsconfig.lib.json" } }, "defaultConfiguration": "production" }, "test": { "builder": "@nrwl/jest:jest", "outputs": ["coverage/libs/shared/ui"], "options": { "jestConfig": "libs/shared/ui/jest.config.js", "passWithNoTests": true }, "configurations": { "ci": { "ci": true, "codeCoverage": true, "colors": false, "runInBand": true, "force": true } } }, "lint": { "builder": "@nrwl/linter:eslint", "options": { "lintFilePatterns": ["libs/shared/ui/**/*.ts", "libs/shared/ui/**/*.html"] }, "configurations": { "ci": { "force": true, "format": "json", "outputFile": "./.analysis/eslint-ui.json" } }, "outputs": ["{options.outputFile}"] }, "storybook": { "builder": "@nrwl/storybook:storybook", "options": { "uiFramework": "@storybook/angular", "projectBuildConfig": "ui-storybook", "browserTarget": "ui-storybook:build", "port": 4400, "config": { "configFolder": "libs/shared/ui/.storybook", "styles": ["libs/sahred/ui/.storybook/storybook.scss"] } }, "configurations": { "ci": { "quiet": true }, "share": { "host": "0.0.0.0" } } }, "build-storybook": { "builder": "@nrwl/storybook:build", "outputs": ["{options.outputPath}"], "options": { "uiFramework": "@storybook/angular", "outputPath": "dist/storybook/ui", "config": { "configFolder": "libs/shared/ui/.storybook" } }, "configurations": { "ci": { "quiet": true } } }, "stylelint": { "builder": "nx-stylelint:lint", "options": { "config": "libs/shared/ui/.stylelintrc.json", "lintFilePatterns": ["libs/shared/ui/**/*.css", "libs/shared/ui/**/*.scss"] }, "configurations": { "ci": { "format": "json", "outputFile": "./.analysis/stylelint-ui.json" } } } }, "tags": ["$scope:libs/shared/ui", "$scope:libs/shared/utility", "$scope:libs/shared/core", "$scope:libs/direct/data"] },

@Itrulia
Copy link

Itrulia commented Jan 13, 2022

@shilman we are also getting the error TypeError: The 'compilation' argument must be an instance of Compilation just like @spaceribs

@meriturva
Copy link

Sorry @joewIST ..no NX on my project.

this is the nx library's entry in angular.json:

"shared-ui": { "projectType": "library", "root": "libs/shared/ui", "sourceRoot": "libs/shared/ui", "prefix": "shared-ui", "architect": { "build": { "builder": "@nrwl/angular:ng-packagr-lite", "outputs": ["dist/libs/shared/ui"], "options": { "project": "libs/shared/ui/ng-package.json", "styles": ["node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css"] }, "configurations": { "production": { "tsConfig": "libs/shared/ui/tsconfig.lib.prod.json" }, "development": { "tsConfig": "libs/shared/ui/tsconfig.lib.json" } }, "defaultConfiguration": "production" }, "test": { "builder": "@nrwl/jest:jest", "outputs": ["coverage/libs/shared/ui"], "options": { "jestConfig": "libs/shared/ui/jest.config.js", "passWithNoTests": true }, "configurations": { "ci": { "ci": true, "codeCoverage": true, "colors": false, "runInBand": true, "force": true } } }, "lint": { "builder": "@nrwl/linter:eslint", "options": { "lintFilePatterns": ["libs/shared/ui/**/*.ts", "libs/shared/ui/**/*.html"] }, "configurations": { "ci": { "force": true, "format": "json", "outputFile": "./.analysis/eslint-ui.json" } }, "outputs": ["{options.outputFile}"] }, "storybook": { "builder": "@nrwl/storybook:storybook", "options": { "uiFramework": "@storybook/angular", "projectBuildConfig": "ui-storybook", "browserTarget": "ui-storybook:build", "port": 4400, "config": { "configFolder": "libs/shared/ui/.storybook", "styles": ["libs/sahred/ui/.storybook/storybook.scss"] } }, "configurations": { "ci": { "quiet": true }, "share": { "host": "0.0.0.0" } } }, "build-storybook": { "builder": "@nrwl/storybook:build", "outputs": ["{options.outputPath}"], "options": { "uiFramework": "@storybook/angular", "outputPath": "dist/storybook/ui", "config": { "configFolder": "libs/shared/ui/.storybook" } }, "configurations": { "ci": { "quiet": true } } }, "stylelint": { "builder": "nx-stylelint:lint", "options": { "config": "libs/shared/ui/.stylelintrc.json", "lintFilePatterns": ["libs/shared/ui/**/*.css", "libs/shared/ui/**/*.scss"] }, "configurations": { "ci": { "format": "json", "outputFile": "./.analysis/stylelint-ui.json" } } } }, "tags": ["$scope:libs/shared/ui", "$scope:libs/shared/utility", "$scope:libs/shared/core", "$scope:libs/direct/data"] },

@petterhoel
Copy link

petterhoel commented Jan 14, 2022

@mandarini

Let me know if this works for you. We'll implement this logic inside the executor, but for now, it's an easy workaround with absolutely NO extra code needed.

Yes this complies and runs sb for me. However I am applying some external/global styles to my components and this approach does not apply these styles like before. I'm in an Nx repo;

I ran

 nx storybook my-lib --projectBuildConfig=my-lib:build-storybook

The following is the code I use for applying the global styles

// `RepoRoot/.storybook/preview.js`
import '!style-loader!css-loader!sass-loader!./scss-loader.scss';
// RepoRoot/.storybook/scss-loader.scss
@import "/libs/styles/src/lib/stylesheets/my-theme";
<!-- 
RepoRoot/libs/my-lib/.storybook/preview-body.html
and `my-theme="dark"` is the hook for my global 
-->
<html my-theme="dark"></html>

these are my relevant versions:

"devDependencies": {
   ...
    "@nrwl/angular": "13.4.4",
    "@nrwl/cli": "13.4.4",
    "@nrwl/cypress": "13.4.4",
    "@nrwl/eslint-plugin-nx": "13.4.4",
    "@nrwl/jest": "13.4.4",
    "@nrwl/linter": "13.4.4",
    "@nrwl/nx-cloud": "13.0.2",
    "@nrwl/storybook": "13.4.4",
    "@nrwl/tao": "13.4.4",
    "@nrwl/workspace": "13.4.4",
    "@storybook/addon-actions": "~6.5.0-alpha.16",
    "@storybook/addon-essentials": "~6.5.0-alpha.16",
    "@storybook/addon-controls": "~6.5.0-alpha.16",
    "@storybook/angular": "~6.5.0-alpha.16",
    "@storybook/builder-webpack5": "~6.5.0-alpha.16",
    "@storybook/manager-webpack5": "~6.5.0-alpha.16",
    ...
 }

macOs Monterey 12.1

@nzacca
Copy link
Contributor

nzacca commented Jan 14, 2022

@mandarini Thank you very much for that. Unfortunately, we run into a different issue with our stylesheets. We had to duplicate the stylePreprocessorOptions from our default app in the build-storybook config in order to include stylesheet paths which seems to work but this doesn't appear to be documented as a valid option for the storybook executor. Would you happen to know if this is something that is supported? Or is there a better way to do this?

@shilman shilman reopened this Jan 14, 2022
@shilman
Copy link
Member

shilman commented Jan 15, 2022

¡Ay Caramba!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.13 containing PR #17206 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb upgrade

Closing this issue. Please re-open if you think there's still more to do.

@joewIST
Copy link

joewIST commented Jan 17, 2022

I still run into the same issue as before:

File was processed with these loaders:

  • ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
  • ./node_modules/@storybook/source-loader/dist/cjs/index.js
    You may need an additional loader to handle the result of these loaders.

@rfprod
Copy link

rfprod commented Jan 17, 2022

I still run into the same issue as before:

File was processed with these loaders:

  • ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
  • ./node_modules/@storybook/source-loader/dist/cjs/index.js
    You may need an additional loader to handle the result of these loaders.

@joewIST It might be different webpack versions (angular-devkit and storybook).
Could you try if this helps nrwl/nx#8538 (comment)?

@joewIST
Copy link

joewIST commented Jan 17, 2022

@rfprod i tried the above but still get the same error

@mandarini
Copy link
Contributor

@joewIST did you try this, too?

@joewIST
Copy link

joewIST commented Jan 17, 2022

@mandarini yes i've already tried that, and besides i have the projectBuildConfig defined in my angular.json

@rfprod
Copy link

rfprod commented Jan 17, 2022

@joewIST can you post your package.json dependency versions (both dependencies and devDependencies)? Specifically, which @angular-devkit package versions do you use, and @nrwl dependencies version?

PS: I tested the webpack version resolution fix on 4 projects (all of them are not new), and it works the same, i.e. it fixes the error. All 4 projects use the latest dependency versions.

@joewIST
Copy link

joewIST commented Jan 18, 2022

@rfprod here is my dependencies:

"dependencies": {
"@angular-slider/ngx-slider": "^2.0.3",
"@angular/animations": "13.1.2",
"@angular/cdk": "13.1.2",
"@angular/common": "13.1.2",
"@angular/compiler": "13.1.2",
"@angular/core": "13.1.2",
"@angular/forms": "13.1.2",
"@angular/localize": "13.1.2",
"@angular/material": "13.1.2",
"@angular/platform-browser": "13.1.2",
"@angular/platform-browser-dynamic": "13.1.2",
"@angular/router": "13.1.2",
"@angular/youtube-player": "^12.2.12",
"@apollo/client": "^3.5.6",
"@microsoft/signalr": "^3.1.15",
"@ngneat/spectator": "^8.3.1",
"@ngneat/until-destroy": "^8.1.4",
"@nrwl/schematics": "8.12.11",
"@sentry/angular": "^6.13.3",
"@sentry/tracing": "^6.13.3",
"@storybook/theming": "^6.5.0-alpha.21",
"@tinymce/tinymce-angular": "^4.2.4",
"@types/d3-brush": "^3.0.1",
"@types/d3-array": "^3.0.2",
"angularx-qrcode": "^11.0.0",
"apollo-angular": "^2.6.0",
"bootstrap": "^5.0.2",
"d3": "^7.3.0",
"dayjs": "^1.10.5",
"flag-icon-css": "^4.1.4",
"flatpickr": "^4.6.9",
"graphql": "^15.8.0",
"jest-environment-jsdom": "^27.4.4",
"ng-katex": "^2.0.3",
"ng-qrcode": "^6.0.0",
"ngx-color-picker": "^11.0.0",
"ngx-infinite-scroll": "^10.0.1",
"nx": "^13.1.2",
"perfect-scrollbar": "^1.5.3",
"rxjs": "^7.4.0",
"tslib": "^2.3.1",
"underscore": "^1.13.1",
"uuid": "^8.3.2",
"webfontloader": "1.6.28",
"zone.js": "0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "13.1.3",
"@angular-devkit/core": "^13.1.3",
"@angular-devkit/schematics": "^13.1.3",
"@angular-eslint/builder": "^13.0.1",
"@angular-eslint/eslint-plugin": "^13.0.1",
"@angular-eslint/eslint-plugin-template": "13.0.1",
"@angular-eslint/schematics": "^13.0.1",
"@angular-eslint/template-parser": "13.0.1",
"@angular/cli": "13.1.3",
"@angular/compiler-cli": "13.1.2",
"@angular/language-service": "13.1.2",
"@babel/core": "^7.16.7",
"@commitlint/cli": "^14.1.0",
"@commitlint/config-conventional": "^14.1.0",
"@compodoc/compodoc": "^1.1.16",
"@ljcl/storybook-addon-cssprops": "^1.0.0",
"@ngneat/spectator": "^8.3.1",
"@nrwl/angular": "13.4.5",
"@nrwl/cli": "13.4.5",
"@nrwl/cypress": "13.4.5",
"@nrwl/devkit": "13.4.5",
"@nrwl/eslint-plugin-nx": "13.4.5",
"@nrwl/jest": "13.4.5",
"@nrwl/js": "13.3.8",
"@nrwl/linter": "13.4.5",
"@nrwl/nx-cloud": "13.0.3",
"@nrwl/storybook": "13.4.5",
"@nrwl/workspace": "13.4.5",
"@popperjs/core": "^2.9.2",
"@storybook/addon-a11y": "^6.5.0-alpha.21",
"@storybook/addon-docs": "^6.5.0-alpha.21",
"@storybook/addon-essentials": "6.5.0-alpha.21",
"@storybook/addon-jest": "^6.5.0-alpha.21",
"@storybook/addons": "^6.5.0-alpha.21",
"@storybook/angular": "6.5.0-alpha.21",
"@storybook/builder-webpack5": "6.5.0-alpha.21",
"@storybook/manager-webpack5": "6.5.0-alpha.21",
"@storybook/preset-scss": "^1.0.3",
"@types/d3": "^7.1.0",
"@types/jasmine": "~3.10.1",
"@types/jasminewd2": "2.0.10",
"@types/jest": "^27.0.2",
"@types/node": "^16.11.6",
"@types/underscore": "^1.11.3",
"@types/uuid": "^8.3.1",
"@types/webfontloader": "^1.6.33",
"@typescript-eslint/eslint-plugin": "5.3.1",
"@typescript-eslint/parser": "5.3.1",
"autoprefixer": "^10.4.0",
"babel-jest": "^27.4.5",
"css-loader": "^6.5.0",
"cypress": "^8.7.0",
"eslint": "8.2.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jsdoc": "^37.0.3",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-rxjs": "^4.0.1",
"eslint-plugin-rxjs-angular": "^2.0.0",
"eslint-plugin-storybook": "^0.5.5",
"husky": "^7.0.4",
"istanbul-instrumenter-loader": "3.0.1",
"jasmine-core": "~3.10.1",
"jasmine-spec-reporter": "~7.0.0",
"jest": "^27.4.5",
"jest-preset-angular": "11.0.0",
"jest-sonar": "^0.2.12",
"karma-cli": "2.0.0",
"lint-staged": "^11.2.6",
"ng-packagr": "13.1.3",
"nx-stylelint": "^12.2.0",
"postcss": "^8.3.11",
"postcss-import": "^14.0.2",
"postcss-preset-env": "^6.7.0",
"postcss-url": "^10.1.1",
"prettier": "2.4.1",
"regenerator-runtime": "^0.13.9",
"sass": "^1.43.4",
"sass-loader": "^12.3.0",
"storybook-addon-themes": "^6.1.0",
"style-loader": "^3.3.1",
"stylelint": "^14.0.1",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-standard": "^23.0.0",
"stylelint-config-standard-scss": "^2.0.0",
"stylelint-declaration-block-no-ignored-properties": "^2.4.0",
"stylelint-declaration-use-variable": "^1.7.3",
"stylelint-group-selectors": "^1.0.8",
"stylelint-scss": "^4.0.0",
"ts-jest": "27.1.1",
"ts-node": "10.4.0",
"tsconfig-paths-webpack-plugin": "^3.5.2",
"typescript": "4.5.4",
"webpack": "^5.66.0"
}

i have tried everything and still can't get storybook to work with the same error every time:

ModuleParseError: Module parse failed: The keyword 'enum' is reserved (15:0)
File was processed with these loaders:

  • ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
  • ./node_modules/@storybook/source-loader/dist/cjs/index.js
    You may need an additional loader to handle the result of these loaders.

@rfprod
Copy link

rfprod commented Jan 18, 2022

@joewIST I would suggest not to use caret ^ and tilde ~ in your package.json at all.

Give it a try in conjunction with the webpack resolution solution.

Remove ^ and ~ from you package.json.
Then add the webpack resolution to your package.json.
Then execute from the project root

rm -rf node_modules/ yarn.lock && yarn install # if you use yarn
# or
rm -rf node_modules/ package-lock.json && npm i # if you use npm

Here's what ^ and ~ do

In the simplest terms, the tilde matches the most recent minor version (the middle number).
~1.2.3 will match all 1.2.x versions but will miss 1.3.0.

The caret, on the other hand, is more relaxed.
It will update you to the most recent major version (the first number). ^1.2.3 will match any 1.x.xrelease including 1.3.0, but will hold off on 2.0.0.

Info source: https://indianceo.medium.com/caret-and-tilde-in-package-json-57f1cbbe347b

If you remove all ^ and ~ from your package.json, the workspace behavior will be more predictable, and it will be easier to debug it.

Also, doing something like this

"@angular-devkit/build-angular": "13.1.3",
"@angular-devkit/core": "^13.1.3",

seems incorrect to me. You tell npm to use fixed version of @angular-devkit/build-angular, but the most recent major version of @angular-devkit/core.

Check the semver parser for more details about referencing versions in package.json.

const semver = require('semver')

semver.valid('1.2.3') // '1.2.3'
semver.valid('a.b.c') // null
semver.clean('  =v1.2.3   ') // '1.2.3'
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
semver.gt('1.2.3', '9.8.7') // false
semver.lt('1.2.3', '9.8.7') // true
semver.minVersion('>=1.0.0') // '1.0.0'
semver.valid(semver.coerce('v2')) // '2.0.0'
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'

@joewIST
Copy link

joewIST commented Jan 19, 2022

@rfprod thanks i will try that. tbh most of these versions were auto-generated by the nx migrate latest command so not sure what removing carets/tildes will do but will investigate.

i've been desperately trying to upgrade to angular v.13 and these storybook issues are the only thing holding me back!

UPDATE: I still get the same errors after updating package.json

What "additional loader" might the error message be referring to?

@rfprod
Copy link

rfprod commented Jan 19, 2022

@joewIST first of, if you fix dependency version, I think nx will not add ^ or ~ on its own. At least I have not encountered such behavior, and I use nx heavily on a daily basis.
I automated the update procedure based on nx migrate like this https://github.com/rfprod/nx-ng-starter/blob/main/tools/ts/update.ts. Here are the commands https://github.com/rfprod/nx-ng-starter/blob/main/angular.json#L1625-L1668

Regarding the loader, do you really need all that storybook dependencies listed in your package.json?

Do you really need "@storybook/preset-scss": "^1.0.3",? It was released a year ago.

Also, "@storybook/theming": "^6.5.0-alpha.21", should be probably moved to devDependencies.

What is in your root main.js storybook file? Compare yours with this one https://github.com/rfprod/nx-ng-starter/blob/main/.storybook/main.js

Another unrelated yet intriguing thing is why do you need "karma-cli": "2.0.0", when you seem to be using jest?

@BruceWeng
Copy link

Still see UnhandledPromiseRejectionWarning: TypeError: The 'compilation' argument must be an instance of Compilation error in
storybook: 6.5.0-alpha.23.
jest: 27.4.7.
angular: 13.1.1.

@spaceribs
Copy link
Contributor

spaceribs commented Jan 25, 2022

Still see UnhandledPromiseRejectionWarning: TypeError: The 'compilation' argument must be an instance of Compilation error in storybook: 6.5.0-alpha.23. jest: 27.4.7. angular: 13.1.1.

after stepping away for a week, I can now say that this issue can be resolved by performing the following:

  1. Run npm ls webpack
  2. Find the version of webpack for @angular-devkit/build-angular
  3. npm install that exact version to your dev dependencies
  4. run npm dedupe

that should ensure that only one version of webpack@5 is installed and used across all dependencies, you can verify that by rerunning npm ls webpack
For example:

├─┬ @angular-devkit/build-angular@13.1.2
│ └── webpack@5.65.0  deduped
├─┬ @nrwl/node@13.4.1
│ └── webpack@5.65.0  deduped
├─┬ @storybook/addon-controls@6.5.0-alpha.23
│ └─┬ @storybook/core-common@6.5.0-alpha.23
│   └── webpack@4.46.0 
├─┬ @storybook/addon-docs@6.5.0-alpha.23
│ ├─┬ @storybook/builder-webpack4@6.5.0-alpha.23
│ │ └── UNMET PEER DEPENDENCY webpack@4.46.0 
│ └─┬ @storybook/core@6.5.0-alpha.23
│   └─┬ @storybook/core-server@6.5.0-alpha.23
│     ├─┬ @storybook/manager-webpack4@6.5.0-alpha.23
│     │ └── webpack@4.46.0 
│     └── webpack@4.46.0 
├─┬ UNMET PEER DEPENDENCY @storybook/angular@6.5.0-alpha.23
│ └── webpack@4.46.0 
├─┬ @storybook/builder-webpack5@6.5.0-alpha.23
│ └── webpack@5.65.0  deduped
├─┬ @storybook/manager-webpack5@6.5.0-alpha.23
│ └── webpack@5.65.0  deduped
└── webpack@5.65.0

you're looking to make sure every instance is deduped

@spaceribs
Copy link
Contributor

is there a separate issue # for the problems with HMR experienced by a few folks?

@sir-captainmorgan21
Copy link

@spaceribs there is an issue I opened and have a work around for: nrwl/nx#8484 (comment)

@mandarini
Copy link
Contributor

New docs for styles and stylePreprocessorOptions

AnalogJ added a commit to fastenhealth/fasten-onprem that referenced this issue Apr 29, 2023
Forced Webpack v5.74.0 version due to Storybook webpack incompatibilities.

storybookjs/storybook#16977 (comment)
nrwl/nx#8538 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests