allow sending plugins fn (to get different instances for each router) #1198
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.
no other way of cloning plugins without their scope right now
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
What is the new behavior?
Fixes #1195
Right now the user sends a list of plugins in the
plugins
option. If these plugins depend on keeping some scope that they use to decide what to, there will be issues as we use the same plugins list for multiple router. I want to encourage people to use the fn version of the plugins config, but its a deviation from the default vite API, but only by the slightest and actually provides powerful pattern.This adds support for the
plugins: () => [....]
format, while keeping the array format intact.This was important for example for the
imagetools
plugin because it adds something to the vite dev server (a middleware) so its needs to be unique for each vinxi router.Other information