storybook: Storybook 6.4 build failing with Angular 13.1
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® Core™ 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
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 64
- Comments: 94 (21 by maintainers)
Commits related to this issue
- fix: support angular 13.1 getTypescriptWorkerPlugin changed names to getDevServerConfig #16977 — committed to leon/storybook by leon 3 years ago
- ci(pipelines): update pipelines, storybook is broken - [x] make storybook build optional, it needs patching; see https://github.com/storybookjs/storybook/issues/16977; — committed to rfprod/nx-ng-starter by rfprod 3 years ago
- working added storybook support. Forced Webpack v5.74.0 version due to Storybook webpack incompatibilities. https://github.com/storybookjs/storybook/issues/16977#issuecomment-1014324178 https://githu... — committed to fastenhealth/fasten-onprem by AnalogJ a year ago
All, thanks for your patience sorting this out. The plan is to get things working in 6.5 and then patch back the final solution to 6.4 once it’s all debugged. In the future we’ll try to get a CI setup that tests prerelease versions of Angular (and the other frameworks we support) so that we catch these earlier and not during the middle of Christmas vacation.
Same here. The problem is that in angular 13.1 the function
getTypescriptWorkerPluginchanged names togetDevServerConfigI was able to get it running by replacing all occurances of
getTypescriptWorkerPluginin the fileor in the original repo https://github.com/storybookjs/storybook/blob/585abdd45c492a69a4e61f11fa9019cd95b94599/app/angular/src/server/angular-cli-webpack-13.x.x.js#L8
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
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
@nextNPM tag to try it out!Closing this issue. Please re-open if you think there’s still more to do.
Same here!
This doesn’t seem to be the only issue. I’m also stumbling upon the following error:
Searched for equivalent errors, but couldn’t find anything related, so i assume this problem has not existed before?
The same here
Same here
Also experience the same issue.
Same here - after fixing
getTypescriptWorkerPluginproblem (by upgrading to 6.5.0-alpha4) Storybook iframe.html now throws “Errors during JIT compilation of template for <component_name>: Unexpected character “EOF”” on all of my stories (worked fine on 6.3.0). @rfprod did you manage to fix this? Going back to 6.3.0 is not an option for me, since we’re using NX with Angular and are trying to upgrade the whole environment to Angular 13 using Nrwl tools.@shilman Unfortunately still an issue please consider re-opening. More comments of mine can be found here.
Just simple reproduction with version 6.4.12:
Errors:
@mleimer I’d be happy to patch back a fix once things have stabilized
@shilman unfortunately I’m still seeing the
The 'compilation' argument must be an instance of Compilationissue running alpha.15 locally, are there any specific steps I can take to remedy that?Now with version 6.5.0-alpha.12: A lot of errors log:
I’m just updating here results after moving to version
6.5.0-alpha.10:with version
6.5.0-alpha.7and the new angular.json project approach described here https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#64-angular-changes :Now with version
6.5.0-alpha.10:EDIT: same errors with version
6.5.0-alpha.12.@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 (https://github.com/storybookjs/storybook/issues/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!
¡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
@latestNPM tag to try it out!Closing this issue. Please re-open if you think there’s still more to do.
@shilman we are also getting the error
TypeError: The 'compilation' argument must be an instance of Compilationjust like @spaceribs¡Ay Caramba!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.5.0-alpha.15 containing PR #17206 that references this issue. Upgrade today to the
@nextNPM tag to try it out!Closing this issue. Please re-open if you think there’s still more to do.
after stepping away for a week, I can now say that this issue can be resolved by performing the following:
npm ls webpack@angular-devkit/build-angularnpm installthat exact version to your dev dependenciesnpm dedupethat 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:
you’re looking to make sure every instance is deduped
¡Ay Caramba!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.12 containing PR #17032 that references this issue. Upgrade today to the
@latestNPM tag to try it out!Closing this issue. Please re-open if you think there’s still more to do.
@shilman Updating to 6.5.0-alpha7 and using @SebastianPodgajny code did eventually do the trick. But for whatever reason I also had to fix my tsconfig, because it was complaining about not being able to find
polyfill.tsand hotreload is broken. So I would still much rather have a fix in 6.4 😕@SebastianPodgajny perfect, it works. Thank you very much for saving some time for me.
@KirillMetrik check this
We got the same error ERR! why storybook is so hard to use.
is there a separate issue # for the problems with HMR experienced by a few folks?
hot reload problem still exist.
We got the same error
ERR! TypeError: getTypescriptWorkerPlugin is not a functionafter updating Angular 13.1.1 and Storybook 6.4.9.Also having problems when updating to alpha:
Please make sure it is in your tsconfig via the 'files' or 'include' property.I managed to fix this by modifying some build config but then I had an whole load of other runtime template issues. I’d comment out stuff only to find more and more problems.
@unnhao @fasidOnGit @stefan-schweiger
Solution for the missing
polyfill.tsfile in Nx workspaces:For buildable projects
That means: for apps, buildable libs, projects that have the
buildtarget in theirarchitectortargetsinangular.jsonorproject.jsonRun you app like this:For non-buildable projects
For non buildable projects, projects that do NOT have the
buildtarget in theirarchitectortargetsinangular.jsonorproject.jsonRun your app like this:
Notice how here we are explicitly passing the
build-storybooktarget!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.
(Referencing this here too)
Also, there’s a PR under way for better logging and this PR to use the current project’s build configuration.
Haha, I try to change
projectBuildConfigto"projectsBuildConfig": "client-ui:build-storybook"and it work. but I don’t know what I do ether it’s right or not. thanks.for the polyfills.ts. I had to add it (the polyfills.ts file) to the
filesarray in tsconfig under.storybookfiles or includes both works 👍
@qortex my solution was to add
"../../../../../apps/<default-app>/src/*.ts",to theincludesof the storybook tsconfig file.@rfprod You need to remove html raw-loader rule in webpack config
Stories should be added to the storybook
tsconfig. For example:But it did not work with
alphafor me yet. Jit compiler complained that it could not have parsed component templates correctly.New docs for
stylesandstylePreprocessorOptions@spaceribs there is an issue I opened and have a work around for: https://github.com/nrwl/nx/issues/8484#issuecomment-1012664860
@joewIST I would suggest not to use caret
^and tilde~in yourpackage.jsonat all.Give it a try in conjunction with the webpack resolution solution.
Remove
^and~from youpackage.json. Then add the webpack resolution to yourpackage.json. Then execute from the project rootHere’s what
^and~doInfo 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
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.@mandarini yes i’ve already tried that, and besides i have the projectBuildConfig defined in my angular.json
@joewIST did you try this, too?
this fix is for nx, but it should have some similarities, watch mode needs to be enabled in the build configuration in
angular.jsonon the contrary, as of alpha 12, I haven’t had any issue, if anything, the workaround for removing the html loader in the webpack config under angular + nx isn’t needed anymore
@rfprod well I already had that config 😉 but without the resolutions for webpack it will give me the error about “TypeError: The ‘compilation’ argument must be an instance of Compilation”.
Thanks anyway!
@stefan-schweiger Cool. that fixed it. But, the live reloading is gone.