Skip to content

Save declaredModuleSize in the persistent scan cache - #21

Merged
h-a-n-a merged 1 commit into
mainfrom
save-declared-module-size
Nov 24, 2026
Merged

h-a-n-a merged 1 commit into
mainfrom
save-declared-module-size

Conversation

@h-a-n-a

@h-a-n-a h-a-n-a commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Rolldown now has declaredModuleSize (rolldown/rolldown#11844). A load or transform hook can return it to declare the size of a module. Size-based code splitting uses this value instead of the size of the module's code.

This PR adds it to the "State after transform" table in 0002 What a saved result holds.

The section's rule already covers it: a value from a skipped hook is saved when a later stage reads it. Code splitting reads declaredModuleSize, so a saved result must hold it. Without it, a cache hit gives a different output:

transform(code, id) {
  if (id.endsWith('b.js')) return { code, declaredModuleSize: 1001 };
}
// output.codeSplitting.groups: [{ name: 'small', test: /b\.js$/, maxModuleSize: 1000 }]
// Without the cache: no "small" chunk, because 1001 > 1000.
// Cache hit without the saved value: Rolldown measures the code of b.js, so a "small" chunk appears.

The implementation is in rolldown/rolldown#11671: SavedResult::declared_module_size in crates/rolldown/src/persistent_cache/saved_result.rs.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T08:31:56.706112Z de4819c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@h-a-n-a
h-a-n-a merged commit 858612b into main Nov 24, 2026
2 checks passed
@h-a-n-a
h-a-n-a deleted the save-declared-module-size branch November 24, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant