Run the following code:
import { ResolverFactory } from "oxc-resolver";
const resolver = new ResolverFactory({
mainFields: ["types", "typings", "module", "main"],
conditionNames: ["types", "typings", "import", "require"],
extensions: [
".d.ts",
".d.mts",
".d.cts",
".ts",
".mts",
".cts",
".tsx",
".js",
".mjs",
".cjs",
".jsx",
],
});
const currentFile = import.meta.filename;
console.log("Current file:", currentFile);
for (const pkg of ["magic-string"]) {
const resolved = resolver.resolveDtsSync(currentFile, pkg);
console.log(`Resolved ${pkg} to`, resolved.path);
}
Output:
Resolved magic-string to /..../node_modules/magic-string/dist/magic-string.es.mjs
It should resolve to dist/magic-string.cjs.d.ts as magic-string/package.json's types field.
Full reproduction: https://github.com/issueset/oxc-resolver-dts-issue.git
Run the following code:
Output:
It should resolve to
dist/magic-string.cjs.d.tsasmagic-string/package.json'stypesfield.Full reproduction: https://github.com/issueset/oxc-resolver-dts-issue.git