mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
devops: consolidate build.js files (#35935)
This commit is contained in:
parent
f38ee4e212
commit
d8193ca947
@ -1,51 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Microsoft Corporation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// @ts-check
|
|
||||||
const path = require('path');
|
|
||||||
const esbuild = require('esbuild');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean} watchMode
|
|
||||||
* @returns {import('esbuild').BuildOptions}
|
|
||||||
*/
|
|
||||||
function esbuildOptions(watchMode) {
|
|
||||||
return {
|
|
||||||
entryPoints: [path.join(__dirname, 'src/index.ts')],
|
|
||||||
bundle: true,
|
|
||||||
outdir: path.join(__dirname, 'lib'),
|
|
||||||
format: 'cjs',
|
|
||||||
platform: 'node',
|
|
||||||
target: 'ES2019',
|
|
||||||
sourcemap: watchMode,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
const watchMode = process.argv.includes('--watch');
|
|
||||||
const ctx = await esbuild.context(esbuildOptions(watchMode));
|
|
||||||
await ctx.rebuild();
|
|
||||||
if (watchMode)
|
|
||||||
await ctx.watch();
|
|
||||||
else
|
|
||||||
await ctx.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { esbuildOptions };
|
|
||||||
|
|
||||||
if (require.main === module)
|
|
||||||
main();
|
|
@ -1,67 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Microsoft Corporation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// @ts-check
|
|
||||||
const path = require('path');
|
|
||||||
const esbuild = require('esbuild');
|
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
const outdir = path.join(__dirname, '../../lib/utilsBundleImpl');
|
|
||||||
|
|
||||||
function copyXdgOpen() {
|
|
||||||
if (!fs.existsSync(outdir))
|
|
||||||
fs.mkdirSync(outdir, { recursive: true });
|
|
||||||
|
|
||||||
// 'open' package requires 'xdg-open' binary to be present, which does not get bundled by esbuild.
|
|
||||||
fs.copyFileSync(path.join(__dirname, 'node_modules/open/xdg-open'), path.join(outdir, 'xdg-open'));
|
|
||||||
console.log('==== Copied xdg-open to', path.join(outdir, 'xdg-open'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean} watchMode
|
|
||||||
* @returns {import('esbuild').BuildOptions}
|
|
||||||
*/
|
|
||||||
function esbuildOptions(watchMode) {
|
|
||||||
return {
|
|
||||||
entryPoints: [path.join(__dirname, 'src/utilsBundleImpl.ts')],
|
|
||||||
bundle: true,
|
|
||||||
outfile: path.join(outdir, 'index.js'),
|
|
||||||
format: 'cjs',
|
|
||||||
platform: 'node',
|
|
||||||
target: 'ES2019',
|
|
||||||
sourcemap: watchMode,
|
|
||||||
minify: !watchMode,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
copyXdgOpen();
|
|
||||||
const watchMode = process.argv.includes('--watch');
|
|
||||||
const ctx = await esbuild.context(esbuildOptions(watchMode));
|
|
||||||
await ctx.rebuild();
|
|
||||||
if (watchMode)
|
|
||||||
await ctx.watch();
|
|
||||||
else
|
|
||||||
await ctx.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
beforeEsbuild: copyXdgOpen,
|
|
||||||
esbuildOptions,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (require.main === module)
|
|
||||||
main();
|
|
@ -2,12 +2,6 @@
|
|||||||
"name": "utils-bundle",
|
"name": "utils-bundle",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
|
||||||
"esbuild": "node build.js",
|
|
||||||
"build": "npm run esbuild",
|
|
||||||
"watch": "npm run esbuild -- --watch",
|
|
||||||
"generate-license": "node ../../../../utils/generate_third_party_notice.js"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"colors": "1.4.0",
|
"colors": "1.4.0",
|
||||||
"commander": "8.3.0",
|
"commander": "8.3.0",
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Microsoft Corporation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// @ts-check
|
|
||||||
const path = require('path');
|
|
||||||
const esbuild = require('esbuild');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean} watchMode
|
|
||||||
* @returns {import('esbuild').BuildOptions}
|
|
||||||
*/
|
|
||||||
function esbuildOptions(watchMode) {
|
|
||||||
return {
|
|
||||||
entryPoints: [path.join(__dirname, 'src/zipBundleImpl.ts')],
|
|
||||||
bundle: true,
|
|
||||||
outdir: path.join(__dirname, '../../lib'),
|
|
||||||
format: 'cjs',
|
|
||||||
platform: 'node',
|
|
||||||
target: 'ES2019',
|
|
||||||
sourcemap: watchMode,
|
|
||||||
minify: !watchMode,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
const watchMode = process.argv.includes('--watch');
|
|
||||||
const ctx = await esbuild.context(esbuildOptions(watchMode));
|
|
||||||
await ctx.rebuild();
|
|
||||||
if (watchMode)
|
|
||||||
await ctx.watch();
|
|
||||||
else
|
|
||||||
await ctx.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { esbuildOptions };
|
|
||||||
|
|
||||||
if (require.main === module)
|
|
||||||
main();
|
|
@ -2,12 +2,6 @@
|
|||||||
"name": "zip-bundle",
|
"name": "zip-bundle",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
|
||||||
"esbuild": "node build.js",
|
|
||||||
"build": "npm run esbuild",
|
|
||||||
"watch": "npm run esbuild -- --watch",
|
|
||||||
"generate-license": "node ../../../../utils/generate_third_party_notice.js"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"get-stream": "^5.1.0",
|
"get-stream": "^5.1.0",
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Microsoft Corporation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// @ts-check
|
|
||||||
const path = require('path');
|
|
||||||
const esbuild = require('esbuild');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean} watchMode
|
|
||||||
* @returns {import('esbuild').BuildOptions}
|
|
||||||
*/
|
|
||||||
function esbuildOptions(watchMode) {
|
|
||||||
return {
|
|
||||||
entryPoints: [path.join(__dirname, 'src/babelBundleImpl.ts')],
|
|
||||||
external: ['playwright'],
|
|
||||||
bundle: true,
|
|
||||||
outdir: path.join(__dirname, '../../lib/transform'),
|
|
||||||
format: 'cjs',
|
|
||||||
platform: 'node',
|
|
||||||
target: 'ES2019',
|
|
||||||
sourcemap: watchMode,
|
|
||||||
minify: !watchMode,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
const watchMode = process.argv.includes('--watch');
|
|
||||||
const ctx = await esbuild.context(esbuildOptions(watchMode));
|
|
||||||
await ctx.rebuild();
|
|
||||||
if (watchMode)
|
|
||||||
await ctx.watch();
|
|
||||||
else
|
|
||||||
await ctx.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { esbuildOptions };
|
|
||||||
|
|
||||||
if (require.main === module)
|
|
||||||
main();
|
|
@ -2,12 +2,6 @@
|
|||||||
"name": "babel-bundle",
|
"name": "babel-bundle",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
|
||||||
"esbuild": "node build.js",
|
|
||||||
"build": "npm run esbuild",
|
|
||||||
"watch": "npm run esbuild -- --watch",
|
|
||||||
"generate-license": "node ../../../../utils/generate_third_party_notice.js"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": "^7.26.2",
|
"@babel/code-frame": "^7.26.2",
|
||||||
"@babel/core": "^7.26.10",
|
"@babel/core": "^7.26.10",
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Microsoft Corporation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// @ts-check
|
|
||||||
const path = require('path');
|
|
||||||
const esbuild = require('esbuild');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean} watchMode
|
|
||||||
* @returns {import('esbuild').BuildOptions}
|
|
||||||
*/
|
|
||||||
function esbuildOptions(watchMode) {
|
|
||||||
return {
|
|
||||||
entryPoints: [path.join(__dirname, 'src/expectBundleImpl.ts')],
|
|
||||||
bundle: true,
|
|
||||||
outdir: path.join(__dirname, '../../lib/common'),
|
|
||||||
format: 'cjs',
|
|
||||||
platform: 'node',
|
|
||||||
target: 'ES2019',
|
|
||||||
sourcemap: watchMode,
|
|
||||||
minify: !watchMode,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
const watchMode = process.argv.includes('--watch');
|
|
||||||
const ctx = await esbuild.context(esbuildOptions(watchMode));
|
|
||||||
await ctx.rebuild();
|
|
||||||
if (watchMode)
|
|
||||||
await ctx.watch();
|
|
||||||
else
|
|
||||||
await ctx.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { esbuildOptions };
|
|
||||||
|
|
||||||
if (require.main === module)
|
|
||||||
main();
|
|
@ -2,12 +2,6 @@
|
|||||||
"name": "expect-bundle",
|
"name": "expect-bundle",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
|
||||||
"esbuild": "node build.js",
|
|
||||||
"build": "npm run esbuild",
|
|
||||||
"watch": "npm run esbuild -- --watch",
|
|
||||||
"generate-license": "node ../../../../utils/generate_third_party_notice.js"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jest/expect-utils": "29.7.0",
|
"@jest/expect-utils": "29.7.0",
|
||||||
"jest-get-type": "29.6.3",
|
"jest-get-type": "29.6.3",
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Microsoft Corporation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// @ts-check
|
|
||||||
const path = require('path');
|
|
||||||
const esbuild = require('esbuild');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean} watchMode
|
|
||||||
* @returns {import('esbuild').BuildOptions}
|
|
||||||
*/
|
|
||||||
function esbuildOptions(watchMode) {
|
|
||||||
return {
|
|
||||||
entryPoints: [path.join(__dirname, 'src/utilsBundleImpl.ts')],
|
|
||||||
external: ['fsevents'],
|
|
||||||
bundle: true,
|
|
||||||
outdir: path.join(__dirname, '../../lib'),
|
|
||||||
format: 'cjs',
|
|
||||||
platform: 'node',
|
|
||||||
target: 'ES2019',
|
|
||||||
sourcemap: watchMode,
|
|
||||||
minify: !watchMode,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
const watchMode = process.argv.includes('--watch');
|
|
||||||
const ctx = await esbuild.context(esbuildOptions(watchMode));
|
|
||||||
await ctx.rebuild();
|
|
||||||
if (watchMode)
|
|
||||||
await ctx.watch();
|
|
||||||
else
|
|
||||||
await ctx.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { esbuildOptions };
|
|
||||||
|
|
||||||
if (require.main === module)
|
|
||||||
main();
|
|
@ -2,12 +2,6 @@
|
|||||||
"name": "utils-bundle",
|
"name": "utils-bundle",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
|
||||||
"esbuild": "node build.js",
|
|
||||||
"build": "npm run esbuild",
|
|
||||||
"watch": "npm run esbuild -- --watch",
|
|
||||||
"generate-license": "node ../../../../utils/generate_third_party_notice.js"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chokidar": "3.6.0",
|
"chokidar": "3.6.0",
|
||||||
"enquirer": "2.3.6",
|
"enquirer": "2.3.6",
|
||||||
|
@ -228,16 +228,60 @@ function copyFile(file, from, to) {
|
|||||||
fs.copyFileSync(file, destination);
|
fs.copyFileSync(file, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {{
|
||||||
|
* modulePath: string,
|
||||||
|
* entryPoints: string[],
|
||||||
|
* external?: string[],
|
||||||
|
* outdir?: string,
|
||||||
|
* outfile?: string,
|
||||||
|
* minify?: boolean,
|
||||||
|
* }} BundleOptions
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {BundleOptions[]} */
|
||||||
const bundles = [];
|
const bundles = [];
|
||||||
for (const pkg of workspace.packages()) {
|
|
||||||
const bundlesDir = path.join(pkg.path, 'bundles');
|
bundles.push({
|
||||||
if (!fs.existsSync(bundlesDir))
|
modulePath: 'packages/playwright/bundles/babel',
|
||||||
continue;
|
outdir: 'packages/playwright/lib/transform',
|
||||||
for (const bundle of fs.readdirSync(bundlesDir)) {
|
entryPoints: ['src/babelBundleImpl.ts'],
|
||||||
if (fs.existsSync(path.join(bundlesDir, bundle, 'package.json')))
|
external: ['playwright'],
|
||||||
bundles.push(path.join(bundlesDir, bundle));
|
});
|
||||||
}
|
|
||||||
}
|
bundles.push({
|
||||||
|
modulePath: 'packages/playwright/bundles/expect',
|
||||||
|
outdir: 'packages/playwright/lib/common',
|
||||||
|
entryPoints: ['src/expectBundleImpl.ts'],
|
||||||
|
});
|
||||||
|
|
||||||
|
bundles.push({
|
||||||
|
modulePath: 'packages/playwright/bundles/utils',
|
||||||
|
outdir: 'packages/playwright/lib',
|
||||||
|
entryPoints: ['src/utilsBundleImpl.ts'],
|
||||||
|
external: ['fsevents'],
|
||||||
|
});
|
||||||
|
|
||||||
|
bundles.push({
|
||||||
|
modulePath: 'packages/playwright-core/bundles/utils',
|
||||||
|
outfile: 'packages/playwright-core/lib/utilsBundleImpl/index.js',
|
||||||
|
entryPoints: ['src/utilsBundleImpl.ts'],
|
||||||
|
});
|
||||||
|
|
||||||
|
bundles.push({
|
||||||
|
modulePath: 'packages/playwright-core/bundles/zip',
|
||||||
|
outdir: 'packages/playwright-core/lib',
|
||||||
|
entryPoints: ['src/zipBundleImpl.ts'],
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// @playwright/client
|
||||||
|
bundles.push({
|
||||||
|
modulePath: 'packages/playwright-client',
|
||||||
|
outdir: 'packages/playwright-client/lib',
|
||||||
|
entryPoints: ['src/index.ts'],
|
||||||
|
minify: false,
|
||||||
|
});
|
||||||
|
|
||||||
class GroupStep extends Step {
|
class GroupStep extends Step {
|
||||||
/** @param {Step[]} steps */
|
/** @param {Step[]} steps */
|
||||||
@ -269,11 +313,18 @@ updateSteps.push(new ProgramStep({
|
|||||||
|
|
||||||
// Update bundles.
|
// Update bundles.
|
||||||
for (const bundle of bundles) {
|
for (const bundle of bundles) {
|
||||||
|
// Do not update @playwright/client, it has not its own deps.
|
||||||
|
if (bundle.modulePath === 'packages/playwright-client')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const packageJson = path.join(filePath(bundle.modulePath), 'package.json');
|
||||||
|
if (!fs.existsSync(packageJson))
|
||||||
|
throw new Error(`${packageJson} does not exist`);
|
||||||
updateSteps.push(new ProgramStep({
|
updateSteps.push(new ProgramStep({
|
||||||
command: 'npm',
|
command: 'npm',
|
||||||
args: ['ci', '--save=false', '--fund=false', '--audit=false', '--omit=optional'],
|
args: ['ci', '--save=false', '--fund=false', '--audit=false', '--omit=optional'],
|
||||||
shell: true,
|
shell: true,
|
||||||
cwd: bundle,
|
cwd: filePath(bundle.modulePath),
|
||||||
concurrent: true,
|
concurrent: true,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -375,11 +426,9 @@ class CustomCallbackStep extends Step {
|
|||||||
for (const pkg of workspace.packages()) {
|
for (const pkg of workspace.packages()) {
|
||||||
if (!fs.existsSync(path.join(pkg.path, 'src')))
|
if (!fs.existsSync(path.join(pkg.path, 'src')))
|
||||||
continue;
|
continue;
|
||||||
// playwright-client has its own build step.
|
// playwright-client is built as a bundle.
|
||||||
if (['@playwright/client'].includes(pkg.name)) {
|
if (['@playwright/client'].includes(pkg.name))
|
||||||
loadBundleEsbuildStep(pkg.path);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
steps.push(new EsbuildStep({
|
steps.push(new EsbuildStep({
|
||||||
entryPoints: [path.join(pkg.path, 'src/**/*.ts')],
|
entryPoints: [path.join(pkg.path, 'src/**/*.ts')],
|
||||||
@ -390,18 +439,36 @@ for (const pkg of workspace.packages()) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build/watch bundles.
|
function copyXdgOpen() {
|
||||||
for (const bundle of bundles)
|
const outdir = filePath('packages/playwright-core/lib/utilsBundleImpl');
|
||||||
loadBundleEsbuildStep(bundle);
|
if (!fs.existsSync(outdir))
|
||||||
|
fs.mkdirSync(outdir, { recursive: true });
|
||||||
|
|
||||||
function loadBundleEsbuildStep(bundle) {
|
// 'open' package requires 'xdg-open' binary to be present, which does not get bundled by esbuild.
|
||||||
const buildFile = path.join(bundle, 'build.js');
|
fs.copyFileSync(filePath('packages/playwright-core/bundles/utils/node_modules/open/xdg-open'), path.join(outdir, 'xdg-open'));
|
||||||
if (!fs.existsSync(buildFile))
|
console.log('==== Copied xdg-open to', path.join(outdir, 'xdg-open'));
|
||||||
throw new Error(`Build file ${buildFile} does not exist`);
|
}
|
||||||
const { esbuildOptions, beforeEsbuild } = require(buildFile);
|
|
||||||
if (beforeEsbuild)
|
// Copy xdg-open after bundles 'npm ci' has finished.
|
||||||
steps.push(new CustomCallbackStep(beforeEsbuild));
|
steps.push(new CustomCallbackStep(copyXdgOpen));
|
||||||
const options = esbuildOptions(watchMode);
|
|
||||||
|
// Build/watch bundles.
|
||||||
|
for (const bundle of bundles) {
|
||||||
|
/** @type {import('esbuild').BuildOptions} */
|
||||||
|
const options = {
|
||||||
|
bundle: true,
|
||||||
|
format: 'cjs',
|
||||||
|
platform: 'node',
|
||||||
|
target: 'ES2019',
|
||||||
|
sourcemap: watchMode,
|
||||||
|
minify: !watchMode,
|
||||||
|
|
||||||
|
entryPoints: bundle.entryPoints.map(e => path.join(filePath(bundle.modulePath), e)),
|
||||||
|
...(bundle.outdir ? { outdir: filePath(bundle.outdir) } : {}),
|
||||||
|
...(bundle.outfile ? { outfile: filePath(bundle.outfile) } : {}),
|
||||||
|
...(bundle.external ? { external: bundle.external } : {}),
|
||||||
|
...(bundle.minify !== undefined ? { minify: bundle.minify } : {}),
|
||||||
|
};
|
||||||
steps.push(new EsbuildStep(options));
|
steps.push(new EsbuildStep(options));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user