Skip to content

Commit 4fb10bd

Browse files
authored
fix: fix PnP ESM loader integration (#255)
1 parent 7604672 commit 4fb10bd

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

.changeset/honest-forks-juggle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"synckit": patch
3+
---
4+
5+
Fix PnP ESM support

src/helpers.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
INT32_BYTES,
2525
LOADER_FLAG,
2626
LOADER_FLAGS,
27-
MODULE_REGISTER_SUPPORTED,
2827
MTS_SUPPORTED,
2928
NO_STRIP_TYPES,
3029
NO_STRIP_TYPES_FLAG,
@@ -313,9 +312,7 @@ export const setupTsRunner = (
313312
// absolute Windows paths in the --experimental-loader option.
314313
// https://github.com/un-ts/synckit/issues/123
315314
resolvedPnpLoaderPath = pathToFileURL(pnpLoaderPath).href
316-
if (!MODULE_REGISTER_SUPPORTED) {
317-
execArgv = [LOADER_FLAG, resolvedPnpLoaderPath, ...execArgv]
318-
}
315+
execArgv = [LOADER_FLAG, resolvedPnpLoaderPath, ...execArgv]
319316
}
320317
}
321318
}

src/index.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import module from 'node:module'
21
import path from 'node:path'
32
import { fileURLToPath } from 'node:url'
43
import {
@@ -7,7 +6,6 @@ import {
76
workerData,
87
} from 'node:worker_threads'
98

10-
import { MODULE_REGISTER_SUPPORTED } from './constants.js'
119
import {
1210
extractProperties,
1311
overrideStdio,
@@ -107,12 +105,7 @@ export function runAsWorker<T extends AnyFn<Promise<R> | R>, R = ReturnType<T>>(
107105

108106
overrideStdio(stdio)
109107

110-
const { workerPort, sharedBufferView, pnpLoaderPath } =
111-
workerData as WorkerData
112-
113-
if (pnpLoaderPath && MODULE_REGISTER_SUPPORTED) {
114-
module.register(pnpLoaderPath)
115-
}
108+
const { workerPort, sharedBufferView } = workerData as WorkerData
116109

117110
parentPort!.on(
118111
'message',

0 commit comments

Comments
 (0)