From b993f2748a53d63327e936a08c76f5e42823bc73 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Fri, 6 May 2022 16:48:54 +0200 Subject: [PATCH] chore: mark stuff --- docs/config/index.md | 2 +- docs/guide/assets.md | 3 +++ docs/guide/build.md | 2 +- packages/vite/src/node/build.ts | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index 1c61f2bef5b7ac..9a602b8da8fcb7 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -745,7 +745,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'`. - 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. diff --git a/docs/guide/assets.md b/docs/guide/assets.md index 9776dcdd032f35..205eacb817b7f5 100644 --- a/docs/guide/assets.md +++ b/docs/guide/assets.md @@ -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 + + + 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. ::: diff --git a/docs/guide/build.md b/docs/guide/build.md index 358745d02f2cf1..8e09b747619ac3 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -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`. 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. diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index 550af9d13af389..b75fb6d7171ddf 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -253,7 +253,7 @@ export function resolveBuildOptions(raw?: BuildOptions): ResolvedBuildOptions { ] } 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) {