diff --git a/utils/build/build.js b/utils/build/build.js index b0079079f1..11f74d5283 100644 --- a/utils/build/build.js +++ b/utils/build/build.js @@ -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,