Add "moduleResolutionMode", "isolationMode" and "processClosurePrimitives" to GwtRunner flags to help compiling Node code
@@ -29,6 +29,7 @@ import com.google.javascript.jscomp.CheckLevel;
import com.google.javascript.jscomp.CompilationLevel;
import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.CompilerOptions;
+import com.google.javascript.jscomp.CompilerOptions.IsolationMode;
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import com.google.javascript.jscomp.CompilerOptions.TracerMode;
import com.google.javascript.jscomp.DefaultExterns;
@@ -41,6 +42,7 @@ import com.google.javascript.jscomp.SourceFile;
import com.google.javascript.jscomp.SourceMap;
import com.google.javascript.jscomp.SourceMapInput;
import com.google.javascript.jscomp.WarningLevel;
+import com.google.javascript.jscomp.deps.ModuleLoader.ResolutionMode;
import com.google.javascript.jscomp.deps.SourceCodeEscapers;
import java.io.IOException;
import java.io.OutputStream;
@@ -87,17 +89,20 @@ public final class GwtRunner implements EntryPoint {
String languageOut;
boolean checksOnly;
boolean newTypeInf;
+ String isolationMode;
String outputWrapper;
@Deprecated
boolean polymerPass;
Integer polymerVersion;
boolean preserveTypeAnnotations;
+ boolean processClosurePrimitives;
boolean processCommonJsModules;
public String renamePrefixNamespace;
boolean rewritePolyfills;
String warningLevel;
boolean useTypesForOptimization;
String tracerMode;
+ String moduleResolutionMode;
// These flags do not match the Java compiler JAR.
File[] jsCode;
@@ -128,9 +133,11 @@ public final class GwtRunner implements EntryPoint {
defaultFlags.languageIn = "ECMASCRIPT6";
defaultFlags.languageOut = "ECMASCRIPT5";
defaultFlags.newTypeInf = false;
+ defaultFlags.isolationMode = "NONE";
defaultFlags.outputWrapper = null;
defaultFlags.polymerVersion = null;
defaultFlags.preserveTypeAnnotations = false;
+ defaultFlags.processClosurePrimitives = true;
defaultFlags.processCommonJsModules = false;
defaultFlags.renamePrefixNamespace = null;
defaultFlags.rewritePolyfills = true;
@@ -140,6 +147,7 @@ public final class GwtRunner implements EntryPoint {
defaultFlags.externs = null;
defaultFlags.createSourceMap = false;
defaultFlags.tracerMode = "OFF";
+ defaultFlags.moduleResolutionMode = "LEGACY";
}
@JsType(namespace = JsPackage.GLOBAL, name = "Object", isNative = true)
@@ -383,6 +391,15 @@ public final class GwtRunner implements EntryPoint {
options.setTracerMode(TracerMode.valueOf(flags.tracerMode));
}
+ if (flags.moduleResolutionMode != null) {
+ options.setModuleResolutionMode(ResolutionMode.valueOf(flags.moduleResolutionMode));
+ }
+
+ if (flags.isolationMode != null
+ && IsolationMode.valueOf(flags.isolationMode) == IsolationMode.IIFE) {
+ flags.outputWrapper = "(function(){%output%}).call(this);";
+ }
+
options.setAngularPass(flags.angularPass);
options.setApplyInputSourceMaps(flags.applyInputSourceMaps);
options.setChecksOnly(flags.checksOnly);
@@ -396,6 +413,7 @@ public final class GwtRunner implements EntryPoint {
options.setPolymerVersion(flags.polymerVersion);
}
options.setPreserveTypeAnnotations(flags.preserveTypeAnnotations);
+ options.setClosurePass(flags.processClosurePrimitives);
options.setProcessCommonJSModules(flags.processCommonJsModules);
options.setRenamePrefixNamespace(flags.renamePrefixNamespace);
options.setRewritePolyfills(flags.rewritePolyfills);
