-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
[Bug]: Angular Library requires Zone.js #30691
Comments
Tracked down the source of the issue. The following was removed from
10bb8e0#diff-0c21257608d891851ff3890160ecd56a82d7f067127b2fdaaed982a446227089 |
As a workaround the import // .storybook/preview.ts
import {setCompodocJson} from '@storybook/addon-docs/angular';
import docJson from '../documentation.json';
setCompodocJson(docJson);
import '../src/polyfills'; |
@emopti-jrufer Thank you for looking into this. This morning I realized I am starting a new project, so I probably don't need zone.js. So I did some digging and found feature request #28403. Storybook version 8.6.0 (published 2 days ago) now supports zoneless! If you are running into this issue trying to use Storybook in an Nx Angular library, the solution I found was:
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';
setupZoneTestEnv({
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
}); to import { setupZonelessTestEnv } from 'jest-preset-angular/setup-env/zoneless';
setupZonelessTestEnv({
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
}); |
Closing this as fixed in 8.6.0
|
@shilman just tried with 8.6.2 and without explicitly import zone.js into preview.ts the error is still present |
same here with 8.6.2 |
@forgantini @floreauwe did you enable zoneless support per the instructions? Can you share a reproduction? |
Same is happening here with |
@shilman yes i followed what is posted up here but i'm sorry it's a little bit tricky for me to provide a reproduction at now. What i can add is that i'm using ng 18 (maybe the zoneless is still marked as experimental and that causes the issue don't know honestly..) and that obviously we are not yet zoneless |
Reopening until we get to the bottom of this. Thanks all for your patience! |
If you are not on zoneless mode, your {
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular-v16": {
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"polyfills": [
// 👇 Zoneless polyfill should exist
"zone.js"
],
...
},
"storybook": {
"builder": "@storybook/angular:start-storybook",
"options": {
"browserTarget": "angular-v16:build",
// ...
}
},
"build-storybook": {
"builder": "@storybook/angular:build-storybook",
"options": {
"browserTarget": "angular-v16:build",
// ...
}
}
}
}
}
} The |
@valentinpalkovic I am using an angular library in Nx repo and your solution unfortunately did not work, as the |
I guess for Angular libraries the right call would be to add zone.js to the preview file as mentioned above. |
Describe the bug
When creating an Angular library with Storybook, an error is thrown "NG0908: In this configuration Angular requires Zone.js". Zone is installed in the project.
I initially found this using NX to create a control component library. However, I was able to reproduce it without NX using just Angular libraries.
Reproduction link
https://stackblitz.com/edit/stackblitz-starters-34gmr3qu?file=package.json
Reproduction steps
System
Additional context
I have provided scripts in the package.json of this StackBlitz for an easy comparison. Please run
npm run control:storybook
to see the errorThe text was updated successfully, but these errors were encountered: