Silent runtime failures after switching ClojureScript build to :advanced optimizations mid-migration
0 reputation · 06 Feb 2020, 14:28 UTC
0 reputation · 06 Feb 2020, 14:28 UTC
I am migrating a small ClojureScript frontend (a handful of namespaces, Reagent UI) from an older build setup to shadow-cljs, with the goal of zero downtime for users. The dev side is fine: the watch build with :none optimizations recompiles changed namespaces and the page updates without a restart.
The problem appears only after I produce a release build with :advanced optimizations. The minified bundle throws runtime errors when calling into third-party JavaScript libraries, and I understand this is the classic symptom of an incomplete externs file: property names get renamed by the Closure Compiler because they were not declared. The dev build never shows these errors, so they surface only late in the migration.
I can either keep the fast :none build with hot reloading during the migration window, or switch to :advanced early to catch externs gaps — but that slows iteration and I am unsure how to generate or validate externs for the libraries I use. I also have state in plain atoms outside component lifecycles that hot reloading will not preserve.
How can I detect missing externs before a full release build? Is there a practical way to run :advanced checks in CI without giving up the fast dev loop? And what is the recommended approach for preserving atom-based state across hot reloads during the cutover?
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.