fix: tree shaking multi decl
Description
for case:
// index.js
import {a,} from './share'
console.log(a)
// share.js
export const a = 1000, b = 1000;
Before
// share.js
const a = 100, b = 1000;
// main1.js
console.log(a);
After
// share.js
const a = 100;
// main1.js
console.log(a);
Deploy Preview for rolldown-rs canceled.
| Name | Link |
|---|---|
| Latest commit | 57f3c764cf562bf723aa1f1c0ec87f2ce27475bc |
| Latest deploy log | https://app.netlify.com/sites/rolldown-rs/deploys/66479b79b5d8bd0008df403b |
Deploy Preview for rolldown-rs canceled.
| Name | Link |
|---|---|
| Latest commit | 3529eb12cebe50df7134414c869eb87aba4e479c |
| Latest deploy log | https://app.netlify.com/sites/rolldown-rs/deploys/6649d143d22d550008293773 |
Codecov Report
Attention: Patch coverage is 89.47368% with 8 lines in your changes are missing coverage. Please review.
Project coverage is 87.03%. Comparing base (
97d50b5) to head (3529eb1). Report is 1 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #1150 +/- ##
==========================================
- Coverage 87.04% 87.03% -0.02%
==========================================
Files 122 122
Lines 6007 6053 +46
==========================================
+ Hits 5229 5268 +39
- Misses 778 785 +7
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Benchmarks Rust
- target:
main(73ae76c6171fbe514e605ce20fd07fe28ed76501) - pr:
fix/tree-shaking-multi-decl(3529eb12cebe50df7134414c869eb87aba4e479c)
group pr target
----- -- ------
rolldown benchmark/threejs-bundle 1.00 31.1±0.40ms ? ?/sec 1.00 31.2±0.37ms ? ?/sec
rolldown benchmark/threejs-scan 1.01 21.8±0.55ms ? ?/sec 1.00 21.5±0.17ms ? ?/sec
rolldown benchmark/threejs-sourcemap 1.00 43.1±0.77ms ? ?/sec 1.02 43.8±0.99ms ? ?/sec
rolldown benchmark/threejs10x-bundle 1.02 328.2±2.96ms ? ?/sec 1.00 322.9±2.85ms ? ?/sec
rolldown benchmark/threejs10x-scan 1.01 211.3±3.65ms ? ?/sec 1.00 210.0±1.86ms ? ?/sec
rolldown benchmark/threejs10x-sourcemap 1.01 467.2±11.16ms ? ?/sec 1.00 463.1±7.90ms ? ?/sec
CodSpeed Performance Report
Merging #1150 will not alter performance
Comparing fix/tree-shaking-multi-decl (3529eb1) with main (73ae76c)
Summary
✅ 6 untouched benchmarks
It's suggested that:
- You could place the transform logic on multiple declarations in https://github.com/rolldown/rolldown/blob/4dc323cf46681d57d56592ee0b7ebdefdaa96268/crates/rolldown/src/utils/tweak_ast_for_scanning.rs
- Create a
VariableDeclarationExttrait in https://github.com/rolldown/rolldown/blob/4dc323cf46681d57d56592ee0b7ebdefdaa96268/crates/rolldown_oxc_utils/src/ext/mod.rs - Create a method
fn unfold_declarators(&mut self, alloc: &Allocator) -> Vec<VariableDeclaration>onVariableDeclarationExt. Feel free to choose a more suitable function name or signature.
This PR is blocked by the source map modification revert,
closed in favor of #1564