Skip to content

Commit 5e345b3

Browse files
authored
core: use with import attributes for legacy-javascript, bump to node 18.20 (#16415)
1 parent 410adb1 commit 5e345b3

13 files changed

+30
-36
lines changed

.github/workflows/ci.yml

+2-2
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.x
32+
- name: Use Node.js 18.20
3333
uses: actions/setup-node@v4
3434
with:
35-
node-version: 18.x
35+
node-version: '18.20'
3636

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

.github/workflows/cron-weekly.yml

+2-2
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.x
34+
- name: Use Node.js 18.20
3535
uses: actions/setup-node@v4
3636
with:
37-
node-version: 18.x
37+
node-version: '18.20'
3838
- run: yarn --frozen-lockfile
3939

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

.github/workflows/devtools.yml

+6-6
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.x
28+
- name: Use Node.js 18.20
2929
uses: actions/setup-node@v4
3030
with:
31-
node-version: 18.x
31+
node-version: '18.20'
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.x
94+
- name: Use Node.js 18.20
9595
uses: actions/setup-node@v4
9696
with:
97-
node-version: 18.x
97+
node-version: '18.20'
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.x
144+
- name: Use Node.js 18.20
145145
uses: actions/setup-node@v4
146146
with:
147-
node-version: 18.x
147+
node-version: '18.20'
148148

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

.github/workflows/package-test.yml

+2-2
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.x
22+
- name: Use Node.js 18.20
2323
uses: actions/setup-node@v4
2424
with:
25-
node-version: 18.x
25+
node-version: '18.20'
2626

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

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- uses: actions/checkout@v4
3232
- uses: actions/setup-node@v4
3333
with:
34-
node-version: 18.x
34+
node-version: '18.20'
3535
registry-url: https://registry.npmjs.org/
3636
- run: yarn --frozen-lockfile
3737

.github/workflows/smoke.yml

+6-6
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.x
39+
- name: Use Node.js 18.20
4040
uses: actions/setup-node@v4
4141
with:
42-
node-version: 18.x
42+
node-version: '18.20'
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.x
101+
- name: Use Node.js 18.20
102102
uses: actions/setup-node@v4
103103
with:
104-
node-version: 18.x
104+
node-version: '18.20'
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.x
149+
- name: Use Node.js 18.20
150150
uses: actions/setup-node@v4
151151
with:
152-
node-version: 18.x
152+
node-version: '18.20'
153153

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

.github/workflows/unit.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ jobs:
106106
- name: git clone
107107
uses: actions/checkout@v4
108108

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

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

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

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

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');
18+
import polyfillModuleData_ from './polyfill-module-data.json' with { type: 'json' };
19+
import graph_ from './polyfill-graph-data.json' with { type: 'json' };
2420

2521
/** @type {import('../../scripts/legacy-javascript/create-polyfill-module-data.js').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');
22+
const polyfillModuleData = polyfillModuleData_;
3023

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

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

docs/headless-chrome.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Setup:
66

77
```sh
8-
# Lighthouse requires Node 18 LTS (18.x) or later.
8+
# Lighthouse requires Node 18.20 or later.
99
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\
1010
sudo apt-get install -y nodejs npm
1111

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"smokehouse": "./cli/test/smokehouse/frontends/smokehouse-bin.js"
1111
},
1212
"engines": {
13-
"node": ">=18.16"
13+
"node": ">=18.20"
1414
},
1515
"scripts": {
1616
"prepack": "yarn build-report --standalone --flow --esm && yarn build-types",

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The Chrome extension was available prior to Lighthouse being available in Chrome
5353
The Node CLI provides the most flexibility in how Lighthouse runs can be configured and reported. Users who want more advanced usage, or want to run Lighthouse in an automated fashion should use the Node CLI.
5454

5555
> **Note**
56-
> Lighthouse requires Node 18 LTS (18.x) or later.
56+
> Lighthouse requires Node 18.20 or later.
5757
5858
**Installation**:
5959

tsconfig-base.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"rootDir": ".",
1313

1414
"target": "es2022",
15-
"module": "es2022",
15+
"module": "preserve",
1616
"moduleResolution": "node",
1717
"esModuleInterop": true,
1818

tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"core/test/fixtures/unresolved-perflog.json",
2626
"core/test/fixtures/traces/lcp-m78.devtools.log.json",
2727
"core/lib/legacy-javascript/polyfill-graph-data.json",
28+
"core/lib/legacy-javascript/polyfill-module-data.json",
2829
"shared/localization/locales/en-US.json",
2930
],
3031
"exclude": [

0 commit comments

Comments
 (0)