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

Method runSync

lib/internal/modules/esm/module_job.js:532–557  ·  view source on GitHub ↗
(parent)

Source from the content-addressed store, hash-verified

530 }
531
532 runSync(parent) {
533 debug('ModuleJobSync.runSync()', this.module);
534 assert(this.shouldRunModule(this.phase));
535 // TODO(joyeecheung): add the error decoration logic from the async instantiate.
536 this.module.instantiate();
537 // If --experimental-print-required-tla is true, proceeds to evaluation even
538 // if it's async because we want to search for the TLA and help users locate
539 // them.
540 // TODO(joyeecheung): track the asynchroniticy using v8::Module::HasTopLevelAwait()
541 // and we'll be able to throw right after compilation of the modules, using acron
542 // to find and print the TLA. This requires the linking to be synchronous in case
543 // it runs into cached asynchronous modules that are not yet fetched.
544 const parentFilename = urlToFilename(parent?.filename);
545 const filename = urlToFilename(this.url);
546 if (this.module.hasAsyncGraph && !getOptionValue('--experimental-print-required-tla')) {
547 throw new ERR_REQUIRE_ASYNC_MODULE(filename, parentFilename);
548 }
549 setHasStartedUserESMExecution();
550 try {
551 const namespace = this.module.evaluateSync(filename, parentFilename);
552 return { __proto__: null, module: this.module, namespace };
553 } catch (e) {
554 explainCommonJSGlobalLikeNotDefinedError(e, this.module.url, this.module.hasTopLevelAwait);
555 throw e;
556 }
557 }
558}
559
560ObjectSetPrototypeOf(ModuleJobBase.prototype, null);

Callers

nothing calls this directly

Calls 8

urlToFilenameFunction · 0.85
getOptionValueFunction · 0.85
shouldRunModuleMethod · 0.80
debugFunction · 0.50
assertFunction · 0.50
instantiateMethod · 0.45

Tested by

no test coverage detected