Skip to content

Commit e71e259

Browse files
authored
Bugfix: fix URL path for childProcess.fork when using Pleasantest from ESM (#726)
1 parent bcb0851 commit e71e259

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

.changeset/calm-windows-retire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'pleasantest': minor
3+
---
4+
5+
Fix fork URL for ESM use

rollup.config.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,6 @@ function bundlePlugin() {
9191

9292
return resolved;
9393
},
94-
resolveFileUrl({ relativePath, format }) {
95-
return format === 'es'
96-
? `new URL('${relativePath}', import.meta.url).href`
97-
: `require('path').join(__dirname,'${relativePath}')`;
98-
},
99-
resolveImportMeta(property, { format }) {
100-
if (property === 'url' && format === 'cjs') {
101-
// eslint-disable-next-line no-template-curly-in-string
102-
return '`file://${__filename}`';
103-
}
104-
105-
return null;
106-
},
10794
async load(id) {
10895
if (!id.startsWith('\0bundle:')) return;
10996
id = id.slice(8);

src/connect-to-browser.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,13 @@ export const connectToBrowser = async (
111111
return connectedBrowser;
112112
}
113113

114-
const subprocess = childProcess.fork(startDisownedBrowserPath, {
115-
detached: true,
116-
stdio: 'ignore',
117-
});
114+
const subprocess = childProcess.fork(
115+
fileURLToPath(startDisownedBrowserPath),
116+
{
117+
detached: true,
118+
stdio: 'ignore',
119+
},
120+
);
118121
const wsEndpoint = await new Promise<string>((resolve, reject) => {
119122
subprocess.send({ browser, headless });
120123
subprocess.on('message', (msg: any) => {

0 commit comments

Comments
 (0)