node/test/fixtures/es-module-loaders/byop-dummy-loader.mjs
Gil Tayar ccada8bccc
module: change default resolver to not throw on unknown scheme
Fixes https://github.com/nodejs/loaders/issues/138

PR-URL: https://github.com/nodejs/node/pull/47824
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-05-19 15:50:50 +00:00

31 lines
746 B
JavaScript

export function load(url, context, nextLoad) {
switch (url) {
case 'byop://1/index.mjs':
return {
source: 'console.log("index.mjs!")',
format: 'module',
shortCircuit: true,
};
case 'byop://1/index2.mjs':
return {
source: 'import c from "./sub.mjs"; console.log(c);',
format: 'module',
shortCircuit: true,
};
case 'byop://1/sub.mjs':
return {
source: 'export default 42',
format: 'module',
shortCircuit: true,
};
case 'byop://1/index.byoe':
return {
source: 'console.log("index.byoe!")',
format: 'module',
shortCircuit: true,
};
default:
return nextLoad(url, context);
}
}