File tree 7 files changed +67
-4
lines changed
7 files changed +67
-4
lines changed Original file line number Diff line number Diff line change
1
+ core.min.js
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " terser" ,
3
+ "version" : " 0.0.0" ,
4
+ "scripts" : {
5
+ "test" : " node test.js"
6
+ },
7
+ "private" : true ,
8
+ "dependencies" : {
9
+ "@angular/core" : " file:../../dist/packages-dist/core" ,
10
+ "@angular/compiler" : " file:../../dist/packages-dist/compiler" ,
11
+ "@angular/compiler-cli" : " file:../../dist/packages-dist/compiler-cli" ,
12
+ "rxjs" : " file:../../node_modules/rxjs" ,
13
+ "terser" : " 3.17.0" ,
14
+ "zone.js" : " file:../../node_modules/zone.js"
15
+ }
16
+ }
Original file line number Diff line number Diff line change
1
+ const readFileSync = require ( 'fs' ) . readFileSync ;
2
+ const writeFileSync = require ( 'fs' ) . writeFileSync ;
3
+ const resolve = require ( 'path' ) . resolve ;
4
+ const Terser = require ( 'terser' ) ;
5
+ const GLOBAL_DEFS_FOR_TERSER = require ( '@angular/compiler-cli' ) . GLOBAL_DEFS_FOR_TERSER ;
6
+
7
+ const outputPath = resolve ( __dirname , './core.min.js' ) ;
8
+ const pathToCoreFesm5 = resolve ( __dirname , './node_modules/@angular/core/fesm5/core.js' ) ;
9
+ const coreFesm5Content = readFileSync ( pathToCoreFesm5 , 'utf8' ) ;
10
+ // Ensure that Terser global_defs exported by compiler-cli work.
11
+ const terserOpts = {
12
+ compress : {
13
+ module : true ,
14
+ global_defs : GLOBAL_DEFS_FOR_TERSER
15
+ }
16
+ } ;
17
+ const result = Terser . minify ( coreFesm5Content , terserOpts ) ;
18
+ writeFileSync ( outputPath , result . code ) ;
19
+
20
+ for ( const def of Object . keys ( GLOBAL_DEFS_FOR_TERSER ) ) {
21
+ if ( result . code . includes ( def ) ) {
22
+ throw `'${ def } ' should have been removed from core bundle, but was still there.\n` +
23
+ `See output at ${ outputPath } .` ;
24
+ }
25
+ }
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ export * from './src/transformers/api';
17
17
export * from './src/transformers/entry_points' ;
18
18
19
19
export * from './src/perform_compile' ;
20
+ export * from './src/tooling' ;
20
21
21
22
// TODO(tbosch): remove this once cli 1.5 is fully released,
22
23
// and usages in G3 are changed to `CompilerOptions`.
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @license
3
+ * Copyright Google Inc. All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+
9
+ /**
10
+ * @module
11
+ * @description
12
+ * Tooling support helpers.
13
+ */
14
+
15
+ /**
16
+ * Known values for global variables in `@angular/core` that Terser should set using
17
+ * https://github.com/terser-js/terser#conditional-compilation
18
+ */
19
+ export const GLOBAL_DEFS_FOR_TERSER = {
20
+ ngDevMode : false ,
21
+ ngI18nClosureMode : false ,
22
+ } ;
Original file line number Diff line number Diff line change @@ -83,8 +83,7 @@ export function ngDevModeResetPerfCounters(): NgDevModePerfCounters {
83
83
* set `ngDevMode == false` we should be helping the developer by providing
84
84
* as much early warning and errors as possible.
85
85
*
86
- * NOTE: changes to the `ngDevMode` name must be synced with the CLI and
87
- * possibly other third party tooling. Check with them before altering it.
86
+ * NOTE: changes to the `ngDevMode` name must be synced with `compiler-cli/src/tooling.ts`.
88
87
*/
89
88
if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
90
89
ngDevModeResetPerfCounters ( ) ;
Original file line number Diff line number Diff line change @@ -13,8 +13,7 @@ declare global {
13
13
}
14
14
15
15
/**
16
- * NOTE: changes to the `ngI18nClosureMode` name must be synced with the CLI and
17
- * possibly other third party tooling. Check with them before altering it.
16
+ * NOTE: changes to the `ngI18nClosureMode` name must be synced with `compiler-cli/src/tooling.ts`.
18
17
*/
19
18
if ( typeof ngI18nClosureMode === 'undefined' ) {
20
19
// Make sure to refer to ngI18nClosureMode as ['ngI18nClosureMode'] for closure.
You can’t perform that action at this time.
0 commit comments