MCPcopy Index your code
hub / github.com/nodejs/node / prepareShadowRealmExecution

Function prepareShadowRealmExecution

lib/internal/process/pre_execution.js:77–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75}
76
77function prepareShadowRealmExecution() {
78 // Patch the process object with legacy properties and normalizations.
79 // Do not expand argv1 as it is not available in ShadowRealm.
80 patchProcessObject(false);
81 setupDebugEnv();
82
83 // Disable custom loaders in ShadowRealm.
84 initializeModuleLoaders({ shouldSpawnLoaderHookWorker: false, shouldPreloadModules: false });
85 const {
86 privateSymbols: {
87 host_defined_option_symbol,
88 },
89 } = internalBinding('util');
90 const {
91 vm_dynamic_import_default_internal,
92 } = internalBinding('symbols');
93
94 // For ShadowRealm.prototype.importValue(), the referrer name is
95 // always null, so the native ImportModuleDynamically() callback would
96 // always fallback to look up the host-defined option from the
97 // global object using host_defined_option_symbol. Using
98 // vm_dynamic_import_default_internal as the host-defined option
99 // instructs the JS-land importModuleDynamicallyCallback() to
100 // proxy the request to defaultImportModuleDynamically().
101 globalThis[host_defined_option_symbol] =
102 vm_dynamic_import_default_internal;
103}
104
105function prepareExecution(options) {
106 const { expandArgv1, initializeModules, isMainThread, shouldSpawnLoaderHookWorker, shouldPreloadModules } = options;

Callers 1

shadow_realm.jsFile · 0.85

Calls 3

patchProcessObjectFunction · 0.85
setupDebugEnvFunction · 0.85
initializeModuleLoadersFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…