Undertanding chestnut

137 views
Skip to first unread message

Juan Manuel Gimeno Illa

unread,
Dec 8, 2014, 3:23:37 AM12/8/14
to clojur...@googlegroups.com
I'm working on a project created using the chestnut template and there are some things that I do not understand about some elements of this temnplate.

In project.clj we have:

:cljsbuild {:builds {:app {:source-paths ["src/cljs"]
:compiler {:output-to "resources/public/js/app.js"
:output-dir "resources/public/js/out"
:source-map "resources/public/js/out.js.map"
:preamble ["react/react.min.js"]
:externs ["react/externs/react.js"]
:optimizations :none
:pretty-print true}}}}

so the minified version is preappended to the javascript generated in app.js.

But in the routes in the server I find:

(resources "/react" {:root "react"})

as if the server should serve a resource for react (and I cannot find anything in a supposed directoru resources/react).

CAn anyone explain what this route is all about?

Thanks,

Juan Manuel

Martin Klepsch

unread,
Dec 8, 2014, 8:37:55 AM12/8/14
to clojur...@googlegroups.com
Hey Juan,

when compiling Clojurescript with optimisations :none the generated Javascript isn't piped through Google Closure. The :preamble option only works in combination with Google Closure. Therefore you need to manually supply React to the page that uses it.

There is a bit of code that adds this script tag to your site in development mode:
https://github.com/plexus/chestnut/blob/master/src/leiningen/new/chestnut/env/dev/clj/chestnut/dev.clj#L10-L15

Hope this helps,
Martin

Juan Manuel Gimeno Illa

unread,
Dec 8, 2014, 11:40:09 AM12/8/14
to clojur...@googlegroups.com
Yes, that is on the clien'ts side, but the question is: where the server gets react.js code from? Because the route

(resources "/react" {:root "react"})

afaik resolves to subdirectory react from resources which do not exist in the project's directory.

Juan Manuel

Martin Klepsch

unread,
Dec 8, 2014, 11:59:23 AM12/8/14
to clojur...@googlegroups.com
Ah! Om depends on react-cljs, which adds the "react" directory to the classpath

--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/P0C6kE0ndJo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Juan Manuel Gimeno Illa

unread,
Dec 8, 2014, 12:31:52 PM12/8/14
to clojur...@googlegroups.com
I misenterpreted the resources route. I thought it used only the resources directory and not the whole classpath. Now it all makes sense.

Thanks !!

Juan Manuel
Reply all
Reply to author
Forward
0 new messages