Skip to content

Commit 45c1717

Browse files
chore: update browserlist and babel targets to chrome/firefox 89 (#22521)
## **Description** IIRC, we've documented extension browser support for versions 2 years old and newer (I can't find this documentation now though). Chrome and Firefox 89 were released in 2021, so the version in this PR should be good to go. We could go with even newer browser versions, but it was a struggle getting it to work for v89, so I didn't try to take the versions any further. This PR also reduces the chance of seeing a lavamoat caused `RegExpCompiler Allocation failed - process out of memory` error (#21006). ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've clearly explained what problem this PR is solving and how it is solved. - [ ] I've linked related issues - [ ] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [ ] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [ ] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: legobt <[email protected]> Co-authored-by: legobeat <[email protected]>
1 parent e956826 commit 45c1717

12 files changed

+92
-20
lines changed

.browserslistrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
chrome >= 80, firefox >= 78
1+
chrome >= 89, firefox >= 89

.depcheckrc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ ignores:
5858
- 'resolve-url-loader'
5959
# jest environments
6060
- 'jest-environment-jsdom'
61+
# babel
62+
- '@babel/plugin-transform-logical-assignment-operators'
6163

6264
# files depcheck should not parse
6365
ignorePatterns:

.yarn/patches/lavamoat-core-npm-15.1.1-51fbe39988.patch

+52
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
diff --git a/src/kernelCoreTemplate.js b/src/kernelCoreTemplate.js
2+
index 752a9c0f0179c1249bd4c3fdb62c216543f01ce2..39fccc6a004218ce7233cbf95db4ffe24907b856 100644
3+
--- a/src/kernelCoreTemplate.js
4+
+++ b/src/kernelCoreTemplate.js
5+
@@ -70,6 +70,8 @@
6+
const { prepareCompartmentGlobalFromConfig } = templateRequire('makePrepareRealmGlobalFromConfig')({ createFunctionWrapper })
7+
const { strictScopeTerminator } = templateRequire('strict-scope-terminator')
8+
9+
+ // cache regular expressions to work around https://github.com/MetaMask/metamask-extension/issues/21006
10+
+ const regexCache = new Map()
11+
const scuttleOpts = generateScuttleOpts(scuttleGlobalThis)
12+
const moduleCache = new Map()
13+
const packageCompartmentCache = new Map()
14+
@@ -126,10 +128,15 @@
15+
if (!except.startsWith('/')) {
16+
return except
17+
}
18+
+ if (regexCache.has(except)) {
19+
+ return regexCache.get(except)
20+
+ }
21+
const parts = except.split('/')
22+
const pattern = parts.slice(1, -1).join('/')
23+
const flags = parts[parts.length - 1]
24+
- return new RegExp(pattern, flags)
25+
+ const re = new RegExp(pattern, flags)
26+
+ regexCache.set(except, re)
27+
+ return re
28+
}
29+
}
30+
131
diff --git a/src/loadPolicy.js b/src/loadPolicy.js
232
index f0ca3c4991a64f316f4e7199867439dd9ab09354..11296dd253b8dc1afd4cc870a0207c280fb728d9 100644
333
--- a/src/loadPolicy.js
@@ -16,3 +46,25 @@ index f0ca3c4991a64f316f4e7199867439dd9ab09354..11296dd253b8dc1afd4cc870a0207c28
1646

1747
return finalPolicy
1848
}
49+
diff --git a/src/sourceTransforms.js b/src/sourceTransforms.js
50+
index 9b1524810574c207631823869a781c343adb197f..4d02a6557ca0391a06326b420c274b5f60f72edc 100644
51+
--- a/src/sourceTransforms.js
52+
+++ b/src/sourceTransforms.js
53+
@@ -12,12 +12,12 @@ function applySourceTransforms(source) {
54+
])
55+
}
56+
57+
+const DIRECT_EVAL_REPLACE_FN = (_, p1) => '(0,eval)' + p1
58+
function evadeDirectEvalExpressions(source) {
59+
- /* eslint-disable-next-line prefer-regex-literals */
60+
- const someDirectEvalPattern = new RegExp('\\beval(\\s*\\()', 'g')
61+
-
62+
- const replaceFn = (_, p1) => `(0,eval)${p1}`
63+
- return source.replace(someDirectEvalPattern, replaceFn)
64+
+ return source.replace(
65+
+ /\beval(\s*\()/g,
66+
+ DIRECT_EVAL_REPLACE_FN
67+
+ )
68+
}
69+
70+
module.exports = {

app/manifest/v2/chrome.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"matches": ["https://metamask.io/*"],
55
"ids": ["*"]
66
},
7-
"minimum_chrome_version": "80"
7+
"minimum_chrome_version": "89"
88
}

app/manifest/v2/firefox.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"applications": {
33
"gecko": {
44
5-
"strict_min_version": "78.0"
5+
"strict_min_version": "89.0"
66
}
77
}
88
}

app/manifest/v3/chrome.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"matches": ["https://metamask.io/*"],
77
"ids": ["*"]
88
},
9-
"minimum_chrome_version": "88"
9+
"minimum_chrome_version": "89"
1010
}

app/manifest/v3/firefox.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"applications": {
33
"gecko": {
44
5-
"strict_min_version": "78.0"
5+
"strict_min_version": "89.0"
66
}
77
},
88
"background": {

babel.config.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ module.exports = function (api) {
55
strictMode: true,
66
},
77
targets: {
8-
browsers: ['chrome >= 80', 'firefox >= 78'],
8+
browsers: ['chrome >= 89', 'firefox >= 89'],
99
},
10+
plugins: [
11+
// `browserify` is old and busted, and doesn't support `??=` (and other
12+
// logical assignment operators). This plugin lets us target es2020-level
13+
// browsers (except we do still end up with transpiled logical assignment
14+
// operators 😭)
15+
'@babel/plugin-transform-logical-assignment-operators',
16+
],
1017
presets: [
1118
'@babel/preset-typescript',
1219
'@babel/preset-env',

lavamoat/build-system/policy-override.json

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"$root$": true,
66
"@babel/preset-env": true,
77
"@babel/preset-react": true,
8+
"@babel/plugin-transform-logical-assignment-operators": true,
89
"@babel/plugin-transform-runtime": true,
910
"@babel/plugin-proposal-class-properties": true,
1011
"@babel/plugin-proposal-nullish-coalescing-operator": true,
@@ -32,6 +33,13 @@
3233
"process.versions": true
3334
}
3435
},
36+
"@babel/plugin-transform-logical-assignment-operators": {
37+
"packages": {
38+
"@babel/core": true,
39+
"@babel/preset-env>@babel/helper-plugin-utils": true,
40+
"@babel/preset-env>@babel/plugin-syntax-logical-assignment-operators": true
41+
}
42+
},
3543
"depcheck>@babel/traverse": {
3644
"packages": {
3745
"babel/preset-env>b@babel/types": true

lavamoat/build-system/policy.json

+9-8
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
"@babel/plugin-proposal-nullish-coalescing-operator": true,
138138
"@babel/plugin-proposal-object-rest-spread": true,
139139
"@babel/plugin-proposal-optional-chaining": true,
140+
"@babel/plugin-transform-logical-assignment-operators": true,
140141
"@babel/plugin-transform-runtime": true,
141142
"@babel/preset-env": true,
142143
"@babel/preset-react": true,
@@ -304,6 +305,13 @@
304305
"eslint": true
305306
}
306307
},
308+
"@babel/plugin-transform-logical-assignment-operators": {
309+
"packages": {
310+
"@babel/core": true,
311+
"@babel/preset-env>@babel/helper-plugin-utils": true,
312+
"@babel/preset-env>@babel/plugin-syntax-logical-assignment-operators": true
313+
}
314+
},
307315
"@babel/preset-env": {
308316
"globals": {
309317
"console.log": true,
@@ -314,6 +322,7 @@
314322
"packages": {
315323
"@babel/core>@babel/helper-compilation-targets": true,
316324
"@babel/core>@babel/types": true,
325+
"@babel/plugin-transform-logical-assignment-operators": true,
317326
"@babel/preset-env>@babel/compat-data": true,
318327
"@babel/preset-env>@babel/helper-plugin-utils": true,
319328
"@babel/preset-env>@babel/helper-validator-option": true,
@@ -356,7 +365,6 @@
356365
"@babel/preset-env>@babel/plugin-transform-function-name": true,
357366
"@babel/preset-env>@babel/plugin-transform-json-strings": true,
358367
"@babel/preset-env>@babel/plugin-transform-literals": true,
359-
"@babel/preset-env>@babel/plugin-transform-logical-assignment-operators": true,
360368
"@babel/preset-env>@babel/plugin-transform-member-expression-literals": true,
361369
"@babel/preset-env>@babel/plugin-transform-modules-amd": true,
362370
"@babel/preset-env>@babel/plugin-transform-modules-commonjs": true,
@@ -717,13 +725,6 @@
717725
"@babel/preset-env>@babel/helper-plugin-utils": true
718726
}
719727
},
720-
"@babel/preset-env>@babel/plugin-transform-logical-assignment-operators": {
721-
"packages": {
722-
"@babel/core": true,
723-
"@babel/preset-env>@babel/helper-plugin-utils": true,
724-
"@babel/preset-env>@babel/plugin-syntax-logical-assignment-operators": true
725-
}
726-
},
727728
"@babel/preset-env>@babel/plugin-transform-member-expression-literals": {
728729
"packages": {
729730
"@babel/core": true,

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@
390390
"@babel/core": "^7.23.2",
391391
"@babel/eslint-parser": "^7.22.15",
392392
"@babel/eslint-plugin": "^7.22.10",
393+
"@babel/plugin-transform-logical-assignment-operators": "^7.23.4",
393394
"@babel/preset-env": "^7.23.2",
394395
"@babel/preset-react": "^7.22.15",
395396
"@babel/preset-typescript": "^7.23.2",

yarn.lock

+7-6
Original file line numberDiff line numberDiff line change
@@ -1022,15 +1022,15 @@ __metadata:
10221022
languageName: node
10231023
linkType: hard
10241024

1025-
"@babel/plugin-transform-logical-assignment-operators@npm:^7.22.11":
1026-
version: 7.22.11
1027-
resolution: "@babel/plugin-transform-logical-assignment-operators@npm:7.22.11"
1025+
"@babel/plugin-transform-logical-assignment-operators@npm:^7.22.11, @babel/plugin-transform-logical-assignment-operators@npm:^7.23.4":
1026+
version: 7.23.4
1027+
resolution: "@babel/plugin-transform-logical-assignment-operators@npm:7.23.4"
10281028
dependencies:
10291029
"@babel/helper-plugin-utils": "npm:^7.22.5"
10301030
"@babel/plugin-syntax-logical-assignment-operators": "npm:^7.10.4"
10311031
peerDependencies:
10321032
"@babel/core": ^7.0.0-0
1033-
checksum: c664e9798e85afa7f92f07b867682dee7392046181d82f5d21bae6f2ca26dfe9c8375cdc52b7483c3fc09a983c1989f60eff9fbc4f373b0c0a74090553d05739
1033+
checksum: 2ae1dc9b4ff3bf61a990ff3accdecb2afe3a0ca649b3e74c010078d1cdf29ea490f50ac0a905306a2bcf9ac177889a39ac79bdcc3a0fdf220b3b75fac18d39b5
10341034
languageName: node
10351035
linkType: hard
10361036

@@ -23412,13 +23412,13 @@ __metadata:
2341223412

2341323413
"lavamoat-core@patch:lavamoat-core@npm%3A15.1.1#~/.yarn/patches/lavamoat-core-npm-15.1.1-51fbe39988.patch":
2341423414
version: 15.1.1
23415-
resolution: "lavamoat-core@patch:lavamoat-core@npm%3A15.1.1#~/.yarn/patches/lavamoat-core-npm-15.1.1-51fbe39988.patch::version=15.1.1&hash=1424a1"
23415+
resolution: "lavamoat-core@patch:lavamoat-core@npm%3A15.1.1#~/.yarn/patches/lavamoat-core-npm-15.1.1-51fbe39988.patch::version=15.1.1&hash=95165a"
2341623416
dependencies:
2341723417
json-stable-stringify: "npm:1.0.2"
2341823418
lavamoat-tofu: "npm:^7.1.0"
2341923419
merge-deep: "npm:3.0.3"
2342023420
type-fest: "npm:4.7.1"
23421-
checksum: 994e2c67fa55f2ca110fe3d880a6f5e1763b1aea123333792131526cdbb7083fe4f0e3db2e1f502a8517230298295a44869366dfd358a443ea06835c6a8cba47
23421+
checksum: e408e3fd65987e0083a4649da3b158ace2eb55379add58a2a0c9a2d1b9b5aee86d03dd44dc616796a5c1c07f303c0691db7c41877b2c3cc4ce86d80af229844b
2342223422
languageName: node
2342323423
linkType: hard
2342423424

@@ -24701,6 +24701,7 @@ __metadata:
2470124701
"@babel/core": "npm:^7.23.2"
2470224702
"@babel/eslint-parser": "npm:^7.22.15"
2470324703
"@babel/eslint-plugin": "npm:^7.22.10"
24704+
"@babel/plugin-transform-logical-assignment-operators": "npm:^7.23.4"
2470424705
"@babel/preset-env": "npm:^7.23.2"
2470524706
"@babel/preset-react": "npm:^7.22.15"
2470624707
"@babel/preset-typescript": "npm:^7.23.2"

0 commit comments

Comments
 (0)