Files
NapCatQQ/.pnpm-store/v3/files/a2/078a3e5debd53f856035b45fad2560f9a2861e01970347e48a30442200212d96bc1963da2edf7383b7bd4876278fecc401d1dc517d643ff9e461ebefc1fe96
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

30 lines
1.1 KiB
Plaintext

import { isBuiltin } from 'node:module';
import path from 'node:path';
import { ResolverFactory } from 'unrs-resolver';
export function createNodeResolver({ extensions = ['.mjs', '.cjs', '.js', '.json', '.node'], conditionNames = ['import', 'require', 'default'], mainFields = ['module', 'main'], ...restOptions } = {}) {
const resolver = new ResolverFactory({
extensions,
conditionNames,
mainFields,
...restOptions,
});
return {
interfaceVersion: 3,
name: 'eslint-plugin-import-x:node',
resolve(modulePath, sourceFile) {
if (isBuiltin(modulePath) || modulePath.startsWith('data:')) {
return { found: true, path: null };
}
try {
const resolved = resolver.sync(path.dirname(sourceFile), modulePath);
if (resolved.path) {
return { found: true, path: resolved.path };
}
}
catch {
}
return { found: false };
},
};
}
//# sourceMappingURL=node-resolver.js.map