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

Function main

benchmark/esm/detect-esm-syntax.js:14–36  ·  view source on GitHub ↗
({ n, type })

Source from the content-addressed store, hash-verified

12});
13
14async function main({ n, type }) {
15 tmpdir.refresh();
16 fs.mkdirSync(tmpdir.resolve('bench'));
17
18 let loader = '';
19 const modules = [];
20 for (let i = 0; i < n; i++) {
21 const url = tmpdir.fileURL('bench', `mod${i}.js`);
22 fs.writeFileSync(url, `const foo${i} = ${i};\nexport { foo${i} };\n`);
23 loader += `import { foo${i} } from './mod${i}.js';\n`;
24 modules.push(url);
25 }
26 const loaderURL = tmpdir.fileURL('bench', 'load.js');
27 fs.writeFileSync(loaderURL, loader);
28
29 if (type === 'with-package-json') {
30 fs.writeFileSync(tmpdir.resolve('bench', 'package.json'), '{ "type": "module" }');
31 }
32
33 bench.start();
34 await import(loaderURL);
35 bench.end(n);
36}

Callers

nothing calls this directly

Calls 7

refreshMethod · 0.45
mkdirSyncMethod · 0.45
resolveMethod · 0.45
writeFileSyncMethod · 0.45
pushMethod · 0.45
startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…