6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
import { readFileSync } from 'fs' ;
9
- import { TransformJavascriptOutput , transformJavascript } from '../helpers/transform-javascript' ;
9
+ import {
10
+ TransformJavascriptOptions ,
11
+ TransformJavascriptOutput ,
12
+ transformJavascript ,
13
+ } from '../helpers/transform-javascript' ;
10
14
import { getFoldFileTransformer } from '../transforms/class-fold' ;
11
15
import { getImportTslibTransformer , testImportTslib } from '../transforms/import-tslib' ;
12
16
import { getPrefixClassesTransformer , testPrefixClasses } from '../transforms/prefix-classes' ;
@@ -62,6 +66,7 @@ export interface BuildOptimizerOptions {
62
66
outputFilePath ?: string ;
63
67
emitSourceMap ?: boolean ;
64
68
strict ?: boolean ;
69
+ isSideEffectFree ?: boolean ;
65
70
}
66
71
67
72
export function buildOptimizer ( options : BuildOptimizerOptions ) : TransformJavascriptOutput {
@@ -92,7 +97,7 @@ export function buildOptimizer(options: BuildOptimizerOptions): TransformJavascr
92
97
getTransforms . push ( getPrefixClassesTransformer ) ;
93
98
}
94
99
95
- if ( inputFilePath && isKnownSideEffectFree ( inputFilePath ) ) {
100
+ if ( options . isSideEffectFree || inputFilePath && isKnownSideEffectFree ( inputFilePath ) ) {
96
101
getTransforms . push (
97
102
// getPrefixFunctionsTransformer is rather dangerous, apply only to known pure es5 modules.
98
103
// It will mark both `require()` calls and `console.log(stuff)` as pure.
@@ -109,5 +114,14 @@ export function buildOptimizer(options: BuildOptimizerOptions): TransformJavascr
109
114
) ;
110
115
}
111
116
112
- return transformJavascript ( { ...options , getTransforms, content } ) ;
117
+ const transformJavascriptOpts : TransformJavascriptOptions = {
118
+ content : content ,
119
+ inputFilePath : options . inputFilePath ,
120
+ outputFilePath : options . outputFilePath ,
121
+ emitSourceMap : options . emitSourceMap ,
122
+ strict : options . strict ,
123
+ getTransforms,
124
+ } ;
125
+
126
+ return transformJavascript ( transformJavascriptOpts ) ;
113
127
}
0 commit comments