Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow sending plugins fn (to get different instances for each router) #1198

Merged
merged 1 commit into from
Dec 30, 2023

Conversation

nksaraf
Copy link
Member

@nksaraf nksaraf commented Dec 30, 2023

no other way of cloning plugins without their scope right now

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • infrastructure changes
  • Other... Please describe:

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

no other way of cloning plugins without their scope right now
@nksaraf nksaraf merged commit a9b4b05 into main Dec 30, 2023
1 check passed
@nksaraf nksaraf deleted the plugins-api branch December 30, 2023 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Missing/no images using vite-imagetools in dev mode
1 participant