A Vite 7 config sets `optimizeDeps.esbuildOptions` with `loader`, `define` and an esbuild plugin; what does Vite 8 do with it, and what replaces it?
answer
- the optimizer changed engines
- deprecated, but still read
- converted into rolldownOptions
- loader becomes moduleTypes
- target, JSX and alias do not convert
basics
~20 sVite 8 runs the optimizer on Rolldown, so it warns that optimizeDeps.esbuildOptions is deprecated and converts what it can into optimizeDeps.rolldownOptions: loader to moduleTypes, define to transform.define, plugins with partial support. Move the settings there yourself.
solid answer
~40 sVite 8 replaced esbuild with Rolldown in the dependency optimizer. It still reads `optimizeDeps.esbuildOptions`, logs a deprecation warning, and converts the options it can into `optimizeDeps.rolldownOptions`. `loader` becomes `moduleTypes`, `define` becomes `transform.define`, `mainFields` and `conditions` become `resolve.mainFields` and `resolve.conditionNames`, and esbuild `plugins` are wrapped as Rolldown plugins with only partial support. Some options are not converted at all, among them `target`, the JSX options, `alias` and `inject`. A value you have already set in `rolldownOptions` wins over a converted one. The fix is to move the settings into `optimizeDeps.rolldownOptions` yourself and rewrite the esbuild plugin as a Rolldown plugin built on hooks such as `resolveId` and `load`. To see what the compatibility layer produced, log `config.optimizeDeps.rolldownOptions` from a plugin's `configResolved` hook.
code
typescript · 24 lines// vite.config.ts
import { defineConfig } from 'vite'
export default defineConfig({
optimizeDeps: {
// Vite 7: esbuildOptions: { loader: { '.js': 'jsx' }, define: { ... }, plugins: [...] }
rolldownOptions: {
moduleTypes: { '.js': 'jsx' },
transform: {
define: { __CAL_DEBUG__: 'false' },
},
plugins: [
{
name: 'recur-locale-stub',
load(id) {
if (id.endsWith('/recur-rules/locales/all.js')) {
return 'export default {}'
}
},
},
],
},
},
})go deeper
Recall that Vite 8 pre-bundles with Rolldown, so the optimizer's options now live under optimizeDeps.rolldownOptions and esbuildOptions is deprecated.
Explain the compatibility layer: the warning, the field-by-field conversion such as loader to moduleTypes and define to transform.define, and why explicit rolldownOptions values win.
Audit for what does not convert, namely target, JSX options, alias and inject, port esbuild plugins to Rolldown hooks, and verify the result from configResolved instead of trusting the shim.
Treat the shim as a migration window, not a destination: schedule the rewrite of shared configs and in-house optimizer plugins before the deprecated option is removed.
## Why the option changed Vite 8's migration guide sums up the release in one line: Vite 8 "uses Rolldown and Oxc based tools instead of esbuild and Rollup". The dependency optimizer is part of that move. Pre-bundling now runs on **Rolldown**, so its customisation point is **`optimizeDeps.rolldownOptions`**. This takes Rolldown's input options minus `input` and `logLevel`, and its output options minus `format`, `sourcemap`, `dir` and `banner`, because changing those would break Vite's optimizer. Plugins you list there are merged with Vite's own dependency plugin. `optimizeDeps.esbuildOptions` still exists, but it is **deprecated and will be removed in the future**, in the guide's words. ## What Vite 8 does with an old config 1. **It warns.** At config resolution Vite logs: `You or a plugin you are using have set optimizeDeps.esbuildOptions but this option is now deprecated.` It goes on to point you at `optimizeDeps.rolldownOptions`. Note the "or a plugin": a plugin's `config` hook can set the option without you writing it. 2. **It converts what it can.** Each field below is copied across, but only when the matching `rolldownOptions` field is still unset, so an explicit Rolldown setting always wins. 3. **It ignores the rest.** Some fields have no converter, and apart from the general deprecation warning there is no further message for them. | `esbuildOptions` field | Becomes, under `optimizeDeps.rolldownOptions` | |---|---| | `loader` | `moduleTypes`, except the `copy`, `css`, `default`, `file` and `local-css` loaders | | `define` | `transform.define` | | `plugins` | `plugins`, with partial support | | `mainFields` / `conditions` | `resolve.mainFields` / `resolve.conditionNames` | | `resolveExtensions` | `resolve.extensions` | | `preserveSymlinks` | the inverse of `resolve.symlinks` | | `minify` / `treeShaking` / `keepNames` | `output.minify` / `treeshake` / `output.keepNames` | | `platform` | `platform` | ## What does not carry over The compatibility code lists the options it cannot convert or does not bother to: - **`target` and `supported`.** To change what the optimizer emits, set Rolldown's transform target under `optimizeDeps.rolldownOptions`, which the pre-bundling guide names as a typical customisation. - **The JSX options** (`jsx`, `jsxFactory`, `jsxImportSource` and the rest) and `tsconfigRaw`. - **`alias`, `inject`, `banner` and `footer`**, the `drop` options and the property-mangling options. A Vite 7 config that relied on any of these still loads without error, but those settings no longer reach the optimizer. ## The esbuild plugin Vite wraps each esbuild plugin in a Rolldown plugin. It runs the plugin's `setup`, maps `onResolve` and `onLoad` callbacks onto Rolldown's resolve and load hooks, and calls `onStart`, `onEnd` and `onDispose` around the run. Parts of esbuild's build API that the wrapper does not implement throw `Not implemented` when a plugin calls them. That is the "partial support" the guide warns about. The lasting fix is to rewrite the plugin as a **Rolldown plugin**: an object with a `name` and Rollup-compatible hooks such as `resolveId` and `load`. Writing those hooks well is the plugin API's own subject. Here it is enough to know where the plugin goes and that esbuild's `setup(build)` shape no longer applies. ## Who has to act - **Application configs.** Any `vite.config` with an `optimizeDeps.esbuildOptions` block. Search the repository for the key, including configs generated from templates. - **Shared and in-house plugins.** A plugin whose `config` hook returns `optimizeDeps.esbuildOptions` sets off the warning in every app that uses it, so fixing it once fixes all of them. - **Third-party plugins.** If the warning persists after your own configs are clean, a dependency's plugin is setting the option, and the remedy is a plugin release built for Vite 8. Until each of these is rewritten, the compatibility layer keeps the converted fields working and drops the others with no message beyond the deprecation warning. ## Rewriting the block 1. Move each converted option to its new name under `optimizeDeps.rolldownOptions`, as in the code example. 2. Re-express each unconverted option deliberately, or confirm it is no longer needed. 3. Port the esbuild plugin to Rolldown hooks, then delete `esbuildOptions` so the warning goes away. 4. Check the result. A plugin's `configResolved(config)` hook can log `config.optimizeDeps.rolldownOptions`, which is the exact technique the migration guide shows. Restart the dev server: because the optimizer's options are part of its cache hash, the next start re-bundles the dependencies with the new settings.
- Why might the `esbuildOptions` warning appear in a project that never sets the option?A Vite plugin can set `optimizeDeps.esbuildOptions` from its `config` hook, which is why the warning says 'You or a plugin you are using'. Update that plugin to a release that uses `optimizeDeps.rolldownOptions`, or check from `configResolved` that its converted options still do what it needs.
- If a config sets both `esbuildOptions.define` and `rolldownOptions.transform.define`, which one applies?The `rolldownOptions` value. The compatibility layer fills a converted field only while the matching `optimizeDeps.rolldownOptions` field is undefined, so an explicit Rolldown setting is never overwritten by the old esbuild one.
- How do you change the optimizer's output target in Vite 8?Through Rolldown's transform target under `optimizeDeps.rolldownOptions`, the customisation the pre-bundling guide names. `esbuildOptions.target` is one of the fields the compatibility layer does not convert, so leaving it in the old block has no effect on the Rolldown optimizer.
- Vite 8 ignores optimizeDeps.esbuildOptions entirely, so the old settings are simply lost.
- Every esbuildOptions field is converted, so the old block can stay as it is.
- esbuild plugins run unchanged inside the Vite 8 dependency optimizer.
- The converted esbuildOptions value overrides anything set in rolldownOptions.
- esbuildOptions.target is the way to change what Vite 8's optimizer emits.
Assumes Vite 8: the dependency optimizer runs on Rolldown, and optimizeDeps.esbuildOptions is deprecated, converted automatically and due to be removed.