Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/minifier): should not drop statements which has side-effects
- Loading branch information
Showing
7 changed files
with
80 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
crates/swc_ecma_minifier/tests/fixture/issues/6422/2/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"toplevel": true, | ||
"unused": true | ||
} |
10 changes: 10 additions & 0 deletions
10
crates/swc_ecma_minifier/tests/fixture/issues/6422/2/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import assert from 'assert' | ||
let result = 'FAIL'; | ||
const unused = { | ||
...{ | ||
get prop() { | ||
result = 'PASS'; | ||
} | ||
} | ||
}; | ||
assert.strictEqual(result, 'PASS'); |
10 changes: 10 additions & 0 deletions
10
crates/swc_ecma_minifier/tests/fixture/issues/6422/2/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import assert from 'assert'; | ||
let result = 'FAIL'; | ||
({ | ||
...{ | ||
get prop () { | ||
result = 'PASS'; | ||
} | ||
} | ||
}); | ||
assert.strictEqual(result, 'PASS'); |
4 changes: 4 additions & 0 deletions
4
crates/swc_ecma_minifier/tests/fixture/issues/6422/3/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"toplevel": true, | ||
"unused": true | ||
} |
18 changes: 18 additions & 0 deletions
18
crates/swc_ecma_minifier/tests/fixture/issues/6422/3/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import assert from 'assert' | ||
let result = 0; | ||
const unused = { | ||
...{ | ||
get prop() { | ||
result = 1; | ||
} | ||
}, | ||
[assert.strictEqual(result, 1)]: null, | ||
[result = 2]: null, | ||
[assert.strictEqual(result, 2)]: null, | ||
...{ | ||
get prop() { | ||
result = 3; | ||
} | ||
} | ||
}; | ||
assert.strictEqual(result, 3); |
18 changes: 18 additions & 0 deletions
18
crates/swc_ecma_minifier/tests/fixture/issues/6422/3/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import assert from 'assert'; | ||
let result = 0; | ||
({ | ||
...{ | ||
get prop () { | ||
result = 1; | ||
} | ||
}, | ||
[assert.strictEqual(result, 1)]: null, | ||
[result = 2]: null, | ||
[assert.strictEqual(result, 2)]: null, | ||
...{ | ||
get prop () { | ||
result = 3; | ||
} | ||
} | ||
}); | ||
assert.strictEqual(result, 3); |