boot-clj / boot-cljs

Boot task to compile ClojureScript programs.
Eclipse Public License 1.0
176 stars 40 forks source link

Externs inference in 1.9.456 #149

Closed mgerlach-klick closed 7 years ago

mgerlach-klick commented 7 years ago

Could you maybe add some instructions on how to make use of the new ClojureScript 1.9.456 Externs Inference feature? I did naively just try to use the new CLJS version and was looking for the output file, but that clearly wasn't enough :) Or is that simply not supported yet?

Deraen commented 7 years ago

Works fine for me.

❯ grep baz target/js/main.out/inferred_externs.js 
Foo.prototype.baz;

Did you enable compiler-option and set the dynamic var?

Also, the file is not visible at browser as externs are only used for compilation, so use target task to check if the file exists.

mgerlach-klick commented 7 years ago

Hm, interesting.

I am using this task: (deftask build [] (comp (cljs :optimizations :advanced :infer-externs true ) (target)))

and I am setting the *warn-on-infer* var, but when running boot build it complains

cljs: unknown option(s): :infer-externs

and there is no inferred_externs.js file anywhere to be found.

Any ideas?

For completeness' sake, I am using: (set-env! :dependencies '[[adzerk/boot-cljs "1.7.228-2" :scope "test"] [org.clojure/clojurescript "1.9.456"]])

Deraen commented 7 years ago

:infer-externs is not valid option to cljs task, you need to provide :compiler-options option instead:

(cljs :compiler-options {:infer-externs true}) or use .cljs.edn file.

mgerlach-klick commented 7 years ago

Oh, that's the piece I was missing! Thank you! Do I still need to specify a deps.cljs or would the compiler now take care of that for me?

Deraen commented 7 years ago

If you need to include foreign JS files, yes, you need deps.cljs to include those files, but you don't need :externs property.

mgerlach-klick commented 7 years ago

Thank you! Closing this as I am all out of questions. Thank you so much for your help!