1import { spawnPromisified } from '../common/index.mjs'; 2import * as fixtures from '../common/fixtures.mjs'; 3import assert from 'node:assert'; 4import { execPath } from 'node:process'; 5import { describe, it } from 'node:test'; 6 7 8describe('ESM: ensure initialization happens only once', { concurrency: true }, () => { 9 it(async () => { 10 const { code, stderr, stdout } = await spawnPromisified(execPath, [ 11 '--experimental-import-meta-resolve', 12 '--loader', 13 fixtures.fileURL('es-module-loaders', 'loader-resolve-passthru.mjs'), 14 '--no-warnings', 15 fixtures.path('es-modules', 'runmain.mjs'), 16 ]); 17 18 assert.strictEqual(stderr, ''); 19 /** 20 * resolveHookRunCount = 2: 21 * 1. fixtures/…/runmain.mjs 22 * 2. node:module (imported by fixtures/…/runmain.mjs) 23 * 3. doesnt-matter.mjs (first import.meta.resolve call) 24 * 4. fixtures/…/runmain.mjs (entry point) 25 * 5. doesnt-matter.mjs (second import.meta.resolve call) 26 */ 27 assert.strictEqual(stdout.match(/resolve passthru/g)?.length, 5); 28 assert.strictEqual(code, 0); 29 }); 30}); 31