Skip to content

feat: inline const for leaf modules #10451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

feat: inline const for leaf modules #10451

wants to merge 10 commits into from

Conversation

ahabhgk
Copy link
Contributor

@ahabhgk ahabhgk commented May 22, 2025

Summary

Pre-PR for enum inlining

ref: evanw/esbuild@7bf3046

This PR only handle the cross-module part of const inlining, the idea is very similar to mangle exports:

  1. Add inlinable on export_info, which is similar to can_mangle, and add UsedName::Inlined for inlined value and UsedName::Normal for maybe mangled names
  2. Add inline_const parser plugin to find all the inlinable const variable, and "tag" it to tell the ESMExportSpecifierDependency that this exported value is inlinable

Inline const for the module that declared the const (in-module inlining) is not implemented yet, which need further discussion to decide:

  1. Leave it all to minimizer, keep the behavior simple
  2. Inline const for other top-level const declaration, which can help to find more inlinable const values, but may make the behavior more complex

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required update in future PR).

Copy link

netlify bot commented May 22, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 063b115
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/68356d6a02a5830008f46791

@github-actions github-actions bot added release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack. labels May 22, 2025
Copy link

codspeed-hq bot commented May 22, 2025

CodSpeed Performance Report

Merging #10451 will degrade performances by 13.54%

Comparing const-inlining (063b115) with main (1c2d7ab)

🎉 Hooray! codspeed-node just leveled up to 4.0.1!

A heads-up, this is a breaking change and it might affect your current performance baseline a bit. But here's the exciting part - it's packed with new, cool features and promises improved result stability 🥳!
Curious about what's new? Visit our releases page to delve into all the awesome details about this new version.

Summary

❌ 1 regressions
✅ 10 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
build_chunk_graph_parallel 70.7 ms 81.7 ms -13.54%

@ahabhgk ahabhgk marked this pull request as ready for review May 27, 2025 07:48
@ahabhgk ahabhgk changed the title feat: inline "const" values that come first feat: inline const in leaf module May 27, 2025
@ahabhgk ahabhgk changed the title feat: inline const in leaf module feat: inline const for leaf modules May 27, 2025
@ahabhgk ahabhgk requested a review from JSerFeng May 27, 2025 08:21
@ahabhgk
Copy link
Contributor Author

ahabhgk commented May 27, 2025

CodSpeed regression is caused by extra get_used_name, will optimize the perf of get_used_name in future PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant