Skip to content

Commit

Permalink
chore: 🤖 allow more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IWANABETHATGUY committed May 9, 2024
1 parent f507780 commit 9145de6
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 27 deletions.
31 changes: 7 additions & 24 deletions crates/rolldown/src/stages/link_stage/tree_shaking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,14 @@ fn include_symbol(ctx: &mut Context, symbol_ref: SymbolRef) {
canonical_ref = namespace_alias.namespace_ref;
}
include_module(ctx, canonical_ref_module);

let need_merge_duplicate_function_decl = canonical_ref_module.stmt_infos.len() > 1;

let declared_stmts =
canonical_ref_module.stmt_infos.declared_stmts_by_symbol(&canonical_ref).to_vec();

// dbg!(&canonical_ref.symbol_id);
dbg!(&ctx.symbols.get_original_name(canonical_ref));
dbg!(&declared_stmts
canonical_ref_module
.stmt_infos
.declared_stmts_by_symbol(&canonical_ref)
.iter()
.map(|item| canonical_ref_module.stmt_infos[*item].clone())
.collect::<Vec<_>>());
dbg!(&declared_stmts);

if let Some(stmt_info_id) =
canonical_ref_module.stmt_infos.declared_stmts_by_symbol(&canonical_ref).last()
{
include_statement(ctx, canonical_ref_module, *stmt_info_id);
};
// .copied()
// .for_each(|stmt_info_id| {
// });
.copied()
.for_each(|stmt_info_id| {
include_statement(ctx, canonical_ref_module, stmt_info_id);
});
}

fn include_statement(ctx: &mut Context, module: &NormalModule, stmt_info_id: StmtInfoId) {
Expand Down Expand Up @@ -131,9 +117,6 @@ impl LinkStage<'_> {
module.is_included = is_module_included_vec[module.id];
is_included_vec[module.id].iter_enumerated().for_each(|(stmt_info_id, is_included)| {
module.stmt_infos.get_mut(stmt_info_id).is_included = *is_included;
if module.pretty_path != "<runtime>" {
// dbg!(&module.stmt_infos);
}
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"import": "entry.js"
}
]
}
}
},
"expectExecuted": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
}
]
},
"expect_executed": false
"expectExecuted": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ input_file: crates/rolldown/tests/esbuild/dce/multiple_declaration_tree_shaking

```js
// function2.js
function x() {
return 1;
}
console.log(x());
function x() {
return 2;
Expand All @@ -18,7 +21,13 @@ function x() {

```js
// function3.js
function x() {
return 1;
}
console.log(x());
function x() {
return 2;
}
console.log(x());
function x() {
return 3;
Expand All @@ -28,14 +37,17 @@ function x() {

```js
// var2.js
var x = 1;
console.log(x);
var x = 2;
```
## var3_js.mjs

```js
// var3.js
var x = 1;
console.log(x);
var x = 2;
console.log(x);
var x = 3;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
source: crates/rolldown/tests/common/case.rs
expression: content
input_file: crates/rolldown/tests/esbuild/dce/tree_shaking_no_bundle_cjs
---
# Assets

## entry_js.mjs

```js
// entry.js
function keep() {
}
keep();
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
source: crates/rolldown/tests/common/case.rs
expression: content
input_file: crates/rolldown/tests/esbuild/dce/tree_shaking_no_bundle_esm
---
# Assets

## entry_js.mjs

```js
// entry.js
function keep() {
}
keep();
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
source: crates/rolldown/tests/common/case.rs
expression: content
input_file: crates/rolldown/tests/esbuild/dce/tree_shaking_no_bundle_iife
---
# Assets

## entry_js.mjs

```js
// entry.js
function keep() {
}
keep();
```

0 comments on commit 9145de6

Please sign in to comment.