@@ -10,6 +10,7 @@ import {
10
10
import {
11
11
DIST_BUNDLES , DIST_ROOT , SOURCE_ROOT , PROJECT_ROOT , LICENSE_BANNER , MATERIAL_VERSION
12
12
} from '../constants' ;
13
+ import { addPureAnnotations } from './annotate-pure' ;
13
14
14
15
// There are no type definitions available for these imports.
15
16
const uglify = require ( 'uglify-js' ) ;
@@ -38,6 +39,7 @@ export function composeRelease(packageName: string) {
38
39
updatePackageVersion ( releasePath ) ;
39
40
createTypingFile ( releasePath , packageName ) ;
40
41
createMetadataFile ( releasePath , packageName ) ;
42
+ addPureAnnotationCommentsToEs5Bundle ( releasePath , packageName ) ;
41
43
}
42
44
43
45
/** Builds the bundles for the specified package. */
@@ -156,3 +158,12 @@ function inlinePackageMetadataFiles(packagePath: string) {
156
158
writeFileSync ( path , JSON . stringify ( metadata ) , 'utf-8' ) ;
157
159
} ) ;
158
160
}
161
+
162
+ /** Adds Uglify "@__PURE__" decorations to the generated ES5 bundle. */
163
+ function addPureAnnotationCommentsToEs5Bundle ( outputDir : string , entryName : string ) {
164
+ const es5BundlePath = join ( outputDir , '@angular' , `${ entryName } .es5.js` ) ;
165
+ const originalContent = readFileSync ( es5BundlePath , 'utf-8' ) ;
166
+ const annotatedContent = addPureAnnotations ( originalContent ) ;
167
+
168
+ writeFileSync ( es5BundlePath , annotatedContent , 'utf-8' ) ;
169
+ }
0 commit comments