Skip to content
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

feat(angular): disable ngcc when not needed #19307

Merged
merged 4 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
kroeder marked this conversation as resolved.
Show resolved Hide resolved
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