chore: support npm run build -- --sourcemap (#24529)

This commit is contained in:
Dmitry Gozman 2023-07-31 13:53:28 -07:00 committed by GitHub
parent 786cb4019d
commit 57ab732fb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -62,6 +62,7 @@ const copyFiles = [];
const watchMode = process.argv.slice(2).includes('--watch');
const lintMode = process.argv.slice(2).includes('--lint');
const withSourceMaps = process.argv.slice(2).includes('--sourcemap') || watchMode;
const ROOT = path.join(__dirname, '..', '..');
/**
@ -238,11 +239,13 @@ for (const pkg of workspace.packages()) {
command: 'npx',
args: [
'babel',
...(watchMode ? ['-w', '--source-maps'] : []),
...(watchMode ? ['-w'] : []),
...(withSourceMaps ? ['--source-maps'] : []),
'--extensions', '.ts',
'--out-dir', quotePath(path.join(pkg.path, 'lib')),
'--ignore', '"packages/playwright-core/src/server/injected/**/*"',
quotePath(path.join(pkg.path, 'src'))],
quotePath(path.join(pkg.path, 'src')),
],
shell: true,
concurrent: true,
});
@ -252,7 +255,11 @@ for (const pkg of workspace.packages()) {
for (const bundle of bundles) {
steps.push({
command: 'npm',
args: ['run', watchMode ? 'watch' : 'build'],
args: [
'run',
watchMode ? 'watch' : 'build',
...(withSourceMaps ? ['--', '--sourcemap'] : [])
],
shell: true,
cwd: bundle,
concurrent: true,
@ -263,7 +270,12 @@ for (const bundle of bundles) {
for (const webPackage of ['html-reporter', 'recorder', 'trace-viewer']) {
steps.push({
command: 'npx',
args: ['vite', 'build', ...(watchMode ? ['--watch', '--sourcemap', '--minify=false'] : [])],
args: [
'vite',
'build',
...(watchMode ? ['--watch', '--minify=false'] : []),
...(withSourceMaps ? ['--sourcemap'] : []),
],
shell: true,
cwd: path.join(__dirname, '..', '..', 'packages', webPackage),
concurrent: true,
@ -272,7 +284,14 @@ for (const webPackage of ['html-reporter', 'recorder', 'trace-viewer']) {
// Build/watch trace viewer service worker.
steps.push({
command: 'npx',
args: ['vite', '--config', 'vite.sw.config.ts', 'build', ...(watchMode ? ['--watch', '--sourcemap', '--minify=false'] : [])],
args: [
'vite',
'--config',
'vite.sw.config.ts',
'build',
...(watchMode ? ['--watch', '--minify=false'] : []),
...(withSourceMaps ? ['--sourcemap'] : []),
],
shell: true,
cwd: path.join(__dirname, '..', '..', 'packages', 'trace-viewer'),
concurrent: true,