1import assert from 'node:assert';
2
3// a loader that asserts that the defaultResolve will throw "not found"
4// (skipping the top-level main of course)
5let mainLoad = true;
6export async function resolve(specifier, { importAttributes }, next) {
7  if (mainLoad) {
8    mainLoad = false;
9    return next(specifier);
10  }
11  try {
12    await next(specifier);
13  }
14  catch (e) {
15    assert.strictEqual(e.code, 'ERR_MODULE_NOT_FOUND');
16    return {
17      url: 'node:fs',
18      importAttributes,
19    };
20  }
21  assert.fail(`Module resolution for ${specifier} should be throw ERR_MODULE_NOT_FOUND`);
22}
23