diff --git a/code/examples/angular-cli/.storybook/main.ts b/code/examples/angular-cli/.storybook/main.ts index df48c9d5aa87..41e94c2c0013 100644 --- a/code/examples/angular-cli/.storybook/main.ts +++ b/code/examples/angular-cli/.storybook/main.ts @@ -34,6 +34,7 @@ const mainConfig: import('@storybook/angular').StorybookConfig = { name: '@storybook/angular', options: { enableIvy: true, + enableNgcc: true, }, }, }; diff --git a/code/frameworks/angular/src/server/framework-preset-angular-ivy.ts b/code/frameworks/angular/src/server/framework-preset-angular-ivy.ts index a83019a97b0b..3ff8d02415c3 100644 --- a/code/frameworks/angular/src/server/framework-preset-angular-ivy.ts +++ b/code/frameworks/angular/src/server/framework-preset-angular-ivy.ts @@ -58,7 +58,9 @@ export const webpack = async (webpackConfig: Configuration, options: PresetOptio return webpackConfig; } - runNgcc(); + if(angularOptions.enableNgcc !== false) { + runNgcc(); + } return { ...webpackConfig, diff --git a/code/frameworks/angular/src/types.ts b/code/frameworks/angular/src/types.ts index 26d68a283a57..cfb69b81a7ae 100644 --- a/code/frameworks/angular/src/types.ts +++ b/code/frameworks/angular/src/types.ts @@ -45,5 +45,6 @@ export type StorybookConfig = Omit< StorybookConfigFramework; export interface AngularOptions { - enableIvy: boolean; + enableIvy?: boolean; + enableNgcc?: boolean; } diff --git a/code/lib/cli/src/automigrate/fixes/new-frameworks.test.ts b/code/lib/cli/src/automigrate/fixes/new-frameworks.test.ts index 2d4996809e9a..7ffaf5385cd9 100644 --- a/code/lib/cli/src/automigrate/fixes/new-frameworks.test.ts +++ b/code/lib/cli/src/automigrate/fixes/new-frameworks.test.ts @@ -196,6 +196,7 @@ describe('new-frameworks fix', () => { }, angularOptions: { enableIvy: true, + enableNgcc: true, }, }, }) @@ -206,6 +207,7 @@ describe('new-frameworks fix', () => { dependenciesToRemove: ['@storybook/builder-webpack5', '@storybook/manager-webpack5'], frameworkOptions: { enableIvy: true, + enableNgcc: true, }, builderInfo: { name: 'webpack5', diff --git a/code/lib/telemetry/src/storybook-metadata.test.ts b/code/lib/telemetry/src/storybook-metadata.test.ts index 380c5343a6da..a45f970dbf3a 100644 --- a/code/lib/telemetry/src/storybook-metadata.test.ts +++ b/code/lib/telemetry/src/storybook-metadata.test.ts @@ -123,11 +123,12 @@ describe('await computeStorybookMetadata', () => { ...mainJsMock, angularOptions: { enableIvy: true, + enableNgcc: true, }, }, }); - expect(angularResult.framework).toEqual({ name: 'angular', options: { enableIvy: true } }); + expect(angularResult.framework).toEqual({ name: 'angular', options: { enableIvy: true, enableNgcc: true } }); }); test('should separate storybook packages and addons', async () => { diff --git a/docs/faq.md b/docs/faq.md index b83a5fd35906..2a3e3ffe6b28 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -24,6 +24,26 @@ module.exports = { }, }; ``` +### How can I opt-out of Angular ngcc? + +In case you postinstall ngcc, you can disable it: + +```javascript +module.exports = { + stories: [ + /* ... */ + ], + addons: [ + /* ... */ + ], + framework: { + name: '@storybook/angular', + options: { + enableNgcc: false, + }, + }, +}; +``` Please report any issues related to Ivy in our [GitHub Issue Tracker](https://github.com/storybookjs/storybook/labels/app%3A%20angular) as the support for View Engine will be dropped in a future release of Angular.