Reproduction link or steps
import { defineConfig } from "tsdown";
export default defineConfig({
entry: "index.ts",
fixedExtension: false,
format: {
esm: {
outDir: "esm/",
},
cjs: {
outDir: "cjs/",
},
},
});
package.json:
{
"exports": {
".": {
"import": {
"default": "./esm/index.js",
"types": "./esm/index.d.ts"
},
"require": {
"default": "./cjs/index.cjs",
"types": "./cjs/index.d.cts"
}
}
}
}
What is expected?
The construct above should be enough for tsdown to generate types.
What is actually happening?
Types are not generated, since it only looks for types or typings at the top level.
Any additional comments?
One subtlety: if the "." entry contains a "types" field, but the "require" entry does not contain a "types" field, the types should be generated for one module but not the other. Tricky tricky.
Reproduction link or steps
package.json:{ "exports": { ".": { "import": { "default": "./esm/index.js", "types": "./esm/index.d.ts" }, "require": { "default": "./cjs/index.cjs", "types": "./cjs/index.d.cts" } } } }What is expected?
The construct above should be enough for tsdown to generate types.
What is actually happening?
Types are not generated, since it only looks for
typesortypingsat the top level.Any additional comments?
One subtlety: if the
"."entry contains a "types" field, but the"require"entry does not contain a "types" field, the types should be generated for one module but not the other. Tricky tricky.