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

Let plugin define config "optimizeDeps" and "jsx" #1162

Closed
csr632 opened this issue Nov 28, 2020 · 2 comments
Closed

Let plugin define config "optimizeDeps" and "jsx" #1162

csr632 opened this issue Nov 28, 2020 · 2 comments
Labels

Comments

@csr632
Copy link
Member

csr632 commented Nov 28, 2020

Is your feature request related to a problem? Please describe.
Even if I am using vite-plugin-react, I still have to add jsx: "react" to my vite config.(The same goes with preact).

Furthermore, after the new vite-plugin-react is release, users still have to add optimizeDeps.include: ["react", "react-dom"] to their vite config.

Describe the solution you'd like

Let plugin (vite-plugin-react) help users to define "optimizeDeps" and "jsx" config.

This will let vite plugin system do more and let plugin users do less.

Describe alternatives you've considered
No.

Additional context

If you are open to this idea, I can help implementing this feature.

@csr632
Copy link
Member Author

csr632 commented Nov 28, 2020

The plugin API in my mind is like this:

const myVitePlugin = {
   jsx: (prevJSX) => {
       if (prevJSX === undefined) return "react";
       return prevJSX;
   },
   optimizeDeps: (prevOptimizeDeps) => {
       if (!prevOptimizeDeps.inlude.find("react") && !prevOptimizeDeps.inlude.find("react-dom"))
         prevOptimizeDeps.inlude.push("react", "react-dom");
       return prevOptimizeDeps;
   }

}

@yyx990803
Copy link
Member

Fixed in 2.0.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants