feat(loader): add in-memory loader chain cache - #15225
Draft
intellild wants to merge 14 commits into
Draft
Conversation
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.
Summary
Rule.use.cacheand group adjacent cached loaders into aCacheChainwhile retaining the nested JavaScript/native execution chains from refactor(loader): schedule loader chains as execution units聽#15219LoaderCacheregistry backed by a globalDashMap, with one sharedLoaderCacheinstance per cache directorynew_cache::MemoryCachestorage behindLoaderCache::get/store; loader execution no longer sees cache facades or item storage<context>/node_modules/.cache/lodaer-cacheas the hardcoded cache-directory identity; this version remains memory-only and does not write that directoryExample
For example, when an unrelated watched dependency triggers a rebuild but the input to this loader chain is unchanged, Rspack restores the cached chain result instead of running the loader again. Changing the resource content changes the input etag and executes the chain again. The loader cache is independent from the general compiler cache in this version.
For package loaders, the package name and version participate in the key. For non-package loaders, the resolved loader entry file is content-hashed. This first version intentionally does not include files imported or required by the loader in that file hash, and does not persist loader-chain entries.
Related links
Validation
cargo check -p rspack_loader_runner -p rspack_core -p rspack_binding_api -p rspack --all-targets --lockedcargo check -p rspack_core --lib --lockedcargo test -p rspack_loader_runner --locked(10 passed)cargo check -p rspack_benchmark --bench benches --lockedloaders/loader-chain-cachewatch and incremental-watch cases (8 passed) with the general compiler cache disabled, includingparallelcached loaders, dependency-triggered hits, source maps, additional data, and resource invalidationpackages/rspacklibrary buildChecklist
by OpenAI Codex