node/test/parallel/test-shadow-realm-preload-module.js
Chengzhong Wu fc2862b7f5
module: bootstrap module loaders in shadow realm
This bootstraps ESM loaders in the ShadowRealm with
`ShadowRealm.prototype.importValue` as its entry point and enables
loading ESM and CJS modules in the ShadowRealm. The module is imported
without a parent URL and resolved with the current process's working
directory.

PR-URL: https://github.com/nodejs/node/pull/48655
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2023-11-13 22:09:47 +08:00

21 lines
591 B
JavaScript

'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
const { spawnSyncAndExitWithoutError } = require('../common/child_process');
const commonArgs = [
'--experimental-shadow-realm',
];
async function main() {
// Verifies that --require preload modules are not enabled in the ShadowRealm.
spawnSyncAndExitWithoutError(process.execPath, [
...commonArgs,
'--require',
fixtures.path('es-module-shadow-realm', 'preload.js'),
fixtures.path('es-module-shadow-realm', 'preload-main.js'),
]);
}
main().then(common.mustCall());