We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a3f792d + 3738052 commit 37bc524Copy full SHA for 37bc524
src/helpers/createRefreshTemplate.js
@@ -9,9 +9,19 @@ const { Template } = require('webpack');
9
*/
10
const beforeModule = `
11
let cleanup = function NoOp() {};
12
-
13
-if (window && window.$RefreshSetup$) {
14
- cleanup = window.$RefreshSetup$(module.i);
+let check = function (it) {
+ return it && it.Math == Math && it;
+};
15
+
16
+let safeThis =
17
+ check(typeof globalThis == 'object' && globalThis) ||
18
+ check(typeof window == 'object' && window) ||
19
+ check(typeof self == 'object' && self) ||
20
+ check(typeof global == 'object' && global) ||
21
+ Function('return this')();
22
23
+if (safeThis && safeThis.$RefreshSetup$) {
24
+ cleanup = safeThis.$RefreshSetup$(module.i);
25
}
26
27
try {
0 commit comments