Skip to content

Commit 98bee62

Browse files
authored
misc: revert json modules to fully support Node 20 (#16613)
1 parent 11210b0 commit 98bee62

File tree

19 files changed

+241
-198
lines changed

19 files changed

+241
-198
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ jobs:
2929
GITHUB_CONTEXT_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
3030
GITHUB_CONTEXT_BASE_SHA: ${{ github.event.before }}
3131

32-
- name: Use Node.js 18.20
32+
- name: Use Node.js 18.x
3333
uses: actions/setup-node@v4
3434
with:
35-
node-version: '18.20'
35+
node-version: 18.x
3636

3737
- run: yarn install --frozen-lockfile --network-timeout 1000000
3838
- run: yarn type-check

.github/workflows/cron-weekly.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ jobs:
3131
steps:
3232
- name: git clone
3333
uses: actions/checkout@v4
34-
- name: Use Node.js 18.20
34+
- name: Use Node.js 18.x
3535
uses: actions/setup-node@v4
3636
with:
37-
node-version: '18.20'
37+
node-version: 18.x
3838
- run: yarn --frozen-lockfile
3939

4040
- run: yarn mocha --testMatch=third-party/chromium-synchronization/*-test.js

.github/workflows/devtools.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
with:
2626
path: lighthouse
2727

28-
- name: Use Node.js 18.20
28+
- name: Use Node.js 18.x
2929
uses: actions/setup-node@v4
3030
with:
31-
node-version: '18.20'
31+
node-version: 18.x
3232

3333
- name: Generate cache hash
3434
run: bash $GITHUB_WORKSPACE/lighthouse/.github/scripts/generate-devtools-hash.sh > cdt-test-hash.txt
@@ -91,10 +91,10 @@ jobs:
9191
with:
9292
path: lighthouse
9393

94-
- name: Use Node.js 18.20
94+
- name: Use Node.js 18.x
9595
uses: actions/setup-node@v4
9696
with:
97-
node-version: '18.20'
97+
node-version: 18.x
9898

9999
- run: yarn --frozen-lockfile --network-timeout 1000000
100100
working-directory: ${{ github.workspace }}/lighthouse
@@ -141,10 +141,10 @@ jobs:
141141
with:
142142
path: lighthouse
143143

144-
- name: Use Node.js 18.20
144+
- name: Use Node.js 18.x
145145
uses: actions/setup-node@v4
146146
with:
147-
node-version: '18.20'
147+
node-version: 18.x
148148

149149
- name: Load build artifacts
150150
id: devtools-build-artifacts

.github/workflows/package-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
- name: git clone
2020
uses: actions/checkout@v4
2121

22-
- name: Use Node.js 18.20
22+
- name: Use Node.js 18.x
2323
uses: actions/setup-node@v4
2424
with:
25-
node-version: '18.20'
25+
node-version: 18.x
2626

2727
- run: yarn install --frozen-lockfile --network-timeout 1000000
2828
- run: yarn build-report

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- uses: actions/checkout@v4
4040
- uses: actions/setup-node@v4
4141
with:
42-
node-version: '18.20'
42+
node-version: 18.x
4343
registry-url: https://registry.npmjs.org/
4444
- run: yarn --frozen-lockfile
4545

.github/workflows/smoke.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ jobs:
3636
# Depth of at least 2 for codecov coverage diffs. See https://github.com/GoogleChrome/lighthouse/pull/12079
3737
fetch-depth: 2
3838

39-
- name: Use Node.js 18.20
39+
- name: Use Node.js 18.x
4040
uses: actions/setup-node@v4
4141
with:
42-
node-version: '18.20'
42+
node-version: 18.x
4343

4444
# Since Ubuntu 23, dev builds of Chromium need this.
4545
# https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
@@ -98,10 +98,10 @@ jobs:
9898
uses: actions/checkout@v4
9999

100100
# Use Node 18 here earlier than everywhere else, see https://github.com/GoogleChrome/lighthouse/issues/15160#issuecomment-1589913408
101-
- name: Use Node.js 18.20
101+
- name: Use Node.js 18.x
102102
uses: actions/setup-node@v4
103103
with:
104-
node-version: '18.20'
104+
node-version: 18.x
105105

106106
- name: Define ToT chrome path
107107
run: echo "CHROME_PATH=${env:GITHUB_WORKSPACE}\.tmp\chrome-tot\chrome.exe" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
@@ -146,10 +146,10 @@ jobs:
146146
- name: git clone
147147
uses: actions/checkout@v4
148148

149-
- name: Use Node.js 18.20
149+
- name: Use Node.js 18.x
150150
uses: actions/setup-node@v4
151151
with:
152-
node-version: '18.20'
152+
node-version: 18.x
153153

154154
- run: yarn install --frozen-lockfile --network-timeout 1000000
155155
- run: yarn build-report

.github/workflows/unit.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ jobs:
1313
unit:
1414
strategy:
1515
matrix:
16-
node: ['18', '20']
16+
node: ['18.20', '20.9', '20']
1717
fail-fast: false
1818
runs-on: ubuntu-latest
1919
name: node ${{ matrix.node }}
2020
env:
2121
CHROME_PATH: ${{ github.workspace }}/.tmp/chrome-tot/chrome
22-
LATEST_NODE: '18'
22+
LATEST_NODE: '20'
2323
FORCE_COLOR: true
2424

2525
steps:
@@ -106,10 +106,10 @@ jobs:
106106
- name: git clone
107107
uses: actions/checkout@v4
108108

109-
- name: Use Node.js 18.20
109+
- name: Use Node.js 18.x
110110
uses: actions/setup-node@v4
111111
with:
112-
node-version: '18.20'
112+
node-version: 18.x
113113

114114
- run: yarn install --frozen-lockfile --network-timeout 1000000
115115
- run: yarn build-report

build/build-legacy-javascript.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import fs from 'fs';
99
import esbuild from 'esbuild';
1010
import esMain from 'es-main';
1111

12+
import * as plugins from './esbuild-plugins.js';
1213
import {LH_ROOT} from '../shared/root.js';
1314

1415
async function buildPackage() {
@@ -17,6 +18,12 @@ async function buildPackage() {
1718
outfile: 'dist/legacy-javascript/legacy-javascript.js',
1819
format: 'esm',
1920
bundle: true,
21+
plugins: [
22+
plugins.bulkLoader([
23+
plugins.partialLoaders.inlineFs({verbose: Boolean(process.env.DEBUG)}),
24+
]),
25+
plugins.ignoreBuiltins(),
26+
],
2027
});
2128

2229
fs.copyFileSync(`${LH_ROOT}/core/lib/legacy-javascript/package.json`,

core/lib/legacy-javascript/legacy-javascript.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,21 @@
1515
/** @typedef {{name: string, line: number, column: number}} PatternMatchResult */
1616
/** @typedef {{matches: PatternMatchResult[], estimatedByteSavings: number}} Result */
1717

18-
import polyfillModuleData_ from './polyfill-module-data.json' with { type: 'json' };
19-
import graph_ from './polyfill-graph-data.json' with { type: 'json' };
18+
import fs from 'fs';
19+
20+
import {LH_ROOT} from '../../../shared/root.js';
21+
22+
const polyfillModuleDataJson = fs.readFileSync(
23+
`${LH_ROOT}/core/lib/legacy-javascript/polyfill-module-data.json`, 'utf-8');
2024

2125
/** @type {import('../../scripts/legacy-javascript/create-polyfill-module-data.js').PolyfillModuleData} */
22-
const polyfillModuleData = polyfillModuleData_;
26+
const polyfillModuleData = JSON.parse(polyfillModuleDataJson);
27+
28+
const graphJson = fs.readFileSync(
29+
`${LH_ROOT}/core/lib/legacy-javascript/polyfill-graph-data.json`, 'utf-8');
2330

2431
/** @type {import('../../scripts/legacy-javascript/create-polyfill-size-estimation.js').PolyfillSizeEstimator} */
25-
const graph = graph_;
32+
const graph = JSON.parse(graphJson);
2633

2734
/**
2835
* Takes a list of patterns (consisting of a name identifier and a RegExp expression string)

core/scripts/legacy-javascript/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"@rollup/plugin-commonjs": "^28.0.3",
99
"@rollup/plugin-terser": "^0.4.4",
1010
"browserify": "^16.5.0",
11-
"caniuse-lite": "^1.0.30001706",
12-
"core-js-compat": "^3.41.0",
11+
"caniuse-lite": "^1.0.30001731",
12+
"core-js-compat": "^3.44.0",
1313
"esbuild": "^0.25.1",
1414
"glob": "^7.1.6",
1515
"rollup": "^4.36.0",

0 commit comments

Comments
 (0)