lighthouse/build/build-smokehouse-bundle.js

54 строки
1.6 KiB
JavaScript
Исходник Обычный вид История

/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import esbuild from 'esbuild';
import * as plugins from './esbuild-plugins.js';
2023-09-06 01:04:35 +03:00
import {LH_ROOT} from '../shared/root.js';
import {nodeModulesPolyfillPlugin} from '../third-party/esbuild-plugins-polyfills/esbuild-polyfills.js';
const distDir = `${LH_ROOT}/dist`;
const bundleOutFile = `${distDir}/smokehouse-bundle.js`;
const smokehouseLibFilename = './cli/test/smokehouse/frontends/lib.js';
const smokehouseCliFilename = `${LH_ROOT}/cli/test/smokehouse/lighthouse-runners/cli.js`;
2022-06-10 20:23:08 +03:00
async function main() {
await esbuild.build({
entryPoints: [smokehouseLibFilename],
outfile: bundleOutFile,
format: 'cjs',
bundle: true,
2021-09-15 02:15:36 +03:00
plugins: [
plugins.replaceModules({
[smokehouseCliFilename]:
'export function runLighthouse() { throw new Error("not supported"); }',
2022-07-14 02:14:27 +03:00
'module': `
export const createRequire = () => {
return {
resolve() {
throw new Error('createRequire.resolve is not supported in bundled Lighthouse');
},
};
};
`,
// Our node modules polyfill plugin does not support assert/strict.
'assert/strict': `
import assert from 'assert';
export default assert;
`,
}),
plugins.bulkLoader([
plugins.partialLoaders.inlineFs({verbose: Boolean(process.env.DEBUG)}),
plugins.partialLoaders.rmGetModuleDirectory,
]),
nodeModulesPolyfillPlugin(),
plugins.ignoreBuiltins(),
2021-09-15 02:15:36 +03:00
],
});
2021-09-15 02:15:36 +03:00
}
2022-06-10 20:23:08 +03:00
await main();