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

Function circular2

test/parallel/test-vm-module-link.js:102–141  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

100}
101
102async function circular2() {
103 const sourceMap = {
104 'root': `
105 import * as a from './a.mjs';
106 import * as b from './b.mjs';
107 if (!('fromA' in a))
108 throw new Error();
109 if (!('fromB' in a))
110 throw new Error();
111 if (!('fromA' in b))
112 throw new Error();
113 if (!('fromB' in b))
114 throw new Error();
115 `,
116 './a.mjs': `
117 export * from './b.mjs';
118 export let fromA;
119 `,
120 './b.mjs': `
121 export * from './a.mjs';
122 export let fromB;
123 `
124 };
125 const moduleMap = new Map();
126 const rootModule = new SourceTextModule(sourceMap.root, {
127 identifier: 'vm:root',
128 });
129 async function link(specifier, referencingModule) {
130 if (moduleMap.has(specifier)) {
131 return moduleMap.get(specifier);
132 }
133 const mod = new SourceTextModule(sourceMap[specifier], {
134 identifier: new URL(specifier, 'file:///').href,
135 });
136 moduleMap.set(specifier, mod);
137 return mod;
138 }
139 await rootModule.link(link);
140 await rootModule.evaluate();
141}
142
143async function asserts() {
144 const m = new SourceTextModule(`

Callers 1

Calls 2

linkMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…