Skip to content

Commit

Permalink
make it possible to toggle :variable-renaming and :property-renaming
Browse files Browse the repository at this point in the history
: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
  • Loading branch information
thheller committed Apr 22, 2018
1 parent dab56fb commit bb81117
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/main/shadow/build/closure.clj
Expand Up @@ -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)
Expand Down Expand Up @@ -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))))

Expand All @@ -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 []
Expand Down

0 comments on commit bb81117

Please sign in to comment.