Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: rephrase browser range and features relation #19286

Merged
merged 1 commit into from
Jan 27, 2025
Merged

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jan 24, 2025

Description

I was discussing with @btea about the wording of this:

https://vite.dev/guide/build.html#browser-compatibility

The production bundle assumes support for modern JavaScript. By default, Vite targets browsers which support the native ES Modules, native ESM dynamic import, and import.meta:

  • Chrome >=87
  • Firefox >=78
  • Safari >=14
  • Edge >=88

The documented features don't match with the browser ranges, and few users have brought this up from time to time. And the reason is mostly that we're bumping to support features like nullish coalescing and bigint so they're not unnecessarily transpiled in modern browsers. However, this wasn't clearly explained in the docs.


This PR rephrases the paragraph, so instead of targets browsers which support, it's targets browsers that support modern JS, such as .... This way we're not implying that the browser ranges strictly follow the feature set mentioned.

Ideally we could strictly follow the feature set mentioned, however the browserslist query we used is outdated and can't be reproduced anymore, so I've updated it to use caniuse. Maybe in the next major we can bump up the browser ranges again to match the JS features we intend to follow.

I remember we've brought up to update the browser ranges to be "last 2 years" in the past for every major, but I don't think we've done that. Maybe it's also something we can revisit if we want to do this.

@bluwy bluwy added the documentation Improvements or additions to documentation label Jan 24, 2025
@btea
Copy link
Collaborator

btea commented Jan 25, 2025

Maybe we should also update the legacy plugin readme.

Vite's default browser support baseline is [Native ESM](https://caniuse.com/es6-module), [native ESM dynamic import](https://caniuse.com/es6-module-dynamic-import), and [`import.meta`](https://caniuse.com/mdn-javascript_operators_import_meta). This plugin provides support for legacy browsers that do not support those features when building for production.

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

@bluwy
Copy link
Member Author

bluwy commented Jan 27, 2025

Maybe we should also update the legacy plugin readme.

Vite's default browser support baseline is [Native ESM](https://caniuse.com/es6-module), [native ESM dynamic import](https://caniuse.com/es6-module-dynamic-import), and [`import.meta`](https://caniuse.com/mdn-javascript_operators_import_meta). This plugin provides support for legacy browsers that do not support those features when building for production.

I've tried to rephrase it, but I think currently it's sort of correct as it refers to Vite's bundle requires at least support for ESM, dynamic import, and import.meta. I guess "baseline" could be a bit vague.

But I think it's better to rephrase it differently altogether via #19038. Currently we don't highlight about modernTargets and using plugin-legacy with only modern polyfills is a possible setup too. So that paragraph isn't fully describing what the plugin is about.

@patak-dev patak-dev merged commit 97569ef into main Jan 27, 2025
16 checks passed
@patak-dev patak-dev deleted the docs-browser-range branch January 27, 2025 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants