diff --git a/crates/swc_ecma_transforms_base/src/resolver/mod.rs b/crates/swc_ecma_transforms_base/src/resolver/mod.rs index 4342c7b83bfa..ac97304e335e 100644 --- a/crates/swc_ecma_transforms_base/src/resolver/mod.rs +++ b/crates/swc_ecma_transforms_base/src/resolver/mod.rs @@ -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), diff --git a/crates/swc_ecma_transforms_base/tests/resolver/global/globalThis/input.js b/crates/swc_ecma_transforms_base/tests/resolver/global/globalThis/input.js new file mode 100644 index 000000000000..0290601da4ce --- /dev/null +++ b/crates/swc_ecma_transforms_base/tests/resolver/global/globalThis/input.js @@ -0,0 +1,2 @@ +var globalThis = {}; +console.log(globalThis); diff --git a/crates/swc_ecma_transforms_base/tests/resolver/global/globalThis/output.js b/crates/swc_ecma_transforms_base/tests/resolver/global/globalThis/output.js new file mode 100644 index 000000000000..91adce272ad8 --- /dev/null +++ b/crates/swc_ecma_transforms_base/tests/resolver/global/globalThis/output.js @@ -0,0 +1,2 @@ +var globalThis__2 = {}; +console.log(globalThis__2);