bhauman / lein-figwheel

Figwheel builds your ClojureScript code and hot loads it into the browser as you are coding!
Eclipse Public License 1.0
2.89k stars 210 forks source link

figwheel is not compatible with Nashorn - needs polyfills #31

Open pleasetrythisathome opened 10 years ago

pleasetrythisathome commented 10 years ago

I've been server rendering in Nashorn and i'd love to be able to use figwheel. Unfortunately js/console, js/document, js/location, js/window, etc are undefined in headless environments (like Nashorn). Could you add polyfill or conditionals? (something like this https://github.com/noprompt/shodan/blob/master/src/shodan/console.cljs#L30). Just need the thing not to break when evaluated.

bhauman commented 10 years ago

Can you just wrap the figwheel watch-and-reload call in a conditional? You don't want figwheel to run on the server side right?

pleasetrythisathome commented 10 years ago

it's the actual compiled file that it's issue, not the function call.

depending on optimizations, you either evaluate the single compiled js file, or evaluate each dependency in order from goog.deps to bootstrap the server environment, which means that any dependency included in a namespace form will be evaluated. none of the functions will be called, but the code is still evaluated.

bhauman commented 10 years ago

Gotcha, it's a pretty easy fix. I'll take a look.

bhauman commented 10 years ago

Can you send me a link or some resource to show me a minimal nashorn cljs setup?

pleasetrythisathome commented 10 years ago

https://github.com/pleasetrythisathome/om-server-rendering