-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(es/minifier): Implement optional catch binding (#9657)
**Description:** I think removing `!v.declared_as_catch_param` is safe, since I can't think of a bad case: 1. for the vars in the params of catch-clause, we prevent the removal if `self.options.ecma < EsVersion::Es2019 || !self.options.unused` is not satisfied. 2. for the usages or re-declarations with the same var name in the body of catch-clause, I think it's safe to remove them. **Related issue:** - Closes #8966
- Loading branch information
Showing
7 changed files
with
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
swc_ecma_minifier: patch | ||
swc_core: patch | ||
--- | ||
|
||
feat(es/minifier): Implement optional catch binding |
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
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
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ function f1() { | |
return 1; | ||
} catch (ex) { | ||
return 2; | ||
} finally { | ||
} finally{ | ||
return 3; | ||
} | ||
} | ||
|
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 |
---|---|---|
|
@@ -2,9 +2,7 @@ var a = 1; | |
function f() { | ||
try { | ||
x(); | ||
} catch (a) { | ||
var a; | ||
} | ||
} catch (a) {} | ||
} | ||
f(); | ||
console.log(a); |
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 |
---|---|---|
|
@@ -2,8 +2,6 @@ var a = 1; | |
!function() { | ||
try { | ||
x(); | ||
} catch (a) { | ||
var a; | ||
} | ||
} catch (a) {} | ||
}(); | ||
console.log(a); |
2 changes: 1 addition & 1 deletion
2
crates/swc_ecma_minifier/tests/terser/compress/functions/issue_2604_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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
var a = "FAIL"; | ||
(function () { | ||
(function() { | ||
try { | ||
throw 1; | ||
} catch (o) { | ||
|