-
-
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/resolver): Resolve top-level
undefined
, NaN
, and `Infinity…
…` correctly (#8471) **Description:** For following code ```js var NaN = 1 console.log(NaN) ``` Result would be |Envirnoment|Result| |-|-| |Non strict script(browser, nodejs repl)|NaN| |Non strict script(nodejs script)|1| |Strict script(browser, nodejs repl)|runtime error| |Strict script(nodejs script)|1| |ESM|1| So SWC choose to behave like browser in script mode and confirm to esm standard. **Related issue:** - Closes #8465
- Loading branch information
Showing
8 changed files
with
23 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,4 @@ | ||
function Infinity() { | ||
console.log("xxx"); | ||
} | ||
export default Infinity; |
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 @@ | ||
export default function() { | ||
console.log("xxx"); | ||
} |
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 |
---|---|---|
|
@@ -2,4 +2,4 @@ var NaN__2 = 1; | |
{ | ||
let NaN__3 = 1; | ||
console.log(NaN__3); | ||
}console.log(NaN); | ||
}console.log(NaN__2); |
2 changes: 1 addition & 1 deletion
2
crates/swc_ecma_transforms_base/tests/resolver/minifier/10/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,2 +1,2 @@ | ||
var NaN__2; | ||
console.log(NaN.toString()); | ||
console.log(NaN__2.toString()); |
2 changes: 1 addition & 1 deletion
2
crates/swc_ecma_transforms_base/tests/resolver/minifier/11/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,2 +1,2 @@ | ||
var NaN__2 = 5; | ||
console.log(NaN.toString()); | ||
console.log(NaN__2.toString()); |
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