From 8bc17fe6598bb9e557986030a1feae290b8a968d Mon Sep 17 00:00:00 2001 From: Jack Works Date: Wed, 3 Jul 2019 02:35:27 +0800 Subject: [PATCH] Add support for globalThis when detecting global object (#4347) --- .internal/root.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.internal/root.js b/.internal/root.js index 8a4324d20..c7723bb0f 100644 --- a/.internal/root.js +++ b/.internal/root.js @@ -1,9 +1,12 @@ import freeGlobal from './freeGlobal.js' +/** Detect free variable `globalThis` */ +const freeGlobalThis = typeof globalThis == 'object' && globalThis !== null && globalThis.Object == Object && globalThis + /** Detect free variable `self`. */ const freeSelf = typeof self == 'object' && self !== null && self.Object === Object && self /** Used as a reference to the global object. */ -const root = freeGlobal || freeSelf || Function('return this')() +const root = freeGlobalThis || freeGlobal || freeSelf || Function('return this')() export default root