rolldown icon indicating copy to clipboard operation
rolldown copied to clipboard

fix: tree shaking multi decl

Open IWANABETHATGUY opened this issue 1 year ago • 5 comments

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);

IWANABETHATGUY avatar May 17 '24 18:05 IWANABETHATGUY

Deploy Preview for rolldown-rs canceled.

Name Link
Latest commit 57f3c764cf562bf723aa1f1c0ec87f2ce27475bc
Latest deploy log https://app.netlify.com/sites/rolldown-rs/deploys/66479b79b5d8bd0008df403b

netlify[bot] avatar May 17 '24 18:05 netlify[bot]

Deploy Preview for rolldown-rs canceled.

Name Link
Latest commit 3529eb12cebe50df7134414c869eb87aba4e479c
Latest deploy log https://app.netlify.com/sites/rolldown-rs/deploys/6649d143d22d550008293773

netlify[bot] avatar May 17 '24 18:05 netlify[bot]

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.

Files Patch % Lines
...down/src/finalizer/impl_visit_mut_for_finalizer.rs 76.19% 5 Missing :warning:
crates/rolldown_common/src/types/stmt_info.rs 85.71% 2 Missing :warning:
...tes/rolldown/src/stages/link_stage/tree_shaking.rs 96.96% 1 Missing :warning:
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.

codecov[bot] avatar May 17 '24 18:05 codecov[bot]

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

github-actions[bot] avatar May 19 '24 10:05 github-actions[bot]

CodSpeed Performance Report

Merging #1150 will not alter performance

Comparing fix/tree-shaking-multi-decl (3529eb1) with main (73ae76c)

Summary

✅ 6 untouched benchmarks

codspeed-hq[bot] avatar May 19 '24 10:05 codspeed-hq[bot]

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 VariableDeclarationExt trait 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> on VariableDeclarationExt. Feel free to choose a more suitable function name or signature.

hyf0 avatar May 25 '24 20:05 hyf0

This PR is blocked by the source map modification revert,

IWANABETHATGUY avatar May 26 '24 03:05 IWANABETHATGUY

closed in favor of #1564

IWANABETHATGUY avatar Jul 10 '24 02:07 IWANABETHATGUY