Skip to content

Commit 9b91163

Browse files
filipesilvamgechev
authored andcommitted
fix(@ngtools/webpack): don't warn on unused ngsummary
Fix #15626 (comment)
1 parent 2e24108 commit 9b91163

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

packages/angular_devkit/build_angular/test/browser/unused-files-warning_spec_large.ts

+34
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,40 @@ describe('Browser Builder unused files warnings', () => {
6666
await run.stop();
6767
});
6868

69+
it('should not show warning when excluded files are unused', async () => {
70+
if (veEnabled) {
71+
// TODO: https://github.com/angular/angular-cli/issues/15056
72+
pending('Only supported in Ivy.');
73+
74+
return;
75+
}
76+
77+
const ignoredFiles = {
78+
'src/file.d.ts': 'export type MyType = number;',
79+
'src/file.ngsummary.ts': 'export const hello = 42;',
80+
'src/file.ngfactory.ts': 'export const hello = 42;',
81+
'src/file.ngstyle.ts': 'export const hello = 42;',
82+
'src/file.ng_typecheck__.ts': 'export const hello = 42;',
83+
};
84+
85+
host.writeMultipleFiles(ignoredFiles);
86+
87+
host.replaceInFile(
88+
'src/tsconfig.app.json',
89+
'"main.ts"',
90+
`"main.ts", ${Object.keys(ignoredFiles).map(f => `"${f.replace('src/', '')}"`).join(',')}`,
91+
);
92+
93+
const logger = new TestLogger('unused-files-warnings');
94+
const run = await architect.scheduleTarget(targetSpec, undefined, { logger });
95+
const output = await run.result as BrowserBuilderOutput;
96+
expect(output.success).toBe(true);
97+
expect(logger.includes(warningMessageSuffix)).toBe(false);
98+
logger.clear();
99+
100+
await run.stop();
101+
});
102+
69103
it('should not show warning when type files are used', async () => {
70104
if (veEnabled) {
71105
// TODO: https://github.com/angular/angular-cli/issues/15056

packages/ngtools/webpack/src/angular_compiler_plugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ export class AngularCompilerPlugin {
611611
// JS file example `@angular/core/core.ngfactory.ts`.
612612
// - .d.ts files might not have a correspondent JS file due to bundling.
613613
// - __ng_typecheck__.ts will never be requested.
614-
const fileExcludeRegExp = /(\.(d|ngfactory|ngstyle)\.ts|ng_typecheck__\.ts)$/;
614+
const fileExcludeRegExp = /(\.(d|ngfactory|ngstyle|ngsummary)\.ts|ng_typecheck__\.ts)$/;
615615

616616
const usedFiles = new Set<string>();
617617
for (const compilationModule of compilation.modules) {

0 commit comments

Comments
 (0)