diff --git a/docs/config/index.md b/docs/config/index.md index c885020eca28d3..9da13bd6173583 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -741,7 +741,7 @@ export default defineConfig({ - **Default:** `'modules'` - **Related:** [Browser Compatibility](/guide/build#browser-compatibility) - Browser compatibility target for the final bundle. The default value is a Vite special value, `'modules'`, which targets [browsers with native ES module support](https://caniuse.com/es6-module). + Browser compatibility target for the final bundle. The default value is a Vite special value, `'modules'`, which targets browsers with [native ES Modules](https://caniuse.com/es6-module) and [native ESM dynamic import](https://caniuse.com/es6-module-dynamic-import) support. Another special value is `'esnext'` - which assumes native dynamic imports support and will transpile as little as possible: diff --git a/docs/guide/assets.md b/docs/guide/assets.md index 9776dcdd032f35..34e86924362add 100644 --- a/docs/guide/assets.md +++ b/docs/guide/assets.md @@ -114,6 +114,6 @@ const imgUrl = new URL(imagePath, import.meta.url).href This pattern does not work if you are using Vite for Server-Side Rendering, because `import.meta.url` have different semantics in browsers vs. Node.js. The server bundle also cannot determine the client host URL ahead of time. ::: -::: 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. +::: warning `target` needs to be `es2020` or higher +This pattern will not work if [build-target](https://vitejs.dev/config/#build-target) or [optimizedeps.esbuildoptions.target](https://vitejs.dev/config/#optimizedeps-esbuildoptions) is set to a value lower than `es2020`. ::: diff --git a/docs/guide/build.md b/docs/guide/build.md index 358745d02f2cf1..578b8f495c41fb 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -4,11 +4,12 @@ When it is time to deploy your app for production, simply run the `vite build` c ## Browser Compatibility -The production bundle assumes support for modern JavaScript. By default, Vite targets browsers which support the [native ESM script tag](https://caniuse.com/es6-module) and [native ESM dynamic import](https://caniuse.com/es6-module-dynamic-import). As a reference, Vite uses this [browserslist](https://github.com/browserslist/browserslist) query: +The production bundle assumes support for modern JavaScript. By default, Vite targets browsers which support the [native ES Modules](https://caniuse.com/es6-module) and [native ESM dynamic import](https://caniuse.com/es6-module-dynamic-import) and [`import.meta`](https://caniuse.com/mdn-javascript_statements_import_meta): -``` -defaults and supports es6-module and supports es6-module-dynamic-import, not opera > 0, not samsung > 0, not and_qq > 0 -``` +- Chrome >=87 +- Firefox >=78 +- Safari >=13 +- Edge >=88 You can specify custom targets via the [`build.target` config option](/config/#build-target), where the lowest target is `es2015`. diff --git a/docs/guide/index.md b/docs/guide/index.md index 4989b00769f701..ab45ceb7f85475 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -18,7 +18,7 @@ You can learn more about the rationale behind the project in the [Why Vite](./wh ## Browser Support -- The default build targets browsers that support both [native ESM via script tags](https://caniuse.com/es6-module) and [native ESM dynamic import](https://caniuse.com/es6-module-dynamic-import). Legacy browsers can be supported via the official [@vitejs/plugin-legacy](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy) - see the [Building for Production](./build) section for more details. +- The default build targets browsers that support both [native ES Modules](https://caniuse.com/es6-module) and [native ESM dynamic import](https://caniuse.com/es6-module-dynamic-import). Legacy browsers can be supported via the official [@vitejs/plugin-legacy](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy) - see the [Building for Production](./build) section for more details. ## Trying Vite Online