Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 4814a4a

Browse files
filipesilvaclydin
authored andcommitted
feat(@angular-devkit/build-optimizer): remove angular es5 whitelist
Partially address #816 Fix #523
1 parent d6f03c7 commit 4814a4a

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

packages/angular_devkit/build_optimizer/src/build-optimizer/build-optimizer.ts

+3-17
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,16 @@ const whitelistedAngularModules = [
3737
/[\\/]node_modules[\\/]@angular[\\/]cdk[\\/]/,
3838
];
3939

40-
// TODO: this code is very fragile and should be reworked.
41-
// See: https://github.com/angular/devkit/issues/523
42-
const es5AngularModules = [
43-
// Angular 4 packaging format has .es5.js as the extension.
44-
/\.es5\.js$/, // Angular 4
45-
// Angular 5 has esm5 folders.
46-
// Angular 6 has fesm5 folders.
47-
/[\\/]node_modules[\\/]@angular[\\/][^\\/]+[\\/]f?esm5[\\/]/,
48-
// All Angular versions have UMD with es5.
49-
/\.umd\.js$/,
50-
];
51-
52-
// Factories created by AOT are known to have no side effects and contain es5 code.
40+
// Factories created by AOT are known to have no side effects.
5341
// In Angular 2/4 the file path for factories can be `.ts`, but in Angular 5 it is `.js`.
5442
const ngFactories = [
5543
/\.ngfactory\.[jt]s/,
5644
/\.ngstyle\.[jt]s/,
5745
];
5846

5947
function isKnownSideEffectFree(filePath: string) {
60-
return ngFactories.some((re) => re.test(filePath)) || (
61-
whitelistedAngularModules.some((re) => re.test(filePath))
62-
&& es5AngularModules.some((re) => re.test(filePath))
63-
);
48+
return ngFactories.some((re) => re.test(filePath)) ||
49+
whitelistedAngularModules.some((re) => re.test(filePath));
6450
}
6551

6652
export interface BuildOptimizerOptions {

packages/angular_devkit/build_optimizer/src/build-optimizer/build-optimizer_spec.ts

-18
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,6 @@ describe('build-optimizer', () => {
8989
});
9090
});
9191

92-
it('supports es2015 modules', () => {
93-
// prefix-functions would add PURE_IMPORTS_START and PURE to the super call.
94-
// This test ensures it isn't applied to es2015 modules.
95-
const output = tags.oneLine`
96-
import { Injectable } from '@angular/core';
97-
class Clazz extends BaseClazz { constructor(e) { super(e); } }
98-
`;
99-
const input = tags.stripIndent`
100-
${output}
101-
Clazz.ctorParameters = () => [ { type: Injectable } ];
102-
`;
103-
104-
const inputFilePath = '/node_modules/@angular/core/@angular/core.js';
105-
const boOutput = buildOptimizer({ content: input, inputFilePath });
106-
expect(tags.oneLine`${boOutput.content}`).toEqual(output);
107-
expect(boOutput.emitSkipped).toEqual(false);
108-
});
109-
11092
it('supports flagging module as side-effect free', () => {
11193
const output = tags.oneLine`
11294
/** PURE_IMPORTS_START PURE_IMPORTS_END */

0 commit comments

Comments
 (0)