2022-07-29 16:42:55 +08:00
|
|
|
import assert from 'node:assert';
|
2017-10-11 21:45:21 +08:00
|
|
|
|
2023-08-13 12:23:05 +08:00
|
|
|
// A loader that asserts that the defaultResolve will throw "not found"
|
2023-10-14 11:52:38 +08:00
|
|
|
export async function resolve(specifier, { importAttributes }, next) {
|
2024-05-08 10:20:48 +08:00
|
|
|
if (specifier.startsWith('./not-found')) {
|
|
|
|
await assert.rejects(next(specifier), { code: 'ERR_MODULE_NOT_FOUND' });
|
|
|
|
return {
|
|
|
|
url: 'node:fs',
|
|
|
|
importAttributes,
|
|
|
|
};
|
2017-10-11 21:45:21 +08:00
|
|
|
}
|
2024-05-08 10:20:48 +08:00
|
|
|
return next(specifier);
|
2017-10-11 21:45:21 +08:00
|
|
|
}
|