This thing I wrote is getting to a point where it might be useful to someone 
else. It might make your CLJS life a bit easier.

I have been using my own CLJS tooling (shadow-build) for over 3 years now, it 
had some of lein-figwheel's features that I never talked about but frankly 
lein-figwheel was just plain easier to use so I never bothered.

Over the years however I noticed a trend in my projects that bothered me. I 
would repeat all my build configuration at least twice and only change one tiny 
thing. I would have a :dev build with :optimizations :none and a :min build 
with :advanced. Some other things might change as well but the bulk of the 
configuration stayed the same.

So the goal was simple, abstract the configuration stuff to the basics. You 
define the :target and compile this either in :dev or :release mode. The 
:target defines where your build is supposed to run (ie. browser, node-library 
or node-script). :dev then provides some good defaults for development (with 
REPL, live-reloading, source-maps, ...) and :release takes care of everything 
to produce the most optimized build.

The main goal of this was to automate as much as possible and no changes to 
code should be required when switching between :dev and :release.

Say you want to create a node script, something that runs as a standalone node 
process.

{:id :script
 :target :node-script
 :main demo.script/main
 :output-to "out/demo-script/script.js"}

This creates only the file defined in :output-to. You run that file by calling 
"node script.js arg". It will call "(demo.script/main "arg") on startup which 
is a normal `(defn main [& args] ...)` in `(ns demo.script)`. No need to do the 
usual `(set! *main-cli-fn* ...)` or anything else really.

To compile the script in :dev mode you run:
lein run -m shadow.cljs.devtools.cli/once script

To compile the script in :release mode:
lein run -m shadow.cljs.devtools.cli/release script

Or if you want the full blown dev experience:
rlwrap lein run -m shadow.cljs.devtools.cli/release script

This drops you into a REPL that you can use to interact with the running 
process once you start the node process.


If you just want to integrate with some existing node stuff as a library you 
can use this config:

{:id :library
 :target :node-library
 :output-to "out/demo-library/lib.js"
 :exports
 {:hello demo.lib/hello}}

The :exports map specifies which vars should be exported to node.

> var x = require('./lib');
undefined
> x.hello()
hello
'hello'


The caveat of all this is that these default :target configurations (didn't 
mention :browser yet) are based on what I consider "good" setups. That might be 
totally different from what everyone else is doing. There are also some other 
differences to other build tools like figwheel or lein-cljsbuild, which may be 
confusing at first.

So should anyone be interested in this at all I'd be happy about any kind of 
feedback.

You can find some more information here:
https://github.com/thheller/shadow-devtools

I would consider this ALPHA level but I have been using shadow-build for a 
really long time and some of the devtools things for just as long. I just 
re-wrote some parts recently to simplify the configuration bits. It is nowhere 
near the polish of lein-figwheel but it is probably faster and simpler to 
configure. ;)

Cheers,
/thomas

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at https://groups.google.com/group/clojurescript.

Reply via email to