Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge all d.ts files into a single d.ts file? #55

Closed
moritzmla opened this issue Jan 23, 2022 · 7 comments
Closed

Merge all d.ts files into a single d.ts file? #55

moritzmla opened this issue Jan 23, 2022 · 7 comments

Comments

@moritzmla
Copy link

Is it possible to merge all d.ts files into a single d.ts file?

@qmhc
Copy link
Owner

qmhc commented Jan 23, 2022

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.

@qmhc qmhc closed this as completed Jan 23, 2022
@cdauth
Copy link

cdauth commented Apr 17, 2022

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?

@luckylooke
Copy link
Contributor

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. 😢

@eightHundreds
Copy link

eightHundreds commented Mar 14, 2023

use rollup + rollup-plugin-dts , but there will be problems when it is used with vite.

@lisonge
Copy link

lisonge commented Apr 10, 2023

it work for me

pnpm exec tsup .\src\index.ts --dts-only

@rxliuli
Copy link

rxliuli commented Jul 14, 2023

@smastrom
Copy link

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,
   }),
],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants