Fork me on GitHub
Michael Mossinsohn22:03:31

Where can I find info about setting up the React components that Reagent generates to be easily used from JS? My boss needs my code to enable JS programmers to pick up where I leave, in case I leave the project. I'm using Reagent (plus Reitit, and Shadow-cljs for development) to create a web-app.


It might be easier and more productive to teach them CLJS+Reagent. :D If you leave, will they keep building the project using shadow-cljs but with additional JS files within the project? Or will they switch to something else entirely while building CLJS in advance and using the result as a JS file?

Michael Mossinsohn23:03:34

Indeed, teaching them CLJS+Reagent is the way to go 🙂 But... my boss is worried because CLJS programmers are harder to come by then React programmers. My guess is they will use (if the need will arise) my js output 'as is', unless using Shadow-cljs is the superior way, in which case I can recommend it. Ideally, they would be able to both inerop with my code or even change my code. I was trying to output readable JS which others can edit and build upon but I was told the best I can do is output what is in essence a black-box library. Is this true? I'm afraid I misled my boss, stating that my code would be usable by JS programmers in case the need will arise. What is the best I can do to maximize the usability of my cod from JS?


Alas, they won't be able to use your JS output as is because it will incorporate every NPM library you're using, including React - so they will end up with two React instances on a single page, which simply doesn't work. I think there might be a way to build only CLJS code while leaving all JS dependencies effectively in the "provided" scope. But even if it's true, it will definitely require more work on your end. It might also be tool-dependent, so I won't be surprised if e.g. only shadow-cljs has it. I think the best approach here would be to make it incredibly clear how to do the opposite - write JS components and embed them in the CLJS code. It will still require some CLJS knowledge, but not a lot - especially if you provide some clear examples. Then the potential JS developers would write in JS 90% of the time and the rest would be spent on incorporating the components in the CLJS app.


This is a relevant shadow-cljs documentation section: But it's rather short and doesn't make it clear what happens when you use NPM libraries - whether they end up being compiled into the resulting bundle or not.


Oh, actually seems like it does not include the libraries, so that should be the way to go for you then!

Michael Mossinsohn15:03:04

Thank you very much! This info is very helpful for me.

👍 1