Skip to content

Commit

Permalink
fix(es/renamer): Allow globalThis to be shadowed (#8327)
Browse files Browse the repository at this point in the history
**Related issue:**

 - Closes #8317
  • Loading branch information
Austaras authored Nov 23, 2023
1 parent 5ce4b36 commit 3dd73a3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 3 additions & 4 deletions crates/swc_ecma_transforms_base/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,9 @@ impl<'a> Resolver<'a> {
}

return match &**sym {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects#value_properties
"undefined" | "NaN" | "Infinity" | "globalThis"
if mark == self.config.top_level_mark =>
{
// https://tc39.es/ecma262/multipage/global-object.html#sec-value-properties-of-the-global-object-infinity
// non configurable global value
"undefined" | "NaN" | "Infinity" if mark == self.config.top_level_mark => {
Some(self.config.unresolved_mark)
}
_ => Some(mark),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var globalThis = {};
console.log(globalThis);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var globalThis__2 = {};
console.log(globalThis__2);

0 comments on commit 3dd73a3

Please sign in to comment.