Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: patch lodash to not use Function calls #5408

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -129,7 +129,8 @@
},
"pnpm": {
"patchedDependencies": {
"cytoscape@3.28.1": "patches/cytoscape@3.28.1.patch"
"cytoscape@3.28.1": "patches/cytoscape@3.28.1.patch",
"lodash-es@4.17.21": "patches/lodash-es@4.17.21.patch"
}
}
}
36 changes: 36 additions & 0 deletions patches/cytoscape@3.28.1.patch

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions patches/lodash-es@4.17.21.patch
@@ -0,0 +1,28 @@
diff --git a/_root.js b/_root.js
index 281f81280ec9ea137b644ba60b9f5c6ccede4f88..4f97e318c0fb9b3f43962f9351f0c3d06dec29c8 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 root = globalThis;
+ 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;