Support disabling of declarations generation
See original GitHub issueJust thinking. Currently, we can make multiple Rollup configs using this plugin. So, it will output cjs
, esm
, and umd
bundles for example.
But for all of them, it will also create exactly the same index.d.ts
files, which is unnecessary duplication and increase of the published npm package size.
The workaround is to pass declarationDir: 'types'
in your tsconfig
, but it will throw
[!] (plugin Typescript) TS5055: Cannot write file '/home/charlike/github/tunnckoCore/configs/types/index.d.ts' because it would overwrite input file.
if you have such as the above scenario. And this error makes sense, because what really happening is the following: “okey, a cjs bundle, write index.d.ts; then esm bundle, write index.d.ts”. It throws because after the first bundling process is finished there is already generated types/index.d.ts
file.
While writing the issues, just realized that I there might be one more workaround: use the tsconfig
option (object) instead of depending on the project root tsconfig.json
file, which is automatically detected - so it will be used only for editors support.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
Right, so it would be the inverse if your tsconfig doesn’t set declaration.
My use case is as the one described in the beginning where I generate multiple bundles but I only need one declaration file.
Thanks for providing a solution @tunnckoCore. I wonder whether it makes sense to add an option to rollup-plugin-ts to disable declaration files. I definitely think it’s a common use case. What do you think @wessberg?