Giter Site home page Giter Site logo

Comments (7)

cdauth avatar cdauth commented on June 19, 2024 14

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?

from vite-plugin-dts.

smastrom avatar smastrom commented on June 19, 2024 2

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

from vite-plugin-dts.

qmhc avatar qmhc commented on June 19, 2024 1

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.

from vite-plugin-dts.

eightHundreds avatar eightHundreds commented on June 19, 2024 1

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

from vite-plugin-dts.

luckylooke avatar luckylooke commented on June 19, 2024

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

from vite-plugin-dts.

lisonge avatar lisonge commented on June 19, 2024

it work for me

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

from vite-plugin-dts.

rxliuli avatar rxliuli commented on June 19, 2024

Eventually, I wrote my own code to achieve

https://github.com/rxliuli/liuli-tools/blob/e61812c10e2ca213cdb472c4abf0d08ed190f17f/packages/vite-plugin-node/src/plugins/dts.ts#L7

from vite-plugin-dts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.