Repository navigation
Builds read cljs.core's analysis cache for the copy they compile: restored output keeps its Closure Library modules - #22
Merged
Conversation
… compile, not the jar's entry: a cold build with the output restored from the per-user cache keeps the Closure Library modules only cljs.core imports cljf.esm/compile-ns loaded cljs.core's analysis through with-core-cljs when its output was up to date: an analysis of the classpath's cljs/core.cljs, a jar's entry in a project depending on the compiler's artifact, modified at another time than the analysis cache written for the copy in the output directory. So the source was analyzed again on every build and the cache rewritten without :cljf.esm/goog-libs, which only compiling records. A cold build with the output restored from the per-user cache (0.12.12) then wrote no goog-lib/ns/goog.math.Integer.js and goog.Uri.js, and the output failed to load with ERR_MODULE_NOT_FOUND. cljs.core's analysis is read from source-file's cache like every other namespace's: the restore sets the cache's modification time to the copy's, as a compile does. Up to date builds skip the analysis of cljs.core's source as well. The test serves cljs/core.cljs from a jar on a child-first context class loader and builds twice with a per-user cache of its own (cljf.main/cache-dir redefined), the output deleted in between. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Member
|
thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
In a project depending on the compiler's artifact (
cljf0.12.12 and 0.12.13 from npm), a cold build whosecljs.coreoutput comes from the per-user cache (cljs-core/, since 0.12.12) writes nogoog-lib/ns/goog.math.Integer.jsand nogoog.Uri.js, the two Closure Library modules onlycljs.coreimports. The output then fails to load:Seen on every build after
rm -rf targetin a checkout that had built once before (the first build of a fresh checkout has no cache entry yet and compilescljs.core, so it works; an incremental build keeps the modules of the build before).CLJF_CACHE_DIR=$(mktemp -d)or:core-cache falseworks around it.The cause
cljf.esm/compile-nsloadedcljs.core's analysis throughwith-core-cljswhen its output was up to date. That analyzes the classpath'scljs/core.cljs, the jar's entry, whose modification time differs from the analysis cache written for the copy in the output directory (by the compile of the output, or byrestore-core!).requires-analysis?compares the two times, so the cache was judged stale and the source analyzed again, on every build, and the cache rewritten without:cljf.esm/goog-libs, which only compiling records (esm-goog-lib!).install-goog-libsthen hadcljs.core's modules only when something else used them too (goog.math.Longthrough transit,goog.string.StringBuffer).In this repository's own tests
cljs/core.cljsis a plain file, so the times matched and nothing showed.The change
compile-nsreadscljs.core's analysis fromsource-file's cache like every other namespace's (ana/analyze-file source-file), nowith-core-cljs: the copy's time is the cache's. An up to date build no longer analyzescljs.core's source either.esm_build_tests/restores-core-with-its-closure-libraries:cljs/core.cljsserved from a jar through a child-first context class loader (it hides the parent's copy fromcheck-classpath!too),cljf.main/cache-dirredefined to a directory of its own, two builds with the output deleted in between. Without the fix only its last assertions fail (the restored build lacksgoog.math.Integer.js); with it the suite passes.[Next]changelog entry under Fixed.Checked
script/test-esm: the build and REPL tests (40 tests, 219 assertions) and the runtime suite under Node 26 (670 tests, 21020 assertions), 0 failures, 0 errors.The branch is on the
storritofork, as #7 was.🤖 Generated with Claude Code