Respect Browserslist config in esbuild
Description
esbuild doesn’t have built-in Browserslist config.
Benefits:
- Autoprefixer, postcss-preset-env, Babel and many other tools have. So users may expect Browserslist config.
- It is great to have only single config to specify target browsers for all tools.
- With Browserslist config, we can reduce polyfills in esbuild output and make JS works faster.
Suggested solution
We can use browserslist-to-esbuild as suggested in When Vite ignores your Browserslist configuration article.
In this case, Vite will look for Browserslist config and auto-fill build.target config option.
Alternative
No response
Additional context
Browserslist also supports Node.js versions
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
I could understand why for JS features, someone would like to stick with esbuild target syntax. However for css features I don't see any value in it. Vite should allow both syntaxes maybe?
But IMO it would be an easier bet to initially support build.cssTarget, which is used for css feature support (at least in the new v4.4 beta) and adopt build.target later.
Browserslist is already the most common and versatile syntax in the front-end ecosystem, and I strongly support this proposal.
100%, this makes a lot of sense.
Any update on this?