Nx: storybook-configuration fails on modules without declarations

Created on 6 Mar 2020  路  4Comments  路  Source: nrwl/nx

Prerequisites

  • [X] I am running the latest version
  • [X] I checked the documentation (nx.dev) and found no answer
  • [X] I checked to make sure that this issue has not already been filed
  • [X] I'm reporting the issue to the correct repository (not related to React, Angular or any dependency)

Expected Behavior

nx g @nrwl/angular:storybook-configuration [lib] should ignore modules without declarations arrays.

Current Behavior

What is the current behavior?

Schematic fails if library contains modules without declarations array.

Failure Information (for bugs)

No declarations array in the @NgModule decorator in libs/[lib]/src/lib/[module].module.ts

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Create new Angular project with a UI library following the tutorial. Tutorial - Step 1 and 8
  2. Add a module without declarations such as is recommended in the Angular guide for a routing module.
  3. Run nx g @nrwl/angular:storybook-configuration [lib]

Context

Please provide any relevant information about your setup:

@nrwl/angular : 9.0.4
@nrwl/cli : 9.0.4
@nrwl/cypress : 9.0.4
@nrwl/eslint-plugin-nx : Not Found
@nrwl/express : Not Found
@nrwl/jest : 9.0.4
@nrwl/linter : Not Found
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 9.0.4
@nrwl/web : Not Found
@nrwl/workspace : 9.0.4
typescript : 3.7.5

Failure Logs

No declarations array in the @NgModule decorator in libs/[lib]/src/lib/[module].module.ts

Other

Adding an empty declarations array to the module solves the issue but it would be nice to not have to add empty declarations arrays to all of my routing modules.

community storybook bug

Most helpful comment

I am getting the same error No declarations array in the @NgModule decorator in libs/[lib]/src/lib/[module].module.ts

Add an empty declarations array to every module in that lib:
declarations: [ ]

Then run the generator again.

After it succesfully added the .storybook configuration, you can delete the empty arrays again.

All 4 comments

Would somebody in the community be interested in taking a look? No stories should be produced for modules without declarations. Maybe a warning would be nice to explain why no stories were created.

Even when 'No' is chosen as option to generate the *.stories.ts files, the error occurs. I guess a warning should be shown as @FrozenPandaz mentions, when 'Yes' is chosen. If 'No' is chosen, I expect it to just add the .storybook directory without complaining or showing a warning at all.

The workaround posted by OP works, as an extra note: this has to be done for every module specified in the lib.

image

I am getting the same error No declarations array in the @NgModule decorator in libs/[lib]/src/lib/[module].module.ts

I am getting the same error No declarations array in the @NgModule decorator in libs/[lib]/src/lib/[module].module.ts

Add an empty declarations array to every module in that lib:
declarations: [ ]

Then run the generator again.

After it succesfully added the .storybook configuration, you can delete the empty arrays again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jon301 picture jon301  路  3Comments

joelmuskwe picture joelmuskwe  路  3Comments

SWGeekPD picture SWGeekPD  路  3Comments

zpydee picture zpydee  路  3Comments

elliotmendiola picture elliotmendiola  路  3Comments