-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
factory.js
35 lines (31 loc) · 895 Bytes
/
factory.js
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
28
29
30
31
32
33
34
35
import { ResolverFactory as ResolverFactoryBase } from 'oxc-resolver';
/** @type {Partial<import('./interface.js').ResolveOptions>} */
const defaultOptions = {
preferAbsolute: true,
fullySpecified: false,
mainFields: ['main', 'module', 'browser'],
extensions: ['.ts', '.js', '.d.ts', '.html', '.md', '.json']
};
export default class ResolverFactory extends ResolverFactoryBase {
static createResolver(
/** @type {import('oxc-resolver').NapiResolveOptions} */ opts = {}
) {
return new ResolverFactory(opts);
}
constructor(
/** @type {import('oxc-resolver').NapiResolveOptions} */ props = {}
) {
super({
roots: [process.cwd()],
...defaultOptions,
...props
});
}
resolveSync(
/** @type {unknown} */ _,
/** @type {string} */ path,
/** @type {string} */ request
) {
return this.sync(path, request).path ?? null;
}
}