Fork me on GitHub
#shadow-cljs
<
2022-03-04
>
thheller05:03:35

@dpassen1 oops, forgot to publish. fixed.

thanks2 1
emilaasa13:03:50

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?

thheller13:03:18

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

thheller13:03:19

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

emilaasa13:03:57

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:

thheller13:03:50

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

thheller13:03:20

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

thheller13:03:34

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

thheller13:03:52

hard to say without knowing your JS setup

emilaasa13:03:01

Yep! It's semantically a structure like:

monorepo/
  backend1/
  backend2/
  common-stuff/
  ui/
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.

emilaasa13:03:45

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

emilaasa17:03:20

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