1import { writeSync } from 'node:fs';
2
3
4export async function resolve(specifier, context, next) {
5  // This check is needed to make sure that we don't prevent the
6  // resolution from follow-up loaders. It wouldn't be a problem
7  // in real life because loaders aren't supposed to break the
8  // resolution, but the ones used in our tests do, for convenience.
9  if (specifier === 'node:fs' || specifier.includes('loader')) {
10    return next(specifier);
11  }
12
13  writeSync(1, 'resolve 42' + '\n'); // Signal that this specific hook ran
14  writeSync(1, `next<HookName>: ${next.name}\n`); // Expose actual value the hook was called with
15
16  return next('file:///42.mjs');
17}
18