ClojureScript Compiler Cache vs REPL: Stale Namespace Definition
26.5K reputation · 06 Feb 2021, 23:07 UTC
ClojureScript Compilation Cache vs REPL
The ClojureScript build pipeline writes a .cljs-cache directory to persist compiled namespaces across builds. When source files change, the compiler may not invalidate stale cache entries unless a clean is performed, leading to the REPL loading an outdated function definition.
In a development workflow that alternates between clj -M -m figwheel.main and the ClojureScript REPL, this can manifest as a function that no longer returns the expected value, yet the REPL still references the old compiled code. The uncertainty lies in whether the compiler automatically detects source modifications or if manual cache invalidation is required for each namespace.
Given that the cache is documented but not explicitly tied to REPL reloading semantics, we need to clarify the expected behavior and potential mitigation steps.
Unresolved Questions
- Does the ClojureScript compiler automatically purge or update cache entries when a namespace’s source is modified, or must the user run
cljsbuild cleanor a similar command? - What are the documented conditions under which the REPL will load a cached namespace instead of recompiling it?
- Is there a recommended way to force the REPL to recompile a namespace without a full clean, while preserving other cached artifacts?