Early stage live coding ClojureScript with Webpack

2Comments

Write your comment…

I won't argue about shadow-cljs, although it's self description doesn't say much about what it does (provide some good defaults). I assume your goal is to use CLJS library in an application bundled for the browser using Webpack. CLJS compiler has an option to emit node.js compatible code using :target :nodejs option. You would presumably use this to bundle up your CLJS project as CommonJS module. With this, you can annotate your public functions like so (defn ^:export do-somthing [a b] (...)) you could then use them in your JS code as myns.foo.do-somthing(a, b) after require() or import your module. So that's how you would use your module in production build. If you want live coding, I think figwheel is amazing in what it can do, far more than Webpack's HMR (eg. CIDER, Fireplace, ...). If you want to use live-code your CLJS library in your Webpack JS application, you can comment out the require() or import in your JS client code, and include Figwheel enabled JS file in an extra <script> tag. Hence you won't use Webpack's HMR for CLJS code, you will get faster reloads, and you will be able to eval code from your editor, in your running Webpack app in the browser, and you won't need additional dependency on shadow-cljs

Yes you can always get better experience with Figwheel or boot-reload, and shadow-cljs itself provides better tooling too. The reason I use Webpack is I was from JavaScript side and have features and toolchains I liked in Webpack.

Need to mention that, by using Webpack, we no longer have correct SourceMaps, cljs REPL, head-up compilation error messages. It's an insufficient solution to senior cljs developers.

Write a reply...

Just wanted to say that I think this is a good idea and would def use a mature and stable version of it. :)

Write a reply...

Join a friendly and inclusive Q&A network for coders

  • 🖥Pick the technologies you like & read great content through your feed.
  • 💬Ask a question when you want to learn more about anything.
  • 🚀Share what you know & build your portfolio.
Sign up nowLearn more

loading ...