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
Nx Version 13 not working with Storybook #8360
Comments
Noting this is also being discussed here: storybookjs/storybook#17039 (comment) |
Hi there @KirillMetrik ! I did not look into your issue yet, will do so, soon. In the meantime, can you try this solution and let me know if it works for you? |
Hi @mandarini , not sure how is this connected with styles? |
@KirillMetrik check this comment, it works with Storybook 6.5.0 alpha storybookjs/storybook#16977 (comment)
|
Hi @KirillMetrik , I did not look into your issue, so I just suggested some solution to a similar error, related to Angular 13! :) So, sorry about that! We're working on solving the issues for Storybook+Angular 13, but I think it's mostly related on the Storybook side. Will keep you posted! Thanks @rfprod for jumping in! |
@mandarini When using these workaround there still is an error for some people that EDIT: Also the hot reload goes out the window, doesn't matter if it's storybook 6.4 or 6.5 |
@stefan-schweiger if you define a build config that does not use polyfills it will work without it. For example, remove this line https://github.com/rfprod/nx-ng-starter/blob/main/angular.json#L1166, then remove this line https://github.com/rfprod/nx-ng-starter/blob/main/apps/documentation/.storybook/tsconfig.json#L7 Notice project build configs (if you omit it, the default app build config will be used):
Now if you execute |
@rfprod thanks I will try that workaround out 😉 But this is still a breaking change in the combination of angular+nx+storybook which should be adressed properly 😕 |
@rfprod would you like to submit a PR on our Storybook generator to add the webpack config tweak you created? I'm referring to this. Let me know if you want to do this, or I can take this up and give you credit in the PR!
|
@KirillMetrik @stefan-schweiger thanks for posting all these comments/suggestions/issues! :) I tried in a new workspace to generate a new lib/app, with components, generated Storybook configuration, and indeed I got the same experience as you described, the
After adding what @rfprod suggested in my Please let me know if you find any other issues in the angular+nx+storybook integration!! :) |
@mandarini I'll open the PR in several minutes. However, you'll have to help me a bit as I'm getting into the source code so that I don't miss something. So far I've found only one place where it has to be added. |
* fix(storybook): apply a webpack tweak for storybook and angular - [x] remove html raw-loader from the webpack rules array if storybook is used with angular v13; the html raw-loader breaks jit compilation when storybook 6.5 aplha is used with angular v13 ISSUES CLOSED: #8360 fix(testing): update storybook generator configuration snapshot fix(testing): update storybook generator configuration snapshot, use the flag --update-snapshot fix(testing): update storybook generator configuration snapshot, test affected, update snapshot * cleanup(storybook): make the webpack tweak for storybook and angular explanation more concise
@rfprod @mandarini to be honest in my eyes this is not a fix but a workaround which should be removed as soon as possible. The underlying issue still remains and needs to be fixed in either Angular or Storybook, but nobody seems to feel responsible for this right now. For now I will stay on nx 13.3.6 which uses Angular 13.0 and works without this patch. |
Hi @stefan-schweiger ! Thanks for pointing this out. This is indeed a workaround, and we're waiting on the Storybook side for the Angular 13 issues to be solved. For the time being, let's all try to be patient, I'm sure everyone who's working on this is doing the best they can. |
This should now be fixed with the latest // angular.json / project.json
...
"targets": {
"build": {
"configurations": {
"production": { ... },
// Add this to enable watch mode
"storybook": {
"watch": true
}
}
},
...
"storybook": {
"options": {
// Change the build target to use the storybook build config we created above
"projectBuildConfig": "<project_name_from_above>:build:storybook"
}
}
} While this PR from Storybook makes a change to fix HMR for the default scenario, Ideally, it would be nice if this was just set by default in the executor but this is the workaround we've opted to use for now. Perhaps something needs to be adjusted within Nx to read the watch config setting and use that to override the build config by default. |
@nzacca for me the |
@stefan-schweiger Yes, that is another issue that only affects libraries using Storybook. We fixed that manually by including the polyfill in the storybook tsconfig for that library.
This has allowed us to move forward with our Angular 13 upgrade. Hopefully there is a better configuration for this in future. |
Please take a look at this comment @nzacca @stefan-schweiger storybookjs/storybook#16977 (comment) Also, command suggestion PR and PR that passes the current project build config automatically. |
@mandarini Thank you very much for the response! Sorry for the late reply. I responded to the other ticket you linked by accident: storybookjs/storybook#16977 (comment) What we ended up doing was just setting the |
New docs for |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
Currently Storybook cannot be correctly run for libraries created with standard tools in NX.
After creating a workspace, adding a library and Storybook to the library, the Storybook itself doesn't work correctly. Please see reproduction steps for details.
Expected Behavior
Storybook should work and render stories correctly.
This worked for NX 12 and Storybook 6.3.0.
Steps to Reproduce
Quick Reproduction
I have prepared a GitHub repo reproducing the issue.
npm install
nx run my-lib:storybook
Expected render for the story:
Actual render for the story:
Long Reproduction (all steps from scratch)
npx create-nx-workspace --preset=angular
ng g @nrwl/angular:lib my-lib
nx g @nrwl/angular:storybook-configuration my-lib
npm install
libs/my-lib
folder and fill it with the following content:nx run my-lib:storybook
Expected render for the story:
Actual render for the story:
Environment
The text was updated successfully, but these errors were encountered: