The long answer is unfortunately a year long or so. Don’t really have any pointers to give. I wrote about a bunch of stuff on my blog but thats mostly about shadow-cljs and why it does the stuff it does.
Overall I have no clue anymore what CLJS does with
I did however port your example to
shadow-cljs since I know exactly what that does.
To compare you can look at the build-reports
In short these are 3 separate builds. One using your minimal no-deps entry and 2 using js-joda. One variant just includes the “regular” npm package (similar to what you’d get from cljsjs) and one actually trying to run everything through
:advanced compilation. As you can see it does make a difference but not as much as you’d probably expect.
Note that I didn’t actually try running the compiled code at all. So no clue if it even survived the
:advanced compilation (most packages nowadays don’t).
Overall the Closure Compiler is fully capable of running strict ESM code through
:advanced compilation with full DCE. However the
js-joda.dist.esm.js is not strict ESM code. It is some kind of processed “mess” that basically just has
export added at the end to “pretend to be ESM”. All “modern” language features (eg.
class) were rewritten by babel. Those produce problems for the Closure Compiler and hinder DCE.