Fork me on GitHub

@dpassen1 oops, forgot to publish. fixed.

thanks2 1

This is a sort-of newbie question, forgive me if it's obvious. I have an existing javascript project using webpack, and I've managed to add some cljs code to the project using a simple config like this from the README:

{:source-paths ["src/cljs"]
 :builds {:code
          {:target :npm-module
           :output-dir "node_modules/shadow-cljs"
           :entries [foo]}}}
Seems to work great, I can use it from the js code and it works. Yay!! I'd now like to make it run seamlessly for everyone using the project (they only use JS). For me, seamlessly would imply no one else has to run anything else than npm ci , npm test and npm start The two options I'm looking at are: • a separate project that would produce a separate npm module and importing that • hacking it into some sort of public/js build folder and checking in the compiled js files Is there a recommended way to do this?


a npm module seems best? assuming the JS people are always going to run webpack anyways?


also depends if you are accessing some of the JS code from CLJS


Yeah I'm leaning towards that. A main purpose of having cljs at all is to share some functions between the frontend and backend (and getting to implement them in Clojure!). I wonder if I could somehow add this to our build from the backend modules and just output an npm module? :thinking_face:


I assume you are now using require("shadow-cljs/some.ns") from the JS


you can just output to node_modules/whatever instead of use whatever/some.ns


or you can output to a different dir and use webpack config resolve alias


hard to say without knowing your JS setup


Yep! It's semantically a structure like:

ui is a webpack project, and common-stuff is a clojure project used by both backends. The idea would be to have parts of that be also accessible to the ui project.


Some people mostly work within the ui project and those are the users I'd like to spare knowing about clj at all.


Seems like it wasn't that hard to publish an internal npm package to github and making it available thru that either.