Skip to content

Commit

Permalink
Allow to disable renaming for the JS version of the compiler.
Browse files Browse the repository at this point in the history
Closes #2707

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=175026611
  • Loading branch information
gaearon authored and dimvar committed Nov 9, 2017
1 parent cccb51e commit 5faf29c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/com/google/javascript/jscomp/gwt/client/GwtRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
import com.google.javascript.jscomp.DiagnosticType;
import com.google.javascript.jscomp.JSError;
import com.google.javascript.jscomp.ModuleIdentifier;
import com.google.javascript.jscomp.PropertyRenamingPolicy;
import com.google.javascript.jscomp.SourceFile;
import com.google.javascript.jscomp.SourceMap;
import com.google.javascript.jscomp.SourceMapInput;
import com.google.javascript.jscomp.VariableRenamingPolicy;
import com.google.javascript.jscomp.WarningLevel;
import com.google.javascript.jscomp.deps.ModuleLoader.ResolutionMode;
import com.google.javascript.jscomp.deps.SourceCodeEscapers;
Expand Down Expand Up @@ -97,6 +99,7 @@ private static class Flags {
boolean preserveTypeAnnotations;
boolean processClosurePrimitives;
boolean processCommonJsModules;
boolean renaming;
public String renamePrefixNamespace;
boolean rewritePolyfills;
String warningLevel;
Expand Down Expand Up @@ -141,6 +144,7 @@ private static class Flags {
defaultFlags.processClosurePrimitives = true;
defaultFlags.processCommonJsModules = false;
defaultFlags.renamePrefixNamespace = null;
defaultFlags.renaming = true;
defaultFlags.rewritePolyfills = true;
defaultFlags.warningLevel = "DEFAULT";
defaultFlags.useTypesForOptimization = true;
Expand Down Expand Up @@ -333,6 +337,10 @@ private static void applyOptionsFromFlags(CompilerOptions options, Flags flags)
"Bad value for compilationLevel: " + flags.compilationLevel);
}
}
if (level == CompilationLevel.ADVANCED_OPTIMIZATIONS && !flags.renaming) {
throw new RuntimeException(
"renaming cannot be disabled when ADVANCED_OPTMIZATIONS is used");
}
level.setOptionsForCompilationLevel(options);
if (flags.assumeFunctionWrapper) {
level.setWrappedOutputOptimizations(options);
Expand Down Expand Up @@ -417,6 +425,10 @@ private static void applyOptionsFromFlags(CompilerOptions options, Flags flags)
options.setClosurePass(flags.processClosurePrimitives);
options.setProcessCommonJSModules(flags.processCommonJsModules);
options.setRenamePrefixNamespace(flags.renamePrefixNamespace);
if (!flags.renaming) {
options.setVariableRenaming(VariableRenamingPolicy.OFF);
options.setPropertyRenaming(PropertyRenamingPolicy.OFF);
}
options.setRewritePolyfills(flags.rewritePolyfills);
}

Expand Down

0 comments on commit 5faf29c

Please sign in to comment.