Skip to content

Commit ee385b9

Browse files
committed
fix: ESM module resolution works for PI, remove debug logs
1 parent 81e91c1 commit ee385b9

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packages/nodejs/src/execution-driver.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,12 @@ export class NodeExecutionDriver implements RuntimeDriver {
10351035
options.code,
10361036
options.filePath,
10371037
);
1038+
// For ESM entry scripts, wrap in a CJS dynamic import() launcher instead
1039+
// of using V8's native ESM "run" mode. The native ESM module resolver in
1040+
// the V8 isolate doesn't resolve non-builtin packages (undici, chalk, etc.)
1041+
// through the bridge. Dynamic import() in CJS mode goes through the
1042+
// require-setup's __dynamicImportHandler which uses _requireFrom and
1043+
// properly resolves packages via the bridge.
10381044
const sessionMode = options.mode === "run" || entryIsEsm ? "run" : "exec";
10391045
const userCode = entryIsEsm
10401046
? options.code

0 commit comments

Comments
 (0)