Start compiling cljs to JS using node / browser
I believe this is a goal, but not sure what's are the blockers to get there. Maybe we can discuss and link remaining issues here.
There are several parts to this:
- Port closure.clj and cljsc.clj
- Implement fuller (ns ...) support. Things like :refer and :only for :require and :use (on the ClojureScript side rather than the Clojure side)
- Implement require/use functions
- Get core.cljs compiling with ClojureScript. There are several tough nuts to crack under this one.
- The way that namespaces and macros works will have to be cleaned up. This probably means allowing the :use-macros and :require-macros options for the (ns ...) to load files with ".cljs" extension rather than ".clj". This will probably be a sufficient until more proper "feature expression" support is implemented. For example, the clj-defmacro (which is basically the defmacro the compile time analyzer uses) is something that will probably need this.
- There are some macros from core.clj that still need to be ported. But the way they interact with the existing functions in core.cljs will need to be worked out properly.
- Other things I haven't thought of or run into yet.
I have already made a fair amount of progress porting closure.clj and getting initial require/use support to work. I'm working through macro/namespace interaction and the :use-macros/:require-macros issues right now. The code is really to messy to commit yet.
This is getting much closer. The cljs-in-cljs Node.js based compiler can now compile most of itself with the exception of core.cljs.
Here is the process for compiling the noderepl with the compiled compiler (woah):
-
Compile the Node.js based compiler
cd node rm -rf out mkdir -p out cp ../src/cljs/goog.js out/ time ../bin/cljsc ../src/cljs/cljsc.cljs > out/cljsc.js -
Setup the new output directory with already compiled core.cljs:
rm -rf out2/ mkdir -p out2/cljs cp out/cljs/core.js out2/cljs # this is the cheat, everything will be compiled fresh cp ../src/cljs/goog.js out2 -
Use the compiled compiler (the Node.js one) to compile the REPL:
time ./run.js out/cljsc.js ../src/cljs/noderepl.cljs > out2/noderepl.js -
Run the new REPL:
./run2.js out2/noderepl.js
I tried copying the .clj files to .cljs, and the analyzer then got pretty far through core.cljs, but got stuck on various instances of loop...recur (Assert failed: Can't recur here). So far I couldn't figure out what was going wrong. Is there any uncommitted work on this issue, before I try harder?
@arthuredelstein You've gotten to the same point as me. I haven't had any cycles to dedicate to this in the past couple of months because my company was acquired and things are little busy for me. If you would like to tackle it, that would be great!