Skip to content

Commit a09a5a2

Browse files
authored
misc: prepare core/lib/legacy-javascript to be published to npm (#16416)
1 parent 1a094e1 commit a09a5a2

3 files changed

Lines changed: 49 additions & 2 deletions

File tree

build/build-legacy-javascript.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import fs from 'fs';
8+
9+
import esbuild from 'esbuild';
10+
import esMain from 'es-main';
11+
12+
import {LH_ROOT} from '../shared/root.js';
13+
14+
async function buildPackage() {
15+
await esbuild.build({
16+
entryPoints: ['core/lib/legacy-javascript/legacy-javascript.js'],
17+
outfile: 'dist/legacy-javascript/legacy-javascript.js',
18+
format: 'esm',
19+
bundle: true,
20+
});
21+
22+
fs.copyFileSync(`${LH_ROOT}/core/lib/legacy-javascript/package.json`,
23+
'dist/legacy-javascript/package.json');
24+
}
25+
26+
async function main() {
27+
await buildPackage();
28+
}
29+
30+
if (esMain(import.meta)) {
31+
await main();
32+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "legacy-javascript",
3+
"type": "module",
4+
"version": "0.0.1",
5+
"description": "Identify legacy polyfills and code transforms",
6+
"main": "./legacy-javascript.js",
7+
"repository": "GoogleChrome/lighthouse",
8+
"author": "Google LLC",
9+
"license": "Apache-2.0",
10+
"bugs": {
11+
"url": "https://github.com/GoogleChrome/lighthouse/issues"
12+
},
13+
"homepage": "https://github.com/GoogleChrome/lighthouse#readme"
14+
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
"prepack": "yarn build-report --standalone --flow --esm && yarn build-types",
1717
"postpack": "yarn clean-types",
1818
"build-all": "npm-run-posix-or-windows build-all:task",
19-
"build-all:task": "yarn build-report && yarn build-cdt-strings && yarn build-devtools && concurrently 'yarn build-extension' 'yarn build-lr' 'yarn build-viewer' 'yarn build-treemap' 'yarn build-smokehouse-bundle' && yarn build-pack",
20-
"build-all:task:windows": "yarn build-report && yarn build-cdt-strings && yarn build-extension && yarn build-devtools && yarn build-lr && yarn build-viewer && yarn build-treemap && yarn build-smokehouse-bundle",
19+
"build-all:task": "yarn build-report && yarn build-cdt-strings && yarn build-devtools && concurrently 'yarn build-extension' 'yarn build-lr' 'yarn build-viewer' 'yarn build-treemap' 'yarn build-smokehouse-bundle' 'yarn build-legacy-javascript' && yarn build-pack",
20+
"build-all:task:windows": "yarn build-report && yarn build-cdt-strings && yarn build-extension && yarn build-devtools && yarn build-lr && yarn build-viewer && yarn build-treemap && yarn build-smokehouse-bundle && yarn build-legacy-javascript",
2121
"build-cdt-lib": "node ./build/build-cdt-lib.js",
2222
"build-cdt-strings": "node ./build/build-cdt-strings.js",
2323
"build-extension": "yarn build-extension-chrome && yarn build-extension-firefox",
2424
"build-extension-chrome": "node ./build/build-extension.js chrome",
2525
"build-extension-firefox": "node ./build/build-extension.js firefox",
2626
"build-devtools": "yarn reset-link && node ./build/build-bundle.js clients/devtools/devtools-entry.js dist/lighthouse-dt-bundle.js && node ./build/build-dt-report-resources.js",
27+
"build-legacy-javascript": "node ./build/build-legacy-javascript.js",
2728
"build-smokehouse-bundle": "node ./build/build-smokehouse-bundle.js",
2829
"build-lr": "yarn reset-link && node --max-old-space-size=4096 ./build/build-lightrider-bundles.js",
2930
"build-pack": "bash build/build-pack.sh",

0 commit comments

Comments
 (0)