Skip to content

core: use with import attributes for legacy-javascript, bump to node 18.20 #16415

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

Merged
merged 3 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
GITHUB_CONTEXT_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_CONTEXT_BASE_SHA: ${{ github.event.before }}

- name: Use Node.js 18.x
- name: Use Node.js 18.20
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: '18.20'

- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn type-check
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cron-weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
steps:
- name: git clone
uses: actions/checkout@v4
- name: Use Node.js 18.x
- name: Use Node.js 18.20
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: '18.20'
- run: yarn --frozen-lockfile

- run: yarn mocha --testMatch=third-party/chromium-synchronization/*-test.js
12 changes: 6 additions & 6 deletions .github/workflows/devtools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
with:
path: lighthouse

- name: Use Node.js 18.x
- name: Use Node.js 18.20
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: '18.20'

- name: Generate cache hash
run: bash $GITHUB_WORKSPACE/lighthouse/.github/scripts/generate-devtools-hash.sh > cdt-test-hash.txt
Expand Down Expand Up @@ -91,10 +91,10 @@ jobs:
with:
path: lighthouse

- name: Use Node.js 18.x
- name: Use Node.js 18.20
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: '18.20'

- run: yarn --frozen-lockfile --network-timeout 1000000
working-directory: ${{ github.workspace }}/lighthouse
Expand Down Expand Up @@ -141,10 +141,10 @@ jobs:
with:
path: lighthouse

- name: Use Node.js 18.x
- name: Use Node.js 18.20
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: '18.20'

- name: Load build artifacts
id: devtools-build-artifacts
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/package-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
- name: git clone
uses: actions/checkout@v4

- name: Use Node.js 18.x
- name: Use Node.js 18.20
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: '18.20'

- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn build-report
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: '18.20'
registry-url: https://registry.npmjs.org/
- run: yarn --frozen-lockfile

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ jobs:
# Depth of at least 2 for codecov coverage diffs. See https://github.com/GoogleChrome/lighthouse/pull/12079
fetch-depth: 2

- name: Use Node.js 18.x
- name: Use Node.js 18.20
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: '18.20'

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

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

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

- name: Use Node.js 18.x
- name: Use Node.js 18.20
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: '18.20'

- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn build-report
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ jobs:
- name: git clone
uses: actions/checkout@v4

- name: Use Node.js 18.x
- name: Use Node.js 18.20
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: '18.20'

- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn build-report
Expand Down
15 changes: 4 additions & 11 deletions core/lib/legacy-javascript/legacy-javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,14 @@
/** @typedef {{name: string, line: number, column: number}} PatternMatchResult */
/** @typedef {{matches: PatternMatchResult[], estimatedByteSavings: number}} Result */

import fs from 'fs';

import {LH_ROOT} from '../../../shared/root.js';

const polyfillModuleDataJson = fs.readFileSync(
`${LH_ROOT}/core/lib/legacy-javascript/polyfill-module-data.json`, 'utf-8');
import polyfillModuleData_ from './polyfill-module-data.json' with { type: 'json' };
import graph_ from './polyfill-graph-data.json' with { type: 'json' };

/** @type {import('../../scripts/legacy-javascript/create-polyfill-module-data.js').PolyfillModuleData} */
const polyfillModuleData = JSON.parse(polyfillModuleDataJson);

const graphJson = fs.readFileSync(
`${LH_ROOT}/core/lib/legacy-javascript/polyfill-graph-data.json`, 'utf-8');
const polyfillModuleData = polyfillModuleData_;

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

/**
* Takes a list of patterns (consisting of a name identifier and a RegExp expression string)
Expand Down
2 changes: 1 addition & 1 deletion docs/headless-chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Setup:

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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"smokehouse": "./cli/test/smokehouse/frontends/smokehouse-bin.js"
},
"engines": {
"node": ">=18.16"
"node": ">=18.20"
},
"scripts": {
"prepack": "yarn build-report --standalone --flow --esm && yarn build-types",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The Chrome extension was available prior to Lighthouse being available in Chrome
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.

> **Note**
> Lighthouse requires Node 18 LTS (18.x) or later.
> Lighthouse requires Node 18.20 or later.

**Installation**:

Expand Down
2 changes: 1 addition & 1 deletion tsconfig-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"rootDir": ".",

"target": "es2022",
"module": "es2022",
"module": "preserve",
"moduleResolution": "node",
"esModuleInterop": true,

Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"core/test/fixtures/unresolved-perflog.json",
"core/test/fixtures/traces/lcp-m78.devtools.log.json",
"core/lib/legacy-javascript/polyfill-graph-data.json",
"core/lib/legacy-javascript/polyfill-module-data.json",
"shared/localization/locales/en-US.json",
],
"exclude": [
Expand Down
Loading