Skip to content

Commit e9cf792

Browse files
committed
Don't use VM module loading if the VM module loading is not enabled
1 parent ab3f2dc commit e9cf792

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

security/jsLoader.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ export async function scopedImport(filePath: string | URL, scope?: ApplicationSc
8989
if (!scope.compartment) scope.compartment = getCompartment(scope, globals);
9090
const result = await (await scope.compartment).import(moduleUrl);
9191
return result.namespace;
92-
} // else use standard node:vm module to do containment
93-
return await loadModuleWithVM(moduleUrl, scope);
94-
} else {
95-
// important! we need to await the import, otherwise the error will not be caught
96-
return await import(moduleUrl);
92+
} else if (SourceTextModule) {
93+
// else use standard node:vm module to do containment (if it is available)
94+
return await loadModuleWithVM(moduleUrl, scope);
95+
}
9796
}
97+
// important! we need to await the import, otherwise the error will not be caught
98+
return await import(moduleUrl);
9899
} catch (err) {
99100
try {
100101
// the actual parse error (internally known as the "arrow message")

0 commit comments

Comments
 (0)