When Vite ignores your Browserslist configuration

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • esbuild

    An extremely fast bundler for the web

    Weirdly, it took me ages to notice the JavaScript transformations done by Vite (using ESBuild under the hood) always produce the same result, no matter the content of your browserslist file. Whoops!

  • vite

    Next generation frontend tooling. It's fast!

    On the other hand, if your project uses the @vitejs/plugin-legacy, an official Vite plugin helping you supporting browsers outside of Vite browser compatibility list, then Vite will make use of your Browserslist configuration because this plugin uses Babel @babel/preset-env instead of ESBuild, and this Babel plugin uses your Browserslist configuration out of the box in order to define the list of code transformations that Babel will apply.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

  • browserslist-to-esbuild

    Get esbuild-compatible targets from a browserlist config or project

    Fortunately, there’s the browserslist-to-esbuild package (by Marco Fugaro) that is able to properly pass the content of a browserslist file to ESBuild.

  • PostCSS

    Transforming styles with JS plugins

    Actually, Vite doesn’t support Browserslist at all: the only reason it “seems” to work well with CSS is because Vite uses PostCSS, which itself natively uses Browserslist. We could say that Vite supports Browserslist by proxy, for CSS.

  • burokku

    🤜 ⍰

    The steps described here can also be vizualized in a commit of mine.

  • esbuild-plugin-browserslist

    Configure esbuild targets based on a browserslist query

    (Note: another package can do this, but I have not tested it.)

  • browserslist

    🦔 Share target browsers between different front-end tools, like Autoprefixer, Stylelint and babel-preset-env

    I’m a long time user of Browserslist and Vite and I was pretty convinced they paired very-well. It seems to be the case for both CSS and JavaScript output, but it actually is not for JavaScript.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts