Skip to content

Commit 79db581

Browse files
refactor: use importNodeModule directly with caching protection
Now that import caching prevents infinite recursion, we can use the proper importNodeModule function instead of the workaround in vm.Script importModuleDynamically fallback. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent cad05e6 commit 79db581

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

packages/node/src/runtimePlugin.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,7 @@ export const loadFromFs = (
120120
filename,
121121
importModuleDynamically:
122122
//@ts-ignore
123-
vm.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER ??
124-
((specifier: string) => {
125-
// Use direct dynamic import to avoid recursion
126-
const dynamicImport = new Function(
127-
'specifier',
128-
'return import(specifier)',
129-
);
130-
return dynamicImport(specifier);
131-
}),
123+
vm.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER ?? importNodeModule,
132124
},
133125
);
134126
script.runInThisContext()(

0 commit comments

Comments
 (0)