nginx / njs

A subset of JavaScript language to use in nginx
http://nginx.org/en/docs/njs/
BSD 2-Clause "Simplified" License
1.02k stars 147 forks source link

Help to add browserslist support #582

Closed xiaoxiangmoe closed 16 hours ago

xiaoxiangmoe commented 1 year ago

see https://github.com/browserslist/browserslist/issues/733#issuecomment-1263422707

browserslist need your help to add njs runtime js compliance information to some database like browserslist-db.

ai commented 1 year ago

Browserslist is a config with target browsers for the project. You can use this config to find what polyfills you have to add. For instance, you can avoid adding polyfills if target browsers don’t need it.

Browserslist is a very popular config. It already used by Autoprefixer, Babel, webpack, postcss-preset-env. CRA adds it by default.

xeioex commented 1 year ago

Hi @ai,

You can open an issue and mention me, I will add extra details.

Please, provide me with the list of information required to create a .browserslistrc. A link to a .browserslistrc for project like njs would help.

ai commented 1 year ago

Browserslist is a library with Can I Use data, which automatically look and parse config to get target browsers from end-users queries like last 2 versions.

We have a JS library and Rust.

ai commented 1 year ago

There is a spec for queries:

  1. https://github.com/browserslist/browserslist#queries
  2. https://github.com/browserslist/browserslist/blob/main/grammar.w3c-ebnf
xiaoxiangmoe commented 1 year ago

@ai Is there any tutorial for providing Can I Use data?

Should we provide data by creating a PR to https://github.com/Fyrd/caniuse repo?

ai commented 1 year ago

It depends on your programming language and environment.

I am using Can I Use data from caniuse-lite npm package.

jirutka commented 1 year ago

FYI, If you need browserslist just to configure the Babel transpiler, you can use babel-preset-njs instead. This doesn’t deal with polyfills though.

xiaoxiangmoe commented 1 year ago

@jirutka But some other tool like swc need using .browserslistrc