Skip to content

Commit f69e51d

Browse files
fix: restore preferred use of vm.constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
Prefer using vm.constants.USE_MAIN_CONTEXT_DEFAULT_LOADER when available, fallback to cached importNodeModule to prevent recursion. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c3824be commit f69e51d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/node/src/runtimePlugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ export const loadFromFs = (
118118
`(function(exports, require, __dirname, __filename) {${content}\n})`,
119119
{
120120
filename,
121-
importModuleDynamically: importNodeModule,
121+
importModuleDynamically:
122+
//@ts-ignore
123+
vm.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER ?? importNodeModule,
122124
},
123125
);
124126
script.runInThisContext()(

packages/sdk/src/node.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ export const createScriptNode =
115115
`(function(exports, module, require, __dirname, __filename) {${data}\n})`,
116116
{
117117
filename,
118-
importModuleDynamically: importNodeModule,
118+
importModuleDynamically:
119+
//@ts-ignore
120+
vm.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER ??
121+
importNodeModule,
119122
},
120123
);
121124

0 commit comments

Comments
 (0)