Make Vite a Peer Dependency
Feature Request
I get lots of comments about this issue:
- https://github.com/wxt-dev/wxt/issues/1460#issuecomment-2811260819
- https://github.com/wxt-dev/wxt/issues/1702
Which would be solved by making Vite a peer and requiring all projects list a version of it in their package.json.
Is your feature request related to a bug?
N/A
What are the alternatives?
Keep it a subdependency. Only benefit here is WXT has control over the version of vite it uses, and can prevent people from trying a newer version, like v7, before it's ready.
It's easy to ignore peer dependency version warnings, while those should tell the user t hey have an invalid version installed.
One idea that might help, Yarn & pnpm support "peer dependencies with defaults". If you include a package in both peerDependencies and dependencies, it'll act like a peer, but it'll be auto-installed npm-style unless you install your own version of Vite, in which case it'll inherit your version. In npm, it'll fall back to a normal dependency (status quo).
References
Docs:
- Yarn supports "peer dependencies with default": dependencies listed in both the dependencies and a peerDependencies fields will try to solve the peer dependency first, but will fallback to the regular dependency if it can't be satisfied otherwise.
- The preferred one is to list the dependency (in Next.js's case, webpack) as both a regular dependency and a peer dependency. Yarn will interpret this pattern as "peer dependency with a default", meaning that your users will be able to take ownership of the Webpack package if they need to, while still giving the package manager the ability to emit a warning if the provided version is incompatible with the one your package expects.
- pnpm PR
P.S. I'm back for at least a bit! 😛