File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
src/com/google/javascript/jscomp Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 16
16
17
17
package com .google .javascript .jscomp ;
18
18
19
+ import com .google .javascript .jscomp .CompilerOptions .ChunkOutputType ;
19
20
import com .google .javascript .jscomp .Es6RewriteDestructuring .ObjectDestructuringRewriteMode ;
20
21
import com .google .javascript .jscomp .parsing .parser .FeatureSet ;
21
22
import com .google .javascript .jscomp .parsing .parser .FeatureSet .Feature ;
@@ -108,6 +109,18 @@ public static void addEarlyOptimizationTranspilationPasses(
108
109
passes .maybeAdd (rewriteCatchWithNoBinding );
109
110
}
110
111
112
+ if (options .getChunkOutputType () != ChunkOutputType .ES_MODULES ) {
113
+ // Default output mode of JSCompiler is a script, unless chunkOutputType is set to
114
+ // `ES_MODULES` where each output chunk is an ES module.
115
+ passes .maybeAdd (createFeatureRemovalPass ("markModulesRemoved" , Feature .MODULES ));
116
+ // Since import.meta cannot be transpiled, it is passed-through when the output format
117
+ // is a module. Otherwise it must be marked removed.
118
+ passes .maybeAdd (createFeatureRemovalPass ("markImportMetaRemoved" , Feature .IMPORT_META ));
119
+ // Dynamic imports are preserved for open source output only when the chunk output type is
120
+ // ES_MODULES
121
+ passes .maybeAdd (createFeatureRemovalPass ("markDynamicImportRemoved" , Feature .DYNAMIC_IMPORT ));
122
+ }
123
+
111
124
if (options .needsTranspilationOf (Feature .FOR_AWAIT_OF )
112
125
|| options .needsTranspilationOf (Feature .ASYNC_GENERATORS )) {
113
126
passes .maybeAdd (rewriteAsyncIteration );
You can’t perform that action at this time.
0 commit comments