Skip to content

Commit

Permalink
chore: mark stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed May 6, 2022
1 parent 66c2be3 commit ce123e8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/config/index.md
Expand Up @@ -727,7 +727,7 @@ export default defineConfig({

Another special value is `'esnext'` - which assumes native dynamic imports support and will transpile as little as possible:

- If the [`build.minify`](#build-minify) option is `'terser'`, `'esnext'` will be forced down to `'es2019'`.
- If the [`build.minify`](#build-minify) option is `'terser'`, `'esnext'` will be forced down to `'es2019'`. <!-- mark -->
- In other cases, it will perform no transpilation at all.

The transform is performed with esbuild and the value should be a valid [esbuild target option](https://esbuild.github.io/api/#target). Custom targets can either be a ES version (e.g. `es2015`), a browser with version (e.g. `chrome58`), or an array of multiple target strings.
Expand Down
3 changes: 3 additions & 0 deletions docs/guide/assets.md
Expand Up @@ -115,5 +115,8 @@ This pattern does not work if you are using Vite for Server-Side Rendering, beca
:::
::: warning Esbuild target config is necessary
<!-- mark -->
This pattern needs esbuild target to be set to `es2020` or higher. `vite@2.x` use `es2019` as default target. Set [build-target](https://vitejs.dev/config/#build-target) and [optimizedeps.esbuildoptions.target](https://vitejs.dev/config/#optimizedeps-esbuildoptions) to `es2020` or higher if you intend to use this partten.
:::
2 changes: 1 addition & 1 deletion docs/guide/build.md
Expand Up @@ -10,7 +10,7 @@ The production bundle assumes support for modern JavaScript. By default, Vite ta
defaults and supports es6-module and supports es6-module-dynamic-import, not opera > 0, not samsung > 0, not and_qq > 0
```

You can specify custom targets via the [`build.target` config option](/config/#build-target), where the lowest target is `es2015`.
You can specify custom targets via the [`build.target` config option](/config/#build-target), where the lowest target is `es2015`. <!-- mark -->

Note that by default, Vite only handles syntax transforms and **does not cover polyfills by default**. You can check out [Polyfill.io](https://polyfill.io/v3/) which is a service that automatically generates polyfill bundles based on the user's browser UserAgent string.

Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/build.ts
Expand Up @@ -246,15 +246,15 @@ export function resolveBuildOptions(raw?: BuildOptions): ResolvedBuildOptions {
// Support browserslist
// "defaults and supports es6-module and supports es6-module-dynamic-import",
resolved.target = [
'es2019',
'es2020',
'edge88',
'firefox78',
'chrome87',
'safari13.1'
]
} else if (resolved.target === 'esnext' && resolved.minify === 'terser') {
// esnext + terser: limit to es2019 so it can be minified by terser
resolved.target = 'es2019'
resolved.target = 'es2020'
}

if (!resolved.cssTarget) {
Expand Down

0 comments on commit ce123e8

Please sign in to comment.