Skip to content

Commit 758aaf1

Browse files
authored
fix: pnp loader path on Windows (#126)
1 parent 644cd74 commit 758aaf1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.changeset/pnp-loader-windows-path.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"synckit": patch
3+
---
4+
5+
fix: pnp loader path on Windows
6+

src/index.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,11 @@ const setupTsRunner = (
249249
execArgv = ['-r', pnpApiPath, ...execArgv]
250250
const pnpLoaderPath = path.resolve(pnpApiPath, '../.pnp.loader.mjs')
251251
if (isFile(pnpLoaderPath)) {
252-
execArgv = ['--experimental-loader', pnpLoaderPath, ...execArgv]
252+
// Transform path to file URL because nodejs does not accept
253+
// absolute Windows paths in the --experimental-loader option.
254+
// https://github.com/un-ts/synckit/issues/123
255+
const experimentalLoader = pathToFileURL(pnpLoaderPath).toString()
256+
execArgv = ['--experimental-loader', experimentalLoader, ...execArgv]
253257
}
254258
}
255259
}

0 commit comments

Comments
 (0)