-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dce): bail on non-constant replacement path (#755)
* fix(dce): bail on non-constant replacement path In one use variable replacement, if the right hand side contains constant violations, the left-hand side is supposed to be preserved, so we detect this and bail out for this case + Fix #685 * Fix binding check and checks for not Identifier * Add testcase for non-identifier replacementPaths
- Loading branch information
Showing
3 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
packages/babel-plugin-minify-dead-code-elimination/__tests__/fixtures/issue-685/actual.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,16 @@ | ||
function loop() { | ||
var end = 0; | ||
var start = end; | ||
while (end < 10) { | ||
console.log(start, end); | ||
var end = end + 1; | ||
} | ||
} | ||
loop(); | ||
|
||
function bar() { | ||
var x = 1; | ||
var y = x + 2; | ||
var x = 3; | ||
return x + y; | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/babel-plugin-minify-dead-code-elimination/__tests__/fixtures/issue-685/expected.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,16 @@ | ||
function loop() { | ||
var end = 0; | ||
var start = end; | ||
while (end < 10) { | ||
console.log(start, end); | ||
var end = end + 1; | ||
} | ||
} | ||
loop(); | ||
|
||
function bar() { | ||
var x = 1; | ||
var y = x + 2; | ||
var x = 3; | ||
return x + y; | ||
} |
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