From bb8111728e406976a943c81592350d3ee3ec52b9 Mon Sep 17 00:00:00 2001 From: Thomas Heller Date: Sun, 22 Apr 2018 18:48:01 +0200 Subject: [PATCH] make it possible to toggle :variable-renaming and :property-renaming :variable-renaming can mess with npm graphql. not changing the default for now since it only seems to affect graphql for now and the impact of disabling can be quite substantial --- src/main/shadow/build/closure.clj | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/shadow/build/closure.clj b/src/main/shadow/build/closure.clj index 4a02a894..7e126c6b 100644 --- a/src/main/shadow/build/closure.clj +++ b/src/main/shadow/build/closure.clj @@ -22,7 +22,7 @@ CommandLineRunner VariableMap SourceMapInput DiagnosticGroups CheckLevel JSModule CompilerOptions$LanguageMode SourceMap$LocationMapping BasicErrorManager Result ShadowAccess - SourceMap$DetailLevel SourceMap$Format ClosureCodingConvention CompilationLevel AnonymousFunctionNamingPolicy DiagnosticGroup NodeTraversal StrictModeCheck) + SourceMap$DetailLevel SourceMap$Format ClosureCodingConvention CompilationLevel AnonymousFunctionNamingPolicy DiagnosticGroup NodeTraversal StrictModeCheck VariableRenamingPolicy PropertyRenamingPolicy) (shadow.build.closure ReplaceCLJSConstants NodeEnvInlinePass ReplaceRequirePass PropertyCollector) (com.google.javascript.jscomp.deps ModuleLoader$ResolutionMode ModuleNames) (com.google.javascript.jscomp.parsing.parser FeatureSet) @@ -139,9 +139,6 @@ (when (contains? opts :closure-extra-annotations) (. closure-opts (setExtraAnnotationNames (map name (:closure-extra-annotations opts))))) - (when (contains? opts :closure-module-roots) - (. closure-opts (setModuleRoots (:closure-module-roots opts)))) - (when (contains? opts :closure-generate-exports) (. closure-opts (setGenerateExports (:closure-generate-exports opts)))) @@ -150,6 +147,26 @@ (. closure-opts (setOutputCharset (Charset/forName (:closure-output-charset opts "UTF-8")))) + (when (contains? opts :variable-renaming) + (.setVariableRenaming + closure-opts + (case (:variable-renaming opts) + false VariableRenamingPolicy/OFF + :off VariableRenamingPolicy/OFF + :local VariableRenamingPolicy/LOCAL + :all VariableRenamingPolicy/ALL + (throw (ex-info "invalid :variable-renaming (use :off, :local or :all)" {}))))) + + (when (contains? opts :property-renaming) + (.setPropertyRenaming + closure-opts + (case (:property-renaming opts) + false PropertyRenamingPolicy/OFF + :off PropertyRenamingPolicy/OFF + true PropertyRenamingPolicy/ALL_UNQUOTED + :all-unquoted PropertyRenamingPolicy/ALL_UNQUOTED + (throw (ex-info "invalid :property-renaming (use :off or :all-unquoted)" {}))))) + closure-opts) (defn ^CompilerOptions make-options []