This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-19
Channels
- # admin-announcements (14)
- # architecture (1)
- # beginners (21)
- # boot (301)
- # clojure (93)
- # clojure-brasil (56)
- # clojure-india (4)
- # clojure-italy (11)
- # clojure-japan (25)
- # clojure-russia (16)
- # clojure-sg (1)
- # clojure-uk (5)
- # clojurescript (64)
- # clojurex (4)
- # clojutre (7)
- # cursive (18)
- # datascript (35)
- # datomic (212)
- # editors (27)
- # emacs (38)
- # events (9)
- # funcool (21)
- # hoplon (105)
- # jobs (2)
- # ldnclj (41)
- # ldnproclodo (4)
- # liberator (89)
- # luminus (5)
- # off-topic (32)
- # om (39)
- # onyx (1)
- # re-frame (9)
- # reactive (1)
- # reagent (34)
- # testing (42)
- # yada (4)
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.
I have clojurescript project, starting from the reagent template (https://github.com/pupeno/proclodo-spa-server-rendering). 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?
darwin: nodejs doesn’t implement document and window?
Good to know. That further reduces my desire to use nodejs vs nashorn.
Somehow, omelette avoids document without targeting nodejs (https://github.com/DomKM/omelette)
hmm, I don’t have experience with nashorn, but I think that it has document and window
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.
Now the files contain a few calls to goog, which is not defined 😕
I think the readme is wrong, omelette is using clojure on backend and clojurescript on frontend, no nashorn
darwin: https://github.com/DomKM/omelette/blob/master/src/omelette/render.clj#L9
It’s definitely using nashorn and I run it in my machine and verified that javascript rendering is happening on the server.
But I don’t understand why the generated javascript doesn’t call document and contains this:
var CLOSURE_NO_DEPS = true; var COMPILED = false; var goog = goog || {}; goog.global = this; goog.global.CLOSURE_DEFINES;
I think goog does not depend on js/document, so you can still include it in nashorn and then include your cljs sources
for react, this comment says it: https://github.com/DomKM/omelette/blob/master/src/omelette/render.clj#L10-L11
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
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:
javax.script.ScriptException: ReferenceError: "goog" is not defined in <eval> at line number 1, compiling:(handler.clj:16:3)
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…>”)
ohhh… I should have tried that. Thank you darwin.
figwheel requires optimizations set to none 😞