shadow-cljs
shadow-cljs copied to clipboard
Deprecating :npm-module (maybe)
I'm planning to deprecate the :npm-module
build target since it is getting less and less reliable with each new Closure Compiler release and the world moving to more and more ESM (away from CommonJS, which this emits). So at one point in the not so far future it is likely to not work at all anymore.
I'm curious to hear what people are using this for currently? I'm not yet sure how a general purpose replacement would look like but I'm not sure that is needed in the first place. Maybe a few more dedicated output styles (eg. :webpack
) might be enough to cover all use cases.
Not anymore for me after I figured out the emitted code in CommonJS is too large. Running two compilers in watch mode is heavy cost of memory on my laptops.
We're currently using the :npm-module
target for a self-contained mini-app, that gets embedded in our main web app. The package exposes a react component which is instantiated by our main app.
We do use Webpack for the main app though, so I guess a specific target for that would be suitable for our current needs.
@thheller :npm-module
is the entire reason we use shadow-cljs
as our clojurescript
solution. We have a large react
/redux
code base that we're transitioning over to cljs
, and :npm-module
has allowed us to keep webpack
as our primary compiler while consuming our newer cljs
code. We would need some alternate way of building webpack
-consumable cljs
code if you removed :npm-modules
. Maybe there's already something, but we haven't figured it out yet.
@JeromeDane do you actually consume separate namespaces directly from the JS side or is there a singular entry point that "bridges" the JS<->CLJS worlds?
a)
// src/foo.js
const { thing } = require("./cljs/your.app.thing")
const { something } = require("./cljs/your.app.something")
b)
// src/foo.js
const { thing, something } = require("./cljs/your.app");
Do you have variant a) where your require multiple different CLJS namespaces directly in several JS files or is there just variant b) so only ever importing one singular CLJS namespace? Maybe in multiple files but always the same?
And I guess more importantly do you use the REPL or shadow-cljs hot-reload at all when running in through webpack?
@thheller we consume namespaces individually (option a
above).
Yes, we use the REPL a lot
We would like to use hot reloading through webpack, but our implementation is busted at the moment, even for the native webpack+react.
@thheller My organization uses npm modules as well. It's still the easiest way for us to write tests that work well for react/jest.
:npm-module
is going to stay as is. :esm
might be a better fit in many situations, but :npm-module
is still useful in places. Some of the quirks also have been addressed over time.