Closed nzacca closed 3 years ago
Thanks for submitting the issue!
You you change the configuration version property to 1 (line 2 of workspace.json) and run nx format, you will get the old version of the configuration. You just need to do it once. Everything should work after that.
We support the Angular CLI configuration (Nx can run with angular.json). Everything that requires Angular CLI should work in this case. It's basically an Angular CLI project.
If you are using an Nx workspace without the Angular CLI (workspace.json instead of angular.json), not everything that would work in the Angular CLI will work here. It's not an Angular CLI project any more. We do our best to make sure as much as possible works. We provide a custom host for schematics that converts workspace.json to angular.json on the fly and converts it back etc., but the Angular storybook integration doesn't work.
The reason to have a different config format is that the Angular CLI configuration doesn't work well for large workspaces. The angular.json file should not be the place where 1000 projects are configured.
In Q1 we will allow project configuration to be located within the project's folder. The change required in the Angular Storybook is actually small, so if the folks there are happy to receive a PR, we will send one.
As a side note, the Angular team started work on making the config customizable. But the API was convoluted, so the Angular CLI doesn't use the API consistently, and no tool I know of uses it well either.
@mandarini @juristr can we ping the storybook folks to see if they are happy to receive a PR?
@vsavkin
Thank you for the follow up, explanation, and workaround. I appreciate the insight.
We switched to a non-Angular workspace with the intent on supporting non-Angular libraries/projects alongside our Angular projects. We use storybook a lot so this was something we noticed right away. I have no issues with swapping the version back to v1 while we await the upcoming features in Q1 as you mentioned. Thank you for this tip.
Lastly, may I take a moment to applaud your engagement and responsiveness with the community. The team at Nrwl has done an excellent job at communicating and fielding questions from us. My hope is that other community projects take inspiration from, and lead with, this level of professionalism and engagement. I know my team and I certainly will.
Cheers!
@vsavkin - This maybe a separate issue, but I am getting a different error in the same step. See below:
info => Loading custom manager config
info => Loading presets
info => Loading presets
info => Loading 1 config file in "libs/core/.storybook"
info => Loading 2 other files in "libs/core/.storybook"
info => Found custom tsconfig.json
info => Loading custom manager config
info => Using angular project 'core' for configuring Storybook.
ERR! architect.build is not defined for project 'core'.
info => Loading angular-cli config.
info => Loading custom Webpack config (full-control mode).
Note that angular project 'core'
is an Angular library so it won't have a build property in (e.g.project.core.architect
) in angular.json
Sorry, my issue above was due to the fact that I changed my default project to a library instead of an application. Once I changed the default to an application everything worked as it should. I looked through the documentation and It maybe worth mentioning for Angular users how storybook/webpack bootstraps via the default project.
this issue relate to this PR https://github.com/nrwl/nx/pull/4099 which is fix Storybook always using default project as target p/s: which is still not merged yet, after 1 month 10 days :D
@vsavkin I'll reach out to the Storybook folks.
@hiepxanh I'll try to take a look at your PR. I see it was created 1 month and 10 days ago, but in the meantime it needed revisions, and then there was the Christmas period, which is usually when people who would be reviewing PRs are taking some time off! I see you updated your PR 7 days ago, so all I'm saying is that we're doing our best to catch up with your PRs! :)
thank you, happy new year :D hope you safe and heathy ❤️
Hi folks,
I run into this issue today. From what I understood, the PRs to storybook should have resolved the original issue and allow to use Storybook with Nx config (v2), but it still happened for me. I created a fresh project from Angular schematic with Nx 12. I also made sure I have latest Storybook (6.2.9) installed which includes the merged changes.
Could there be anything else that needs to be done?
Same thing here after bumping minor versions in an Nx 11 project.
Only thing that worked for me was rolling back both the @nrwl
and @storybook
dependencies.
This combination works:
I tried a bunch of other combinations to try to figure out whether the problem is with Nx or with Storybook. All the following combos yield the infamous
info => Using angular project 'storybook' for configuring Storybook.
Cannot read property 'build' of undefined
Hence it would seem that the problem lies in a combination of Nx and Storybook.
@RIAstar can you subscribe to #5688?
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
When an Nx empty workspace is created, and an Angular app is added with Storybook support, Storybook fails to start with the following error:
ERR! TypeError: Cannot read property 'build' of undefined
See Failure Log section below for more details.
Expected Behavior
Storybook can start successfully.
Unclear if this is a regression as this is the first time I'm using an Nx workspace as opposed to an Nx Angular workspace.
Steps to Reproduce
Failure Logs
Environment
Other Notes
Error appears to occur since it is looking for an
architect
property within theworkspace.json
however this appears to have been renamed totargets
. Note, renamingtargets
back toarchitect
within workspace.json does fix the issue. However, it is unclear if this will cause problems for other Nx systems.Based on my testing so far (running an Angular app, linting, and jest tests) renaming the property back to
architect
has not had any issues but I assume this was renamed for a purpose so I can't be sure that this is a good long term fix.