ClojureScript 1.11 :modules code splitting when moving from :target :node to :target :bundle
0 reputation · 25 Nov 2025, 14:10 UTC
We have a ClojureScript 1.11.x browser project that currently compiles with :target :node and uses :modules to split output into a main chunk plus a lazily loaded feature chunk. We are evaluating a move to :target :bundle so webpack 5 handles npm resolution and code splitting instead of Closure Compiler's module processing.
The uncertainty is how the existing :modules map translates. Under :target :node each module becomes a separate Closure-compiled file wired together with goog.provide/require, and chunk loading is driven by cljs.loader. Under :target :bundle the same keys appear to become webpack entry point names, with splitting delegated to webpack's splitChunks configuration, which we would have to write and tune ourselves.
We also rely on advanced compilation (:optimizations :advanced) and on externs inference for a few npm dependencies, and it is unclear how much of that behavior carries over once webpack sits between our code and Closure's dead-code elimination pass.
Do :modules entry keys map one-to-one onto webpack entry points, or does the configuration need restructuring? How should lazy chunk loading be triggered in application code after the switch, given cljs.loader targets Closure modules? Are there documented pitfalls for externs inference when webpack resolves npm packages before advanced compilation runs?