Skip to content

Commit a68cf51

Browse files
committed
Patch lodash to fix Firefox contentscript incompatibility
1 parent 711bfb1 commit a68cf51

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
diff --git a/_PATCH.txt b/_PATCH.txt
2+
new file mode 100644
3+
index 0000000000000000000000000000000000000000..94d9729bdc09c57a213683e048f1edb9b0d8fe42
4+
--- /dev/null
5+
+++ b/_PATCH.txt
6+
@@ -0,0 +1,2 @@
7+
+This patch fixes a bug in Lodash when it's run in a contentscript on Firefox.
8+
+See here for details: https://github.com/lodash/lodash/issues/5934
9+
diff --git a/_freeGlobal.js b/_freeGlobal.js
10+
index bbec998fc8cbaaeec1f848017aa8e232d4d419eb..37addf20c9846f1729b83c67746714e6bcc6565d 100644
11+
--- a/_freeGlobal.js
12+
+++ b/_freeGlobal.js
13+
@@ -1,4 +1,4 @@
14+
/** Detect free variable `global` from Node.js. */
15+
-var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
16+
+var freeGlobal = typeof globalThis == 'object' && globalThis && globalThis.Object === Object && globalThis;
17+
18+
module.exports = freeGlobal;
19+
diff --git a/core.js b/core.js
20+
index be1d567d629fdfda05efcaa6adfb480d93702889..c74af2204241654129a4b8d9bc8e1ad235c464f1 100644
21+
--- a/core.js
22+
+++ b/core.js
23+
@@ -62,7 +62,7 @@
24+
};
25+
26+
/** Detect free variable `global` from Node.js. */
27+
- var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
28+
+ var freeGlobal = typeof globalThis == 'object' && globalThis && globalThis.Object === Object && globalThis;
29+
30+
/** Detect free variable `self`. */
31+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
32+
diff --git a/lodash.js b/lodash.js
33+
index 4131e936cd1e0521ac7be3a9d4bfb9f1fdb35462..5febc1c8b908871a65db4ffcc8ed4a42f9c648be 100644
34+
--- a/lodash.js
35+
+++ b/lodash.js
36+
@@ -427,7 +427,7 @@
37+
freeParseInt = parseInt;
38+
39+
/** Detect free variable `global` from Node.js. */
40+
- var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
41+
+ var freeGlobal = typeof globalThis == 'object' && globalThis && globalThis.Object === Object && globalThis;
42+
43+
/** Detect free variable `self`. */
44+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@
234234
"@ledgerhq/errors": "^6.21.0",
235235
"nanoid@npm:^5.1.5": "^3.3.8",
236236
"tar-fs@npm:^2.1.0": "^2.1.3",
237-
"lodash.memoize@npm:^4.1.2": "patch:lodash.memoize@npm%3A4.1.2#~/.yarn/patches/lodash.memoize-npm-4.1.2-0e6250041f.patch"
237+
"lodash.memoize@npm:^4.1.2": "patch:lodash.memoize@npm%3A4.1.2#~/.yarn/patches/lodash.memoize-npm-4.1.2-0e6250041f.patch",
238+
"lodash": "patch:lodash@npm%3A4.17.21#~/.yarn/patches/lodash-npm-4.17.21-6382451519.patch"
238239
},
239240
"dependencies": {
240241
"@babel/runtime": "patch:@babel/runtime@npm%3A7.25.9#~/.yarn/patches/@babel-runtime-npm-7.25.9-fe8c62510a.patch",

yarn.lock

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31099,13 +31099,20 @@ __metadata:
3109931099
languageName: node
3110031100
linkType: hard
3110131101

31102-
"lodash@npm:4.17.21, lodash@npm:^4, lodash@npm:^4.16.4, lodash@npm:^4.17.11, lodash@npm:^4.17.14, lodash@npm:^4.17.15, lodash@npm:^4.17.19, lodash@npm:^4.17.20, lodash@npm:^4.17.21, lodash@npm:^4.17.4, lodash@npm:^4.7.0":
31102+
"lodash@npm:4.17.21":
3110331103
version: 4.17.21
3110431104
resolution: "lodash@npm:4.17.21"
3110531105
checksum: 10/c08619c038846ea6ac754abd6dd29d2568aa705feb69339e836dfa8d8b09abbb2f859371e86863eda41848221f9af43714491467b5b0299122431e202bb0c532
3110631106
languageName: node
3110731107
linkType: hard
3110831108

31109+
"lodash@patch:lodash@npm%3A4.17.21#~/.yarn/patches/lodash-npm-4.17.21-6382451519.patch":
31110+
version: 4.17.21
31111+
resolution: "lodash@patch:lodash@npm%3A4.17.21#~/.yarn/patches/lodash-npm-4.17.21-6382451519.patch::version=4.17.21&hash=a39172"
31112+
checksum: 10/c9fdcf4cf6440e980aaa687aa7a787afb4563502c28e88eb230c3adfac0aa6b2ccb96aaf4a17c0148c3daa2d8cc83edad8ecedd8ed64a615b47f07b0f484cd9c
31113+
languageName: node
31114+
linkType: hard
31115+
3110931116
"log-symbols@npm:4.1.0, log-symbols@npm:^4.0.0, log-symbols@npm:^4.1.0":
3111031117
version: 4.1.0
3111131118
resolution: "log-symbols@npm:4.1.0"

0 commit comments

Comments
 (0)