After struggling with the clojurescript webpack setup I decided, finally, to try shadow cljs.
Baseline in this case was a clojurescript project using webpack as per the guide.
The project included a deps.edn
file and package.json
defining node modues we required.
My minimal config file is below. Not complex but the doco fails the "quick start" test so it's possibly a handy reference for those who prefer to pattern match.
;; shadow-cljs configuration
{:deps true
:builds {:app {:target :browser
:modules {:main {:entries [metcalf3.core]}}
;; NOTE: these are specific to my use case
:output-dir "resources/public/js/dev"
:asset-path "/static/metcalf3/js/dev"
:devtools {:preloads [metcalf3.preload]}
}}}
Things to note
- We're deferring to
deps.edn
for dependencies - We're building for a browser environment
Shadow-cljs has a cli tool. To build I type shadow-cljs compile app
.
https://shadow-cljs.github.io/docs/UsersGuide.html#_command_line
The documentation gives you a handy table to help clarify the translation of JS require statements to CLJS :require statements.
https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages
My personal advice is to stick with syntax with matches up with the "official" clojurescript compilers require statements (e.g. :default is not backward compatible).