Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@darwin
Created January 21, 2020 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darwin/c75123726c56e965623eba07aa660e1b to your computer and use it in GitHub Desktop.
Save darwin/c75123726c56e965623eba07aa660e1b to your computer and use it in GitHub Desktop.
diff --git a/src/main/shadow/build/closure.clj b/src/main/shadow/build/closure.clj
index 362450be..2912b866 100644
--- a/src/main/shadow/build/closure.clj
+++ b/src/main/shadow/build/closure.clj
@@ -23,7 +23,7 @@
CommandLineRunner VariableMap SourceMapInput DiagnosticGroups
CheckLevel JSModule CompilerOptions$LanguageMode
Result ShadowAccess
- SourceMap$DetailLevel SourceMap$Format ClosureCodingConvention CompilationLevel AnonymousFunctionNamingPolicy DiagnosticGroup NodeTraversal StrictModeCheck VariableRenamingPolicy PropertyRenamingPolicy PhaseOptimizer)
+ SourceMap$DetailLevel SourceMap$Format ClosureCodingConvention CompilationLevel AnonymousFunctionNamingPolicy DiagnosticGroup NodeTraversal StrictModeCheck VariableRenamingPolicy PropertyRenamingPolicy PhaseOptimizer CompilerOptions$Reach)
(shadow.build.closure ReplaceCLJSConstants NodeEnvInlinePass ReplaceRequirePass PropertyCollector NodeStuffInlinePass FindSurvivingRequireCalls ClearUnassignedJsRequires)
(com.google.javascript.jscomp.deps ModuleLoader$ResolutionMode)
(java.nio.charset Charset)
@@ -136,6 +136,15 @@
:mapped AnonymousFunctionNamingPolicy/MAPPED
(throw (IllegalArgumentException. (str "Invalid :anon-fn-naming-policy value " policy " - only :off, :unmapped, :mapped permitted")))))))
+ (when (contains? opts :remove-unused-variables)
+ (let [policy (:remove-unused-variables opts)
+ reach (case policy
+ :none CompilerOptions$Reach/NONE
+ :local-only CompilerOptions$Reach/LOCAL_ONLY
+ :all CompilerOptions$Reach/ALL
+ (throw (IllegalArgumentException. (str "Invalid :remove-unused-variables value " policy " - only :none, :local-only, :all permitted"))))]
+ (.setRemoveUnusedVariables closure-opts reach)))
+
(when-let [lang-key (:language-in opts)]
(.setLanguageIn closure-opts (lang-key->lang-mode lang-key)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment