feat(codegen): add --cache option to skip emitting unchanged files#418
Draft
mizdra wants to merge 2 commits into
Draft
feat(codegen): add --cache option to skip emitting unchanged files#418mizdra wants to merge 2 commits into
mizdra wants to merge 2 commits into
Conversation
Skips generateDts + writeDtsFile for files whose content hash matches the previous run. parse and check still run every time, so diagnostics remain accurate even when dependencies change. Cache is stored at <dtsOutDir>/.cache as JSON containing the codegen version, a hash of the full CMKConfig, and per-file content hashes. The cache is invalidated entirely when the version or config hash differs from the stored value. --clean discards the cache automatically since it removes dtsOutDir. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 0285cab The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
3d4655d to
0285cab
Compare
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
--cacheflag tocmk. When enabled, files whose content has not changed since the last run skip the emit phase (generateDts+writeDtsFile).<dtsOutDir>/.cache. Running--cleanautomatically discards it since the entire output directory is removed.How it works
On each run with
--cache:<dtsOutDir>/.cache(JSON). If the codegen version or the config hash differs from what is stored, discard the cache entirely.The cache file format:
{ "version": "<codegen version>", "configHash": "<SHA-256 of JSON.stringify(CMKConfig)>", "files": { "src/a.module.css": "<SHA-256 of file content>", ... } }Performance
Measured with hyperfine on a synthetic project (30 selectors and 1
@importper file). Times include Node.js startup (~200 ms).--cache, no existing cache) adds a small overhead for hashing every file and writing the cache, growing with file count (+2% at 100 files, +16% at 10000).Benchmark code
setup.mjs — generates a synthetic project with N files
bench.sh — runs hyperfine for each scenario
Test plan
vp test packages/codegenand confirm all tests pass.