Fork me on GitHub
Pablo Fernandez07:08:53

henryzhu: but why is nodejs needed at all? wouldn’t phantomjs be enough? why do you need a server side javascript framework? I’d rather serve stuff with clojure than javascript.

Pablo Fernandez07:08:52

I have clojurescript project, starting from the reagent template ( I commented out all clojurescript code but in the compiled code I still get this line: if(typeof goog == "undefined") document.write('<script src="js/out/goog/base.js"></script>’); I’m trying to get rid of it to attempt running my cljs code in nashorn, which doesn’t implement document. Any ideas where that line is coming from?


@pupeno: use :compiler { :target :nodejs}

Pablo Fernandez08:08:33

darwin: nodejs doesn’t implement document and window?


no, it doesn't


even if it did, it has require, to include scripts, not a script tag

Pablo Fernandez08:08:39

Good to know. That further reduces my desire to use nodejs vs nashorn.

Pablo Fernandez08:08:12

Somehow, omelette avoids document without targeting nodejs (


hmm, I don’t have experience with nashorn, but I think that it has document and window


maybe you just have to bootstrap it somehow

Pablo Fernandez08:08:45

darwin: I now for a fact it doesn’t. Not sure if there’s a hack to add it, but I know other people had to work-around that.

Pablo Fernandez08:08:09

Now the files contain a few calls to goog, which is not defined 😕


I don’t understand how is omelette using nashorn, it is not obvious from the sources


I think the readme is wrong, omelette is using clojure on backend and clojurescript on frontend, no nashorn

Pablo Fernandez08:08:12

It’s definitely using nashorn and I run it in my machine and verified that javascript rendering is happening on the server.

Pablo Fernandez08:08:31

But I don’t understand why the generated javascript doesn’t call document and contains this:

Pablo Fernandez08:08:46

var CLOSURE_NO_DEPS = true; var COMPILED = false; var goog = goog || {}; = this;;


I think goog does not depend on js/document, so you can still include it in nashorn and then include your cljs sources


they compile their cljs without :main compiler option, so public/assets/scripts/main.js contains goog and compiled sources, there should be no document reference


what are your compiler options?

Pablo Fernandez08:08:59

darwin: I removed my :main attribute and that removed the call to document, but this also got rid of what was creating goog, so now I’m getting:

Pablo Fernandez08:08:01

javax.script.ScriptException: ReferenceError: "goog" is not defined in <eval> at line number 1, compiling:(handler.clj:16:3)


add :optimizations :whitespace


this will tell cljs compiler to create one file, now you are with :optimizations :none, so cljs compiler is creating a bunch of files, and including them with document.write(“<script…>”)


maybe you also need that :output-to and :output-dir


this will include goog into that one file

Pablo Fernandez08:08:53

ohhh… simple_smile I should have tried that. Thank you darwin.

Pablo Fernandez08:08:09

figwheel requires optimizations set to none 😞


ok, then set it to :none and write bootstrap script by hand, eval goog/base.js first and then deps.js and then your cljs sources


just look what gets generated by your :optimizations :none and rewrite the main script for nashorn