Auto Exports
tship can automatically maintain the exports, typesVersions, and classic fields (main, module, types) in your package.json.
Enabling
{
"tship": {
"autoExports": {
"generate": true,
"typesVersions": true
}
}
}Generated Output
{
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/esm/index.d.ts",
"exports": {
".": {
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"types": {
"require": "./dist/cjs/index.d.ts",
"import": "./dist/esm/index.d.ts"
}
}
},
"typesVersions": {
"*": {
"d.cts": ["./dist/cjs/index.d.ts"],
"d.mts": ["./dist/esm/index.d.ts"]
}
}
}mainpoints to the CJS entry for older Node.js and bundlers that only read this field.modulepoints to the ESM entry for modern bundlers (Webpack, Rollup, Vite).typespoints to the ESM declaration for TypeScript resolution.exportsprovides conditional entries for bothrequireandimportconsumers.typesVersionsensures backward compatibility with TypeScript versions below 4.5.
If declaration is disabled in your tsconfig.json, the types field and type entries are skipped automatically.