Skip to content

Commit 2cf8062

Browse files
docs: migration guide (#469)
Co-authored-by: Alexander Lichter <[email protected]>
1 parent edab97e commit 2cf8062

File tree

4 files changed

+402
-63
lines changed

4 files changed

+402
-63
lines changed

docs/config/build-options.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ In this case, you need to set `build.cssTarget` to `chrome61` to prevent vite fr
129129

130130
## build.cssMinify
131131

132-
- **Type:** `boolean | 'esbuild' | 'lightningcss'`
133-
- **Default:** the same as [`build.minify`](#build-minify) for client, `'esbuild'` for SSR
132+
- **Type:** `boolean | 'lightningcss' | 'esbuild'`
133+
- **Default:** the same as [`build.minify`](#build-minify) for client, `'lightningcss'` for SSR
134134

135-
This option allows users to override CSS minification specifically instead of defaulting to `build.minify`, so you can configure minification for JS and CSS separately. Vite uses `esbuild` by default to minify CSS. Set the option to `'lightningcss'` to use [Lightning CSS](https://lightningcss.dev/minification.html) instead. If selected, it can be configured using [`css.lightningcss`](./shared-options.md#css-lightningcss).
135+
This option allows users to override CSS minification specifically instead of defaulting to `build.minify`, so you can configure minification for JS and CSS separately. Vite uses [Lightning CSS](https://lightningcss.dev/minification.html) by default to minify CSS. It can be configured using [`css.lightningcss`](./shared-options.md#css-lightningcss). Set the option to `'esbuild'` to use esbuild instead.
136136

137137
## build.sourcemap
138138

@@ -277,16 +277,19 @@ During the SSR build, static assets aren't emitted as it is assumed they would b
277277

278278
## build.minify
279279

280-
- **Type:** `boolean | 'terser' | 'esbuild'`
281-
- **Default:** `'esbuild'` for client build, `false` for SSR build
280+
- **Type:** `boolean | 'oxc' | 'terser' | 'esbuild'`
281+
- **Default:** `'oxc'` for client build, `false` for SSR build
282282

283-
Set to `false` to disable minification, or specify the minifier to use. The default is [esbuild](https://github.com/evanw/esbuild) which is 20 ~ 40x faster than terser and only 1 ~ 2% worse compression. [Benchmarks](https://github.com/privatenumber/minification-benchmarks)
283+
Set to `false` to disable minification, or specify the minifier to use. The default is [Oxc Minifier](https://oxc.rs/docs/guide/usage/minifier) which is 30 ~ 90x faster than terser and only 0.5 ~ 2% worse compression. [Benchmarks](https://github.com/privatenumber/minification-benchmarks)
284+
285+
`build.minify: 'esbuild'` is deprecated and will be removed in the future.
284286

285287
Note the `build.minify` option does not minify whitespaces when using the `'es'` format in lib mode, as it removes pure annotations and breaks tree-shaking.
286288

287-
Terser must be installed when it is set to `'terser'`.
289+
esbuild or Terser must be installed when it is set to `'esbuild'` or `'terser'` respectively.
288290

289291
```sh
292+
npm add -D esbuild
290293
npm add -D terser
291294
```
292295

docs/config/dep-optimization-options.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@ export default defineConfig({
5151
})
5252
```
5353

54+
## optimizeDeps.rolldownOptions <NonInheritBadge />
55+
56+
- **Type:** [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys)`<``RolldownOptions`, `'input' | 'logLevel' | 'output'> & {
57+
output?: [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys)`<`
58+
`RolldownOutputOptions`,
59+
`'format' | 'sourcemap' | 'dir' | 'banner'>`
60+
`}`
61+
62+
<!-- TODO: add link to RolldownOptions -->
63+
<!-- TODO: add link to RolldownOutputOptions -->
64+
65+
Options to pass to Rolldown during the dep scanning and optimization.
66+
67+
Certain options are omitted since changing them would not be compatible with Vite's dep optimization.
68+
69+
- `plugins` are merged with Vite's dep plugin
70+
5471
## optimizeDeps.esbuildOptions <NonInheritBadge />
5572

5673
- **Type:** [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys)`<`[`EsbuildBuildOptions`](https://esbuild.github.io/api/#general-options)`,
@@ -64,13 +81,9 @@ export default defineConfig({
6481
| 'outbase'
6582
| 'outExtension'
6683
| 'metafile'>`
84+
- **Deprecated**
6785

68-
Options to pass to esbuild during the dep scanning and optimization.
69-
70-
Certain options are omitted since changing them would not be compatible with Vite's dep optimization.
71-
72-
- `external` is also omitted, use Vite's `optimizeDeps.exclude` option
73-
- `plugins` are merged with Vite's dep plugin
86+
This option is converted to `optimizeDeps.rolldownOptions` internally. Use `optimizeDeps.rolldownOptions` instead.
7487

7588
## optimizeDeps.force <NonInheritBadge />
7689

docs/config/shared-options.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -353,36 +353,44 @@ If set to `true`, imported JSON will be transformed into `export default JSON.pa
353353

354354
If set to `'auto'`, the data will be stringified only if [the data is bigger than 10kB](https://v8.dev/blog/cost-of-javascript-2019#json:~:text=A%20good%20rule%20of%20thumb%20is%20to%20apply%20this%20technique%20for%20objects%20of%2010%20kB%20or%20larger).
355355

356-
## esbuild
356+
## oxc
357357

358-
- **Type:** `ESBuildOptions | false`
358+
- **Type:** `OxcOptions | false`
359359

360-
`ESBuildOptions` extends [esbuild's own transform options](https://esbuild.github.io/api/#transform). The most common use case is customizing JSX:
360+
`OxcOptions` extends [Oxc Transformer's options](https://oxc.rs/docs/guide/usage/transformer). The most common use case is customizing JSX:
361361

362362
```js
363363
export default defineConfig({
364-
esbuild: {
365-
jsxFactory: 'h',
366-
jsxFragment: 'Fragment',
364+
oxc: {
365+
jsx: {
366+
runtime: 'classic',
367+
pragma: 'h',
368+
pragmaFrag: 'Fragment',
369+
},
367370
},
368371
})
369372
```
370373

371-
By default, esbuild is applied to `ts`, `jsx` and `tsx` files. You can customize this with `esbuild.include` and `esbuild.exclude`, which can be a regex, a [picomatch](https://github.com/micromatch/picomatch#globbing-features) pattern, or an array of either.
374+
By default, transformation by Oxc is applied to `ts`, `jsx` and `tsx` files. You can customize this with `oxc.include` and `oxc.exclude`, which can be a regex, a [picomatch](https://github.com/micromatch/picomatch#globbing-features) pattern, or an array of either.
372375

373-
In addition, you can also use `esbuild.jsxInject` to automatically inject JSX helper imports for every file transformed by esbuild:
376+
In addition, you can also use `oxc.jsxInject` to automatically inject JSX helper imports for every file transformed by Oxc:
374377

375378
```js
376379
export default defineConfig({
377-
esbuild: {
380+
oxc: {
378381
jsxInject: `import React from 'react'`,
379382
},
380383
})
381384
```
382385

383-
When [`build.minify`](./build-options.md#build-minify) is `true`, all minify optimizations are applied by default. To disable [certain aspects](https://esbuild.github.io/api/#minify) of it, set any of `esbuild.minifyIdentifiers`, `esbuild.minifySyntax`, or `esbuild.minifyWhitespace` options to `false`. Note the `esbuild.minify` option can't be used to override `build.minify`.
386+
Set to `false` to disable transformation by Oxc.
387+
388+
## esbuild
389+
390+
- **Type:** `ESBuildOptions | false`
391+
- **Deprecated**
384392

385-
Set to `false` to disable esbuild transforms.
393+
This option is converted to `oxc` option internally. Use `oxc` option instead.
386394

387395
## assetsInclude
388396

0 commit comments

Comments
 (0)