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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 21 (20 by maintainers)
Commits related to this issue
- chore: export rollup types from pure-dep-types (fix #12270) — committed to sun0day/vite by sun0day a year ago
- chore: export rollup types from dep-types (fix #12270) — committed to sun0day/vite by sun0day a year ago
- chore: export Rollup namespace (fix #12270) — committed to sun0day/vite by sun0day a year ago
I wouldn’t mind renaming the internal
dep-types
too (maybebundled-types
?). But that is if we lean onvite/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 asdep-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.