-
-
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.
fix(es/minifier): Don't invoke IIFE containing reserved words (#8939)
**Description:** `inline` and `seq inline` should apply this change too. **Related issue:** - Closes #8622
- Loading branch information
Showing
5 changed files
with
118 additions
and
60 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
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
15 changes: 15 additions & 0 deletions
15
crates/swc_ecma_minifier/tests/fixture/issues/8622/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,15 @@ | ||
export function foo(cond) { | ||
let reserved = 1; | ||
if (cond) { | ||
reserved = 2; | ||
} | ||
return [reserved, bar(cond)]; | ||
} | ||
|
||
function bar(cond) { | ||
let reserved = 1; | ||
if (cond) { | ||
reserved = 2; | ||
} | ||
return reserved; | ||
} |
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_minifier/tests/fixture/issues/8622/mangle.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,3 @@ | ||
{ | ||
"reserved": ["reserved"] | ||
} |
10 changes: 10 additions & 0 deletions
10
crates/swc_ecma_minifier/tests/fixture/issues/8622/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 @@ | ||
export function foo(e) { | ||
let reserved = 1; | ||
return e && (reserved = 2), [ | ||
reserved, | ||
function(e) { | ||
let reserved = 1; | ||
return e && (reserved = 2), reserved; | ||
}(e) | ||
]; | ||
} |