Skip to content

feat: optimize getter for const export default - #14175

Merged
ahabhgk merged 1 commit into
mainfrom
getter-export-default
May 27, 2026
Merged

ahabhgk merged 1 commit into
mainfrom
getter-export-default

Conversation

@ahabhgk

@ahabhgk ahabhgk commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Optimize generated getter for const export default

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings May 27, 2026 07:27
@ahabhgk

ahabhgk commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-compatible export 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ 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".

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".

@ahabhgk
ahabhgk enabled auto-merge (squash) May 27, 2026 07:35
@github-actions

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 300387f to Revert "fix: require swc helpers 0.5.22" (#14171) by Fy

🙈 Size remains the same at 61.81MB

@github-actions

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 3 projects with changes.

📊 Quick Summary
Project Total Size Change
popular-libs 1.7 MB 0
react-10k 5.6 MB 📉 -71.2 KB (-1.2%)
react-1k 822.8 KB -3.5 KB (-0.4%)
react-5k 2.7 MB 📉 -30.8 KB (-1.1%)
ui-components 4.8 MB 0
📋 Detailed Reports (Click to expand)

📁 react-10k

Path: ../build-tools-performance/cases/react-10k/dist/rsdoctor-data.json

📌 Baseline Commit: ec6c723850 | PR: #14171

Metric Current Baseline Change
📊 Total Size 5.6 MB 5.7 MB -71.2 KB (-1.2%)
📄 JavaScript 5.6 MB 5.7 MB -71.2 KB (-1.2%)
🎨 CSS 21.0 B 21.0 B 0
🌐 HTML 328.0 B 328.0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: react-10k Bundle Diff

📁 react-1k

Path: ../build-tools-performance/cases/react-1k/dist/rsdoctor-data.json

📌 Baseline Commit: ec6c723850 | PR: #14171

Metric Current Baseline Change
📊 Total Size 822.8 KB 826.4 KB -3.5 KB (-0.4%)
📄 JavaScript 822.5 KB 826.0 KB -3.5 KB (-0.4%)
🎨 CSS 0 B 0 B 0
🌐 HTML 328.0 B 328.0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: react-1k Bundle Diff

📁 react-5k

Path: ../build-tools-performance/cases/react-5k/dist/rsdoctor-data.json

📌 Baseline Commit: ec6c723850 | PR: #14171

Metric Current Baseline Change
📊 Total Size 2.7 MB 2.7 MB -30.8 KB (-1.1%)
📄 JavaScript 2.7 MB 2.7 MB -30.8 KB (-1.1%)
🎨 CSS 21.0 B 21.0 B 0
🌐 HTML 328.0 B 328.0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: react-5k Bundle Diff

Generated by Rsdoctor GitHub Action

@codspeed

codspeed Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 37 untouched benchmarks
⏩ 25 skipped benchmarks1


Comparing getter-export-default (300387f) with main (ec6c723)

Open in CodSpeed

Footnotes

  1. 25 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@ahabhgk
ahabhgk merged commit 3ee41ef into main May 27, 2026
38 checks passed
@ahabhgk
ahabhgk deleted the getter-export-default branch May 27, 2026 08:06
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.

3 participants

⌂ 换网址