Repository navigation
feat: optimize getter for const export default - #14175
Conversation
|
@codex review |
There was a problem hiding this comment.
Pull request overview
This PR optimizes how rspack generates ESM export wiring for export default <expr> when the default export can be treated as a const value. It fits into the JS codegen path (rspack_plugin_javascript) and updates test fixtures/snapshots to reflect the more efficient runtime export definition.
Changes:
- Emit a value binding (data property) instead of a getter for non-circular
const-compatibleexport default <expr>codegen. - Add parsing/config case coverage for const default exports, including literal and identifier forms, plus a cyclic default-export case to ensure getters remain in cycles.
- Update HMR concat snapshots to match the new
__webpack_require__.d(..., getters, values)call shape for default exports.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
crates/rspack_plugin_javascript/src/dependency/esm/esm_export_expression_dependency.rs |
Switch default export binding from getter to value when supports_const and the module is confirmed non-circular. |
tests/rspack-test/configCases/parsing/export-const-value-binding/index.js |
Add assertions for default-export descriptors (value vs getter) and a cyclic default-export scenario. |
tests/rspack-test/configCases/parsing/export-const-value-binding/const-default-export.js |
New const-identifier default export fixture. |
tests/rspack-test/configCases/parsing/export-const-value-binding/literal-default-export.js |
New literal default export fixture. |
tests/rspack-test/configCases/parsing/export-const-value-binding/cycle-default-a.js |
New cyclic default export fixture (side A). |
tests/rspack-test/configCases/parsing/export-const-value-binding/cycle-default-b.js |
New cyclic default export fixture (side B). |
tests/rspack-test/hotCases/concat/reload-external/__snapshots__/web/1.snap.txt |
Snapshot updated to reflect value-binding export definition for default export in HMR update. |
tests/rspack-test/hotCases/concat/reload-external/__snapshots__/web/2.snap.txt |
Snapshot updated to reflect value-binding export definition for default export in HMR update. |
tests/rspack-test/hotCases/concat/reload-compat-flag/__snapshots__/web/1.snap.txt |
Snapshot updated to reflect value-binding export definition for default export in HMR update. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
📦 Binary Size-limit
🙈 Size remains the same at 61.81MB |
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 3 projects with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 react-10kPath:
📦 Download Diff Report: react-10k Bundle Diff 📁 react-1kPath:
📦 Download Diff Report: react-1k Bundle Diff 📁 react-5kPath:
📦 Download Diff Report: react-5k Bundle Diff Generated by Rsdoctor GitHub Action |
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Optimize generated getter for const export default
Related links
Checklist