MCPcopy
hub / github.com/webpack/webpack / createImportModuleDynamically

Function createImportModuleDynamically

test/test262.spectest.js:636–663  ·  view source on GitHub ↗
(context, testFile, moduleCache)

Source from the content-addressed store, hash-verified

634
635const createImportModuleDynamically =
636 (context, testFile, moduleCache) => async (specifier, referencing) => {
637 const identifier = referencing.identifier
638 ? path.resolve(path.dirname(referencing.identifier), specifier)
639 : path.resolve(path.dirname(testFile), specifier);
640
641 if (moduleCache.has(identifier)) {
642 return moduleCache.get(identifier);
643 }
644
645 const code = await outputFileSystem.promises.readFile(identifier, "utf8");
646 const module = new vm.SourceTextModule(code, {
647 context,
648 identifier,
649 importModuleDynamically: createImportModuleDynamically(
650 context,
651 testFile,
652 moduleCache
653 )
654 });
655
656 moduleCache.set(identifier, module);
657
658 await module.link(
659 createImportModuleDynamically(context, testFile, moduleCache)
660 );
661
662 return module;
663 };
664
665const runModule = async (context, code, identifier, testFile, moduleCache) => {
666 const module = new vm.SourceTextModule(code, {

Callers 2

runModuleFunction · 0.85
runScriptFunction · 0.85

Calls 6

readFileMethod · 0.80
linkMethod · 0.80
resolveMethod · 0.65
hasMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected