-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathloader.mjs
More file actions
27 lines (21 loc) · 713 Bytes
/
loader.mjs
File metadata and controls
27 lines (21 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { pathToFileURL } from 'url';
import "./register.js"
const baseURL = pathToFileURL(process.cwd() + '/').href;
const extensionsRegex = /\.jadelet$/;
export async function resolve(specifier, context, defaultResolve) {
const { parentURL = baseURL } = context;
if (extensionsRegex.test(specifier)) {
return {
url: new URL(specifier, parentURL).href
};
}
// Let Node.js handle all other specifiers.
return defaultResolve(specifier, context, defaultResolve);
}
export async function load(url, context, defaultLoad) {
if (extensionsRegex.test(url)) {
return { format: "commonjs" };
}
// Let Node.js handle all other URLs.
return defaultLoad(url, context, defaultLoad);
}