Skip to content

Commit

Permalink
fix: patch lodash to not use Function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash-Singh1 committed Mar 23, 2024
1 parent 10fb856 commit 7bc2016
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 13 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@
},
"pnpm": {
"patchedDependencies": {
"[email protected]": "patches/[email protected]"
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]"
}
}
}
36 changes: 36 additions & 0 deletions patches/[email protected]

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions patches/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/_root.js b/_root.js
index 281f81280ec9ea137b644ba60b9f5c6ccede4f88..ceb914c0fa8db7d7064d2a6b79f065ec59c826e9 100644
--- a/_root.js
+++ b/_root.js
@@ -3,7 +3,22 @@ import freeGlobal from './_freeGlobal.js';
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;

+// From https://mathiasbynens.be/notes/globalthis#robust-polyfill
+var root = freeGlobal || freeSelf || null;
+if (root == null) {
+ (function() {
+ if (typeof globalThis === 'object') return;
+ Object.defineProperty(Object.prototype, '__magic__', {
+ get: function() {
+ return this;
+ },
+ configurable: true
+ });
+ root = __magic__;
+ delete Object.prototype.__magic__;
+ })();
+}
+
/** Used as a reference to the global object. */
-var root = freeGlobal || freeSelf || Function('return this')();

export default root;
27 changes: 15 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7bc2016

Please sign in to comment.