diff --git a/.changeset/calm-windows-retire.md b/.changeset/calm-windows-retire.md new file mode 100644 index 00000000..90cfd37d --- /dev/null +++ b/.changeset/calm-windows-retire.md @@ -0,0 +1,5 @@ +--- +'pleasantest': minor +--- + +Fix fork URL for ESM use diff --git a/rollup.config.js b/rollup.config.js index 3173c88b..83d46424 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -91,19 +91,6 @@ function bundlePlugin() { return resolved; }, - resolveFileUrl({ relativePath, format }) { - return format === 'es' - ? `new URL('${relativePath}', import.meta.url).href` - : `require('path').join(__dirname,'${relativePath}')`; - }, - resolveImportMeta(property, { format }) { - if (property === 'url' && format === 'cjs') { - // eslint-disable-next-line no-template-curly-in-string - return '`file://${__filename}`'; - } - - return null; - }, async load(id) { if (!id.startsWith('\0bundle:')) return; id = id.slice(8); diff --git a/src/connect-to-browser.ts b/src/connect-to-browser.ts index acff571c..3be12be5 100644 --- a/src/connect-to-browser.ts +++ b/src/connect-to-browser.ts @@ -111,10 +111,13 @@ export const connectToBrowser = async ( return connectedBrowser; } - const subprocess = childProcess.fork(startDisownedBrowserPath, { - detached: true, - stdio: 'ignore', - }); + const subprocess = childProcess.fork( + fileURLToPath(startDisownedBrowserPath), + { + detached: true, + stdio: 'ignore', + }, + ); const wsEndpoint = await new Promise((resolve, reject) => { subprocess.send({ browser, headless }); subprocess.on('message', (msg: any) => {