This repository was archived by the owner on Apr 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +3
-35
lines changed
packages/angular_devkit/build_optimizer/src/build-optimizer Expand file tree Collapse file tree 2 files changed +3
-35
lines changed Original file line number Diff line number Diff line change @@ -37,30 +37,16 @@ const whitelistedAngularModules = [
3737 / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] @ a n g u l a r [ \\ / ] c d k [ \\ / ] / ,
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- / \. e s 5 \. j s $ / , // Angular 4
45- // Angular 5 has esm5 folders.
46- // Angular 6 has fesm5 folders.
47- / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] @ a n g u l a r [ \\ / ] [ ^ \\ / ] + [ \\ / ] f ? e s m 5 [ \\ / ] / ,
48- // All Angular versions have UMD with es5.
49- / \. u m d \. j s $ / ,
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`.
5442const ngFactories = [
5543 / \. n g f a c t o r y \. [ j t ] s / ,
5644 / \. n g s t y l e \. [ j t ] s / ,
5745] ;
5846
5947function 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
6652export interface BuildOptimizerOptions {
Original file line number Diff line number Diff 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 */
You can’t perform that action at this time.
0 commit comments