lumo

:lumo: Standalone ClojureScript environment. Currently at version 1.9.0
richiardiandrea 2018-01-28T02:21:58.000063Z

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)

mfikes 2018-01-28T02:26:47.000039Z

@richiardiandrea If I understand your first question, usually out/cljs/analyzer.cljc.cache.json.

richiardiandrea 2018-01-28T02:27:37.000056Z

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

richiardiandrea 2018-01-28T02:27:50.000055Z

or compilation will fail

richiardiandrea 2018-01-28T02:28:13.000076Z

(or I am doing something else wrong ;))

mfikes 2018-01-28T02:30:03.000067Z

Ahh, interesting: One problem with attempting to publish any compiled artifacts is that if the compiler version changes, the artifacts become invalid.

richiardiandrea 2018-01-28T02:30:47.000061Z

ah, so ideally lumo should publish its own release cache files

richiardiandrea 2018-01-28T02:31:42.000075Z

no well, any Cljs compiler files should work...only they have to be the same version

mfikes 2018-01-28T02:32:52.000012Z

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.

👍 1
richiardiandrea 2018-01-28T02:34:08.000082Z

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)

richiardiandrea 2018-01-28T02:35:58.000040Z

this last stacktrace is with cljs 1.9.1104

mfikes 2018-01-28T02:39:50.000027Z

@richiardiandrea Is this a new Lumo build failure that occurred simply by switching to 1.9.1104?

richiardiandrea 2018-01-28T02:40:31.000030Z

no well this is my experiments compiling some code containing cljs.analyzer

mfikes 2018-01-28T02:42:15.000015Z

Oh. So... hah 🙂

mfikes 2018-01-28T02:42:59.000060Z

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".

mfikes 2018-01-28T02:43:59.000040Z

In other words, ClojureScript isn't truly "bootstrapped" in the sense that it is still tied to the JVM for the first compile.

richiardiandrea 2018-01-28T02:44:26.000054Z

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...

richiardiandrea 2018-01-28T02:44:58.000060Z

if that does not work probably those should be re-factored out there?

mfikes 2018-01-28T02:46:27.000061Z

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.

richiardiandrea 2018-01-28T02:46:44.000017Z

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))))

richiardiandrea 2018-01-28T02:47:03.000082Z

yep I am doing that already...I think

mfikes 2018-01-28T02:47:15.000086Z

Sure, that seems fine in that that code is only using ana. Not compiling it.

richiardiandrea 2018-01-28T02:47:23.000070Z

lumo -K -c ~/git/lumo/target:serverless-cljs-plugin lumo-compile.cljs

richiardiandrea 2018-01-28T02:48:10.000013Z

but it is requiring it as well and I guess that triggers something I cannot grasp now 😄

richiardiandrea 2018-01-28T02:49:20.000054Z

maybe it is not using the cache then

mfikes 2018-01-28T02:49:42.000034Z

$ 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=>

richiardiandrea 2018-01-28T02:49:55.000004Z

yep that works at the repl

richiardiandrea 2018-01-28T02:50:03.000023Z

it is compilation that is not 😉

mfikes 2018-01-28T02:50:22.000070Z

Ahh. I've never delved into the subtle differences.

richiardiandrea 2018-01-28T02:52:06.000040Z

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 🙂

mfikes 2018-01-28T02:52:32.000011Z

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

mfikes 2018-01-28T02:53:22.000054Z

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.

richiardiandrea 2018-01-28T02:53:48.000011Z

I think lumo does that already

richiardiandrea 2018-01-28T02:54:46.000095Z

there is some difference though that waits to be discovered in there, bug or subtlety

richiardiandrea 2018-01-28T02:55:12.000090Z

I have to say that the JVM compiler is faster in this regard

richiardiandrea 2018-01-28T02:55:42.000078Z

but lumo is in early stages about compilation

mfikes 2018-01-28T02:56:14.000167Z

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. 🙂

richiardiandrea 2018-01-28T02:58:12.000049Z

I think I fixed a warning

richiardiandrea 2018-01-28T02:58:21.000049Z

in cljs core...will open a ticket

richiardiandrea 2018-01-28T03:15:21.000051Z

https://dev.clojure.org/jira/browse/CLJS-2485

richiardiandrea 2018-01-28T03:19:38.000063Z

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

mfikes 2018-01-28T18:08:34.000047Z

@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.

👍 1
richiardiandrea 2018-01-28T19:54:37.000064Z

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!