• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import assert from '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, { parentURL }, defaultResolve) {
7  if (mainLoad) {
8    mainLoad = false;
9    return defaultResolve(specifier, {parentURL}, defaultResolve);
10  }
11  try {
12    await defaultResolve(specifier, {parentURL}, defaultResolve);
13  }
14  catch (e) {
15    assert.strictEqual(e.code, 'ERR_MODULE_NOT_FOUND');
16    return {
17      url: 'node:fs'
18    };
19  }
20  assert.fail(`Module resolution for ${specifier} should be throw ERR_MODULE_NOT_FOUND`);
21}
22