You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wrote a simple test to see how to use the environment APIs to build multiple bundles at once. The API is much nicer to use but performance wise, vite.createBuilder(...).buildApp() negligibly faster than just running vite.build(...) multiple times with different config (what WXT does). Hard to test on a real extension without actually implementing it in WXT... so we'll have to do that to benchmark it against a real extension with lots of dependencies.
@eMerzh You probably have multiple versions of Vite installed. Type errors like this are usually a sign of this. I just released a new version of WXT that adds support for Vite 6: v0.19.17
Update WXT, then delete your lockfile or run pnpm i vite@latest && pnpm rm vite to update vite. Then run pnpm why vite again to make sure there's only one version installed in the project. If you use a different package manager... there are similar commands, but I don't know them off the top of my head.
import{defineConfig}from'wxt';import{defineRunnerConfig}from'wxt';import{defineWxtModule}from'wxt/modules';exportinterfaceCustomCommandOptions{// Add any options your command needscommandName?: string;}// See https://wxt.dev/api/config.htmlexportdefaultdefineConfig({extensionApi: 'chrome',modules: ['@wxt-dev/module-react','@wxt-dev/auto-icons'],manifest: {permissions: ["activeTab","scripting","sidePanel","storage","tabs","history","unlimitedStorage","commands"],description: "A browser extension that allows you to view and interact with your browser history in a side panel.",},runner: defineRunnerConfig({disabled: true}),manifestVersion: 3,autoIcons: {enabled: true,grayscaleOnDevelopment: true},dev: {server: {port: 5180}},vite: ()=>({plugins: [['babel-plugin-react-compiler',{}]]})});
This is the error I was getting
Type '() => { plugins: {}[][]; }' is not assignable to type '(env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>'.
Type '{ plugins: {}[][]; }' is not assignable to type 'WxtViteConfig | Promise<WxtViteConfig>'.
Type '{ plugins: {}[][]; }' is not assignable to type 'WxtViteConfig'.
Types of property 'plugins' are incompatible.
Type '{}[][]' is not assignable to type 'PluginOption[]'.
Type '{}[]' is not assignable to type 'PluginOption'.
Type '{}[]' is not assignable to type 'PluginOption[]'.
Type '{}' is not assignable to type 'PluginOption'.ts(2322)
types.d.ts(407, 5): The expected type comes from property 'vite' which is declared here on type 'UserConfig'
Because of typescript throwing Type 'Plugin<any>[]' is not assignable to type 'PluginOption'. - which seems to happen when using different vite versions in one project: vitest-dev/vitest#1706 => would be great to get WXT on latest vite 6 to use with latest plugins like tailwindcss natively.
Because of typescript throwing Type 'Plugin<any>[]' is not assignable to type 'PluginOption'. - which seems to happen when using different vite versions in one project: vitest-dev/vitest#1706 => would be great to get WXT on latest vite 6 to use with latest plugins like tailwindcss natively.
Activity
aklinker1 commentedon Nov 26, 2024
Wrote a simple test to see how to use the environment APIs to build multiple bundles at once. The API is much nicer to use but performance wise,
vite.createBuilder(...).buildApp()negligibly faster than just runningvite.build(...)multiple times with different config (what WXT does). Hard to test on a real extension without actually implementing it in WXT... so we'll have to do that to benchmark it against a real extension with lots of dependencies.vite-6-demo.zip
Did not profile memory usage nor did I look into changes to dev mode or importing TS files, so still some work to do.
eMerzh commentedon Nov 28, 2024
Hello,
not sure you had that in your radar, but we were prompted with vite6 dep update, and it seems that the vite (https://wxt.dev/guide/essentials/config/vite.html) method to define the config isn't really type compatible anymore.
properties like resolve alias & plugins
🤔
[-]Vite 6[/-][+]Explore improvements made possible by Vite 6[/+][-]Explore improvements made possible by Vite 6[/-][+]Vite 6: Explore possible improvements[/+]aklinker1 commentedon Nov 28, 2024
@eMerzh You probably have multiple versions of Vite installed. Type errors like this are usually a sign of this. I just released a new version of WXT that adds support for Vite 6:
v0.19.17Update WXT, then delete your lockfile or run
pnpm i vite@latest && pnpm rm viteto update vite. Then runpnpm why viteagain to make sure there's only one version installed in the project. If you use a different package manager... there are similar commands, but I don't know them off the top of my head.eMerzh commentedon Nov 28, 2024
awesome @aklinker1 it makes the trick 💪 thanks
remusris commentedon Dec 31, 2024
A vite template for using React Compiler would be a great addition or at least one example showing how to do it.
aklinker1 commentedon Jan 1, 2025
Huh, does the regular react vite plugin not include the compiler already?
remusris commentedon Jan 1, 2025
You have to turn it on and when I tried turning it on it was giving me errors
https://react.dev/learn/react-compiler
below was my attempt of integrating it
This is the error I was getting
aklinker1 commentedon Jan 1, 2025
@remusris See the README for the react module: https://www.npmjs.com/package/@wxt-dev/module-react
To pass options to the react plugin, like the
babel.pluginsarray, use thereact.vitefield:xcaptain commentedon Jan 22, 2025
I use
to load tailwindcss v4, it worked well.
abegehr commentedon Jan 28, 2025
@xcaptain, for me the new tailwindcss vite plugin (tailwinds v4) is also working in WXT, however I had to use a not-so-fun typecast:
Because of typescript throwing
Type 'Plugin<any>[]' is not assignable to type 'PluginOption'.- which seems to happen when using different vite versions in one project: vitest-dev/vitest#1706 => would be great to get WXT on latest vite 6 to use with latest plugins like tailwindcss natively.aklinker1 commentedon Jan 28, 2025
@abegehr Working on it. See #1362
ArjixWasTaken commentedon Mar 9, 2025
a less ugly way is to do
refactor: move to module runner
refactor: move to module runner
refactor: move to module runner
refactor: move to module runner