Closed moritzmla closed 2 years ago
I recommend you using @microsoft/api-extractor to merge d.ts files into a single file, it's well at this work so that I don't want to make duplicate.
The @microsoft/api-extractor
cannot resolve dynamic imports, you can use staticImport: true
of this plugin's options to transfrom dynamic to static.
I would also really love to have this feature. Vite outputs a single .js
bundle, so it would be really nice if we could get it to bundle a single .d.ts
bundle along with it.
API Extractor looks rather complicated to use, and it's also not clear to me how to embed it into the build process in such a way that only a single .d.ts
file ends up in the dist folder. Wouldn't it be an option to make this plugin use API Extractor to output a single bundle?
As far as I understand from API Extractor docs, it can't be used as it needs single *.d.ts as entrypoint and output of vite-plugin-dts does not contain such entry point. Same limit has most of the dts bundlers. I found only one which did not required dts entry point, but it takes tsconfig.json so it does not understand vue ðŸ˜
I didn’t find any working solution so far. 😢
use rollup + rollup-plugin-dts , but there will be problems when it is used with vite.
it work for me
pnpm exec tsup .\src\index.ts --dts-only
Eventually, I wrote my own code to achieve
This is the config I use to get a single index.d.ts will all declarations merged:
plugins: [
dts({
include: ['src'],
staticImport: true,
insertTypesEntry: true,
rollupTypes: true,
}),
],
Is it possible to merge all d.ts files into a single d.ts file?