vite icon indicating copy to clipboard operation
vite copied to clipboard

Respect Browserslist config in esbuild

Open ai opened this issue 3 years ago • 6 comments

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

ai avatar Dec 26 '22 21:12 ai

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.

alexanderniebuhr avatar Jun 20 '23 16:06 alexanderniebuhr

Browserslist is already the most common and versatile syntax in the front-end ecosystem, and I strongly support this proposal.

yisibl avatar Nov 07 '23 11:11 yisibl

100%, this makes a lot of sense.

milton-imageline avatar Apr 30 '24 07:04 milton-imageline

Any update on this?

SinaKarimi7 avatar Jun 18 '24 19:06 SinaKarimi7