Commit 88c6ac7
fix(es/minifier): Remove unused arrow functions in dead code elimination (#11319)
## Description
This PR fixes issue #11303 where the minifier was preserving unused
arrow functions.
## Root Cause
The `ignore_return_value` method in the optimizer handled function
expressions (Expr::Fn) by returning None (indicating no side effects),
but did not handle arrow functions (Expr::Arrow) the same way. Arrow
functions would fall through to the default case and be preserved even
when unused.
## Changes
- Added handling for Expr::Arrow in ignore_return_value method
- Arrow functions are now treated as side-effect-free expressions
- Added test case for issue #11303
- Updated tinymce test expectation to reflect more aggressive
optimization
## Test Results
All 2790 tests pass.
Closes #11303
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>1 parent b0d3154 commit 88c6ac7
File tree
49 files changed
+83
-64
lines changed- .changeset
- crates
- swc_ecma_minifier
- src/compress/optimize
- tests/fixture
- issues/11303
- next/tinymce/1
- swc/tests/tsc-references
- packages
- core/scripts/npm
- darwin-arm64
- darwin-x64
- linux-arm-gnueabihf
- linux-arm64-gnu
- linux-arm64-musl
- linux-x64-gnu
- linux-x64-musl
- win32-arm64-msvc
- win32-ia32-msvc
- win32-x64-msvc
- html/scripts/npm
- darwin-arm64
- darwin-x64
- linux-arm-gnueabihf
- linux-arm64-gnu
- linux-arm64-musl
- linux-x64-gnu
- linux-x64-musl
- win32-arm64-msvc
- win32-ia32-msvc
- win32-x64-msvc
- minifier/scripts/npm
- darwin-arm64
- darwin-x64
- linux-arm-gnueabihf
- linux-arm64-gnu
- linux-arm64-musl
- linux-x64-gnu
- linux-x64-musl
- win32-arm64-msvc
- win32-ia32-msvc
- win32-x64-msvc
- react-compiler/scripts/npm
- darwin-arm64
- darwin-x64
- linux-arm-gnueabihf
- linux-arm64-gnu
- linux-arm64-musl
- linux-x64-gnu
- linux-x64-musl
- win32-arm64-msvc
- win32-ia32-msvc
- win32-x64-msvc
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
49 files changed
+83
-64
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
Lines changed: 2 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
| 3 | + | |
6 | 4 | | |
7 | | - | |
8 | | - | |
9 | | - | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
658 | 658 | | |
659 | 659 | | |
660 | 660 | | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
661 | 671 | | |
662 | 672 | | |
663 | 673 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 1 addition & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
0 commit comments