From 8ed956e496e5ed1a50ce32df40ea442a6cb568ee Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Thu, 15 Jun 2023 20:16:47 +0200 Subject: [PATCH] chore: move pw-core utilsBundleImpl into own directory (#23706) https://github.com/microsoft/playwright/issues/23666 --- packages/playwright-core/.npmignore | 2 +- packages/playwright-core/bundles/utils/build.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/playwright-core/.npmignore b/packages/playwright-core/.npmignore index c13cb082548c1..a7d6253b8f9c8 100644 --- a/packages/playwright-core/.npmignore +++ b/packages/playwright-core/.npmignore @@ -9,7 +9,7 @@ !lib/**/*.html !lib/**/*.png !lib/**/*.ttf -!lib/xdg-open +!lib/utilsBundleImpl/xdg-open # Exclude injected files. A preprocessed version of these is included via lib/generated. # See src/server/injected/README.md. lib/**/injected/ diff --git a/packages/playwright-core/bundles/utils/build.js b/packages/playwright-core/bundles/utils/build.js index ac8f8c6c00012..3135ac858ebcf 100644 --- a/packages/playwright-core/bundles/utils/build.js +++ b/packages/playwright-core/bundles/utils/build.js @@ -19,15 +19,20 @@ const path = require('path'); const esbuild = require('esbuild'); const fs = require('fs'); +const outdir = path.join(__dirname, '../../lib/utilsBundleImpl'); + +if (!fs.existsSync(outdir)) + fs.mkdirSync(outdir); + { - // 'open' package requires 'xdg-open' script to be present, which does not get bundled by esbuild. - fs.copyFileSync(path.join(__dirname, 'node_modules/open/xdg-open'), path.join(__dirname, '../../lib/xdg-open')); + // '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')); } esbuild.build({ entryPoints: [path.join(__dirname, 'src/utilsBundleImpl.ts')], bundle: true, - outdir: path.join(__dirname, '../../lib'), + outfile: path.join(outdir, 'index.js'), format: 'cjs', platform: 'node', target: 'ES2019',