say I am compiling something with cljs.analyzer
in it. Where can I get the analysis cache for it? Is there a place where to find it? I am also thinking whether it should be published on npm
for lumo
consumption (we don't have cache
support yet but it would be awesome to have)
@richiardiandrea If I understand your first question, usually out/cljs/analyzer.cljc.cache.json
.
yep I can find that file in target
because I compile lumo
myself...but I think it should be published for consumption now that we can compile with it
or compilation will fail
(or I am doing something else wrong ;))
Ahh, interesting: One problem with attempting to publish any compiled artifacts is that if the compiler version changes, the artifacts become invalid.
ah, so ideally lumo
should publish its own release cache files
no well, any Cljs compiler files should work...only they have to be the same version
Well, all I'm saying is: If you publish a ClojureScript library for general use, attempting to include compiled artifacts leads to the possibility of a version mismatch. So, most ClojureScript libraries comprise only source code.
Even pointing the classpath to cache fails still has some spurious warning and failures...will need to dig more:
WARNING: Use of undeclared Var cljs.analyzer/no-warn at line 855
WARNING: Use of undeclared Var cljs.analyzer/no-warn at line 873
WARNING: Use of undeclared Var cljs.analyzer/no-warn at line 2495
WARNING: Use of undeclared Var cljs.analyzer/no-warn at line 2516
WARNING: Use of undeclared Var cljs.analyzer/no-warn at line 2536
Copying lumo/io.cljs to out/lumo/io.cljs
Compiling out/lumo/io.cljs
Copying cljs/spec/gen/alpha.cljs to out/cljs/spec/gen/alpha.cljs
Compiling out/cljs/spec/gen/alpha.cljs
Copying cljs/spec/alpha.cljs to out/cljs/spec/alpha.cljs
Compiling out/cljs/spec/alpha.cljs
failed compiling file:out/cljs/spec/alpha.cljs
(new)
Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2058:72)
(evalmachine.<anonymous>:644:25)
Function.lumo.compiler.compile_file.cljs$core$IFn$_invoke$arity$3 (evalmachine.<anonymous>:655:4)
(Object.lumo$closure$compile_file)
(evalmachine.<anonymous>:1644:21)
(Object.lumo$closure$_compile)
(Object.lumo$closure$compile_from_jar)
(evalmachine.<anonymous>:1679:21)
(Object.lumo$closure$_compile)
Cannot write
Object.com.cognitect.transit.impl.writer.marshal (NO_SOURCE_FILE <embedded>:6021:288)
Object.com.cognitect.transit.impl.writer.emitObjects (NO_SOURCE_FILE <embedded>:6008:181)
Object.com.cognitect.transit.impl.writer.emitArray (NO_SOURCE_FILE <embedded>:6008:407)
Object.com.cognitect.transit.impl.writer.marshal (NO_SOURCE_FILE <embedded>:6021:58)
(NO_SOURCE_FILE <embedded>:6014:409)
cljs.core.PersistentHashMap.forEach (NO_SOURCE_FILE <embedded>:1503:182)
Object.com.cognitect.transit.impl.writer.emitMap (NO_SOURCE_FILE <embedded>:6014:286)
Object.com.cognitect.transit.impl.writer.marshal (NO_SOURCE_FILE <embedded>:6021:129)
Object.com.cognitect.transit.impl.writer.marshalTop (NO_SOURCE_FILE <embedded>:6023:120)
com.cognitect.transit.impl.writer.Writer.write (NO_SOURCE_FILE <embedded>:6024:390)
this last stacktrace is with cljs 1.9.1104
@richiardiandrea Is this a new Lumo build failure that occurred simply by switching to 1.9.1104?
no well this is my experiments compiling some code containing cljs.analyzer
Oh. So... hah 🙂
ClojureScript is self-hosting... but this raises the question: Can the self-hosted compiler then compile itself again (2nd stage). In general so far the answer has been "no".
In other words, ClojureScript isn't truly "bootstrapped" in the sense that it is still tied to the JVM for the first compile.
Oooo ok, so well then all the code that relies on compiler features cannot compile itself? For instance a lib that wants to use warning handler functions...
if that does not work probably those should be re-factored out there?
So, what I've done in Planck, (and I assume Lumo does the same), is that things like analyzer.cljc
are indeed compiled down to JavaScript and analysis cache, and then bundled with Planck. So, you can use the cljs.analyzer
namespace (`:require` it). But it is another matter altogether to try to point Planck or Lumo at analyzer.cljc
and try to have it compile that file.
I am specifically using this piece of code:
(defn exit-on-warning!
[warning-type env extra]
(when (warning-type ana/*cljs-warnings*)
(when-let [s (ana/error-message warning-type extra)]
(binding [*print-fn* *print-err-fn*]
(println "lumo error:" (ana/message env s)))
(lumo.core/exit 1))))
yep I am doing that already...I think
Sure, that seems fine in that that code is only using ana
. Not compiling it.
lumo -K -c ~/git/lumo/target:serverless-cljs-plugin lumo-compile.cljs
but it is requiring it as well and I guess that triggers something I cannot grasp now 😄
maybe it is not using the cache then
$ lumo
Lumo 1.7.0
ClojureScript 1.9.908
Node.js v8.4.0
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Exit: Control+D or :cljs/quit or exit
cljs.user=> (require '[cljs.analyzer :as ana])
nil
cljs.user=> (require 'lumo.core)
nil
cljs.user=> (defn exit-on-warning!
#_=> [warning-type env extra]
#_=> (when (warning-type ana/*cljs-warnings*)
#_=> (when-let [s (ana/error-message warning-type extra)]
#_=> (binding [*print-fn* *print-err-fn*]
#_=> (println "lumo error:" (ana/message env s)))
#_=> (lumo.core/exit 1))))
#'cljs.user/exit-on-warning!
cljs.user=>
yep that works at the repl
it is compilation that is not 😉
Ahh. I've never delved into the subtle differences.
I think it has something to do with what you where saying above about not being able to compile itself...and it is probably not using the cache, I will report back 🙂
My first reaction would be to try to have the Lumo compilation mode load compiled artifacts from the Lumo binary if they happen to be things produced from source like analyzer.cljc
In other words, make the compilation mode work just like the REPL mode when it comes to loading stuff like that. But then again, I've never looked at that aspect of Lumo.
I think lumo
does that already
there is some difference though that waits to be discovered in there, bug or subtlety
I have to say that the JVM compiler is faster in this regard
but lumo
is in early stages about compilation
Yeah. You definitely feel the difference in speed when working with Coal Mine. The Clojure compiler can load some of that corpus in seconds, while ClojureScript JVM is in minutes, and Planck gets closer to hours. 🙂
I think I fixed a warning
in cljs core...will open a ticket
Going back to the idea of a common place for projects like lumo
, planck
and closh
... I think that cljs-oss
can be a good place
@richiardiandrea If you end up digging into adding Lumo to Canary, I've distilled the steps into the README. If you see anything inaccurate, we can get it fixed. I'll invite you to the repo so you can push stuff into it.
I have some of the steps ready in a local branch and I think I just need the token or understand how to produce one, afk at the moment. I will read the Readme thanks!