vite: Typescript: Missing all Rollup types

Describe the bug

I am writing Vite plugins in TypeScript. To implement various helper functions that take Rollup data, it is needed to have access to all the Rollup interfaces.

Examples:

  • PluginContext
  • CustomPluginOptions
  • NormalizedInputOptions
  • NormalizedOutputOptions
  • OutputBundle
  • EmittedFile …

My current workaround is to install “rollup” in parallel just to have the type infos. This is not ideal because it needs keeping the version in sync with Vite so that Vite’s rollup dependency will be hoisted to top-level node_modules. Otherwise, TypeScript may issue weird type errors because of incompatible types in the two rollup repos (already happend to me).

There are two options coming into my mind:

  • Export all types top-level. But this may cause name collisions, e.g. with the Plugin type.
  • Export all types as namespace, e.g. export * as Rollup from 'rollup'; in Vite’s index.d.ts

If you agree, I would be happy to credate a merge request.

Reproduction

Steps to reproduce

No response

System Info

-

Used Package Manager

yarn

Logs

No response

Validations

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 21 (20 by maintainers)

Commits related to this issue

Most upvoted comments

I wouldn’t mind renaming the internal dep-types too (maybe bundled-types?). But that is if we lean on vite/dep-types/rollup 👍

Maybe documentation could do if we’re in favour of it, but it feels like a patch (at least for me 😬). But I don’t strongly oppose it.

I think vite/dep-types/rollup is fine too though as dep-types is a new concept publicly, even though we have a different meaning for it internally. vite/rollup might imply exposing the JS API too, so maybe we should avoid it.