Skip to content

Commit

Permalink
fix(@ngtools/webpack): don't warn on unused ngsummary
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva authored and mgechev committed Nov 12, 2019
1 parent 2e24108 commit 9b91163
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,40 @@ describe('Browser Builder unused files warnings', () => {
await run.stop();
});

it('should not show warning when excluded files are unused', async () => {
if (veEnabled) {
// TODO: https://github.com/angular/angular-cli/issues/15056
pending('Only supported in Ivy.');

return;
}

const ignoredFiles = {
'src/file.d.ts': 'export type MyType = number;',
'src/file.ngsummary.ts': 'export const hello = 42;',
'src/file.ngfactory.ts': 'export const hello = 42;',
'src/file.ngstyle.ts': 'export const hello = 42;',
'src/file.ng_typecheck__.ts': 'export const hello = 42;',
};

host.writeMultipleFiles(ignoredFiles);

host.replaceInFile(
'src/tsconfig.app.json',
'"main.ts"',
`"main.ts", ${Object.keys(ignoredFiles).map(f => `"${f.replace('src/', '')}"`).join(',')}`,
);

const logger = new TestLogger('unused-files-warnings');
const run = await architect.scheduleTarget(targetSpec, undefined, { logger });
const output = await run.result as BrowserBuilderOutput;
expect(output.success).toBe(true);
expect(logger.includes(warningMessageSuffix)).toBe(false);
logger.clear();

await run.stop();
});

it('should not show warning when type files are used', async () => {
if (veEnabled) {
// TODO: https://github.com/angular/angular-cli/issues/15056
Expand Down
2 changes: 1 addition & 1 deletion packages/ngtools/webpack/src/angular_compiler_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ export class AngularCompilerPlugin {
// JS file example `@angular/core/core.ngfactory.ts`.
// - .d.ts files might not have a correspondent JS file due to bundling.
// - __ng_typecheck__.ts will never be requested.
const fileExcludeRegExp = /(\.(d|ngfactory|ngstyle)\.ts|ng_typecheck__\.ts)$/;
const fileExcludeRegExp = /(\.(d|ngfactory|ngstyle|ngsummary)\.ts|ng_typecheck__\.ts)$/;

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

0 comments on commit 9b91163

Please sign in to comment.