Skip to content

Commit

Permalink
Merge pull request #19307 from bovandersteene/bovds/disable-ngcc
Browse files Browse the repository at this point in the history
 feat(angular): disable ngcc when not needed
  • Loading branch information
ndelangen authored Oct 4, 2022
2 parents 7efe75a + dfd38af commit 448f5f4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions code/examples/angular-cli/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const mainConfig: import('@storybook/angular').StorybookConfig = {
name: '@storybook/angular',
options: {
enableIvy: true,
enableNgcc: true,
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export const webpack = async (webpackConfig: Configuration, options: PresetOptio
return webpackConfig;
}

runNgcc();
if(angularOptions.enableNgcc !== false) {
runNgcc();
}

return {
...webpackConfig,
Expand Down
3 changes: 2 additions & 1 deletion code/frameworks/angular/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ export type StorybookConfig = Omit<
StorybookConfigFramework;

export interface AngularOptions {
enableIvy: boolean;
enableIvy?: boolean;
enableNgcc?: boolean;
}
2 changes: 2 additions & 0 deletions code/lib/cli/src/automigrate/fixes/new-frameworks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ describe('new-frameworks fix', () => {
},
angularOptions: {
enableIvy: true,
enableNgcc: true,
},
},
})
Expand All @@ -206,6 +207,7 @@ describe('new-frameworks fix', () => {
dependenciesToRemove: ['@storybook/builder-webpack5', '@storybook/manager-webpack5'],
frameworkOptions: {
enableIvy: true,
enableNgcc: true,
},
builderInfo: {
name: 'webpack5',
Expand Down
3 changes: 2 additions & 1 deletion code/lib/telemetry/src/storybook-metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
20 changes: 20 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 448f5f4

Please sign in to comment.