Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to disable renaming for the JS compiler #2707

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -332,6 +336,10 @@ private static void applyOptionsFromFlags(CompilerOptions options, Flags flags)
throw new RuntimeException(
"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) {
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 == false) {
options.setVariableRenaming(VariableRenamingPolicy.OFF);
options.setPropertyRenaming(PropertyRenamingPolicy.OFF);
}
options.setRewritePolyfills(flags.rewritePolyfills);
}

Expand Down