Clear and concise description of the problem
Currently, the inlined deps under unbundle mode will be transpiled to dist/node_modules/.... If not taken extra care when specifying the files field in package.json, npm pack may omit the nested node_modules.
e.g.
import { defineConfig } from 'tsdown';
export default defineConfig({
format: 'esm',
target: 'es2023',
platform: 'browser',
unbundle: true,
dts: true,
deps: {
onlyBundle: ['react-medium-image-zoom'],
},
});
if the files field is defined as follows:
{
"files": [
"dist/*"
]
}
When running npm pack, the node_modules folder containing react-medium-image-zoom will be omitted. It must be dist (without the glob) to avoid the original issue.
It would be great to allow custom destination paths for the inlined deps, this makes tsdown more customisable and allows cleaner & safer output.
Suggested solution
A deps.outDirs option with [dep_name: string] : string pairs, like:
{ "react-medium-image-zoom": "./dist/react-medium-image-zoom" }
It allows developers to specify a output directory for inlined deps.
Alternative
No response
Additional context
I was surprised to know glob in files field will make a difference in npm pack, I think the default can be adjusted to avoid special folder names like node_modules, although probably need extra discussions on this.
Validations
Clear and concise description of the problem
Currently, the inlined deps under unbundle mode will be transpiled to
dist/node_modules/.... If not taken extra care when specifying thefilesfield inpackage.json,npm packmay omit the nestednode_modules.e.g.
if the
filesfield is defined as follows:{ "files": [ "dist/*" ] }When running
npm pack, thenode_modulesfolder containingreact-medium-image-zoomwill be omitted. It must bedist(without the glob) to avoid the original issue.It would be great to allow custom destination paths for the inlined deps, this makes tsdown more customisable and allows cleaner & safer output.
Suggested solution
A
deps.outDirsoption with[dep_name: string] : stringpairs, like:It allows developers to specify a output directory for inlined deps.
Alternative
No response
Additional context
I was surprised to know glob in
filesfield will make a difference innpm pack, I think the default can be adjusted to avoid special folder names likenode_modules, although probably need extra discussions on this.Validations