Avoid leaking Vite plugin types#1218
Closed
peterp wants to merge 7 commits into
Closed
Conversation
Reported-by: Evan Jacobs <570070+quantizor@users.noreply.github.com>
383b64d to
4b4e8f0
Compare
justinvdm
reviewed
Jun 2, 2026
| export const redwoodPlugin = async ( | ||
| options: RedwoodPluginOptions = {}, | ||
| ): Promise<InlineConfig["plugins"]> => { | ||
| ): Promise<any[]> => { |
Collaborator
There was a problem hiding this comment.
@peterp Can't we import type InlineConfig and then use it here? any casting for our main redwoodPlugin export is quite a change.
Member
Author
There was a problem hiding this comment.
Yeah! I don't know why the inference picked this shape.
…oodPlugin return type
…ig['plugins'] return type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Some projects can end up with two physical copies of Vite in
node_modules. When that happens, TypeScript may see RedwoodSDK's Vite plugin type and the app's Vite plugin type as two different things. The app then gets a confusingdefineConfig()type error, even though the plugins work at runtime.Reported by @quantizor in #1112.
Solution
This PR follows the dependency-layout fix suggested in #1112: make
@vitejs/plugin-reactan optional peer dependency instead of a runtime dependency ofrwsdk. That lets the app own the React Vite plugin and its Vite peer, avoiding an extra Vite copy underrwsdk/node_modules.Technical Summary
@vitejs/plugin-reactfromdependenciesto optionalpeerDependenciesanddevDependenciesinsdk/package.json.@vitejs/plugin-reactonly when RedwoodSDK needs to include the default React Vite plugin.redwoodPlugin()return type asPromise<InlineConfig["plugins"]>, addressing the review concern aboutany[].@vitejs/plugin-reactto the starter app so generated apps satisfy the optional peer.includeReactPlugin: false.Closes #1112