Coder Social home page Coder Social logo

browserslist-rs's Introduction

browserslist-rs

The tool like Browserslist, but written in Rust.

Project Status

Can I use this library?

If you don't rely on the features mentioned in the Limitations section, you can use it.

We have supported most widely or most frequently used queries, and there are over 100 tests to make sure it works correctly.

For more detail about development status, please see Project #1.

Usage

Please refer to crate documentation.

Try as Rust crate example

You can try and inspect query result by running example with Cargo:

cargo run --example inspect -- <query>

You can also specify additional options, for example:

cargo run --example inspect -- --mobile-to-desktop 'last 2 versions, not dead'

To get more help, you can run:

cargo run --example inspect -- -h

Limitations

The features below aren't supported currently:

  • Custom usage like > 0.5% in my stats.
  • Custom usage like cover 99.5% in my stats.

Credits

Thanks Andrey Sitnik for creating the JavaScript-based Browserslist which is under MIT License.

License

MIT License

Copyright (c) 2021-present Pig Fang

browserslist-rs's People

Contributors

cobward avatar devongovett avatar g-plane avatar kwonoj avatar themezv avatar zebp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

browserslist-rs's Issues

Move to Browserslist org

Do you want to move your repo to Browserslist, org? It will show an official level of your amazing project?

You will be still main maintainer and I will ask only for queries compatibility (which is already OK).

Add support for `fully supports` and `partial supports` syntax

browserslist/browserslist#787 released in Browserslist v4.22.0 introduced two new syntaxes:

  • fully supports - which only considers browsers with full support from caniuse (where the stat value contains 'y')
  • partially supports - which considers browsers with full or partial support from caniuse (where the stat value contains 'y' or 'a') - which is the same as the current supports syntax

It'd be great if browserslist-rs supported these new syntaxes, especially as browserslist is now pushing for using these syntaxes over the existing supports syntax on https://browsersl.ist/.


Unfortunately my Rust-fu is non existent, but it looks like it would be pretty straight-forwards to someone with not-zero Rust knowledge as it is extending and adjusting the existing supports behaviour:

  • Adjust the the logic to generate the feature support json files so it contains blocks where the stat starts with y or a for partial support (same as what is currently present) and where the stat starts with y for full support.
  • Add an extra include_partial_support boolean argument to the supports lookup logic in supports.rs which controls which support block to look up.
  • In the parser match fully supports, and partial supports in addition to supports, and call supports with the include_partial_support parameter set appropriately.

Could you please expose caniuse mod?

Thanks for what you did for this project, we are planing to port the autoprefixer in rust, we found this project which is super nice. but the caniuse mod is not expose, so i am wonder if you are willing to expose it?

Browserslist wasm with web interface

Hello.

I am have idea to build browserslist wasm with web interface, which will work even offline (by using service worker). I found your project and I want to thanks for great job.

I am start build wasm module based on your library, but now find out you also doing some work with it too (based on commits). I decided to ask, maybe you have similar idea and in this case I don't need waste time on this. Or maybe you working on the wasm module for some different needs (maybe it will be published as npm package)?

P.S. Big thanks for code. I did try to load rust was module, but looks like it return names only for firefox browsers:

  import init, {browserslist} from './../browserslist-wasm/pkg'

  init().then(() => {
    console.log(browserslist('>1%, Firefox ESR, not dead, not ie 11, not op_mini all'))
  })

I uploaded code here (if you want check yourself): https://github.com/le0pard/browserlist

Screenshot 2021-12-09 at 01 01 21

Broken because of `string_cache-v8.5.4`

Opened an issue there, but this might be better off being fixed here
servo/string-cache#271

Error:

error[E0283]: type annotations needed
  --> {.. snip ..}\browserslist-rs-0.12.3\src\data\caniuse.rs:91:35
   |
91 |     let chrome = CANIUSE_BROWSERS.get(&"chrome".into()).unwrap();
   |                                   ^^^ ---------------- type must be known at this point
   |                                   |
   |                                   cannot infer type of the type parameter `Q` declared on the associated function `get`
   |
   = note: multiple `impl`s satisfying `Atom<BrowserNameAtomStaticSet>: Borrow<_>` found in the following crates: `core`, `string_cache`:
           - impl<Static> Borrow<str> for Atom<Static>
             where Static: StaticAtomSet;
           - impl<T> Borrow<T> for T
             where T: ?Sized;
note: required by a bound in `AHashMap::<K, V, S>::get`
  --> {.. snip ..}\ahash-0.7.6\src\hash_map.rs:81:12
   |
81 |         K: Borrow<Q>,
   |            ^^^^^^^^^ required by this bound in `AHashMap::<K, V, S>::get`
help: consider specifying the generic argument
   |
91 |     let chrome = CANIUSE_BROWSERS.get::<Q>(&"chrome".into()).unwrap();
   |                                      +++++

Wasm module not contain all data, as rust package

Thanks for your work.

I am not a Rust developer, so I apologize in advance if the problem and question are stupid.

I am trying to use this library to made web page with wasm module (for fun). Wasm module works, you can check results here (it is draft, no design) - https://browserlist.leopard.in.ua/ (repo here - https://github.com/le0pard/browserlist )

Looks like problem the same, as I mentioned in #4 (comment) - library return versions without browser names.

image

In cargo run --example inspect -- <query> everything works correctly.

rustc version - 1.57.0 (f1edd0429 2021-11-29)
browserslist-rs taken from HEAD - https://github.com/le0pard/browserlist/blob/main/browserslist-wasm/Cargo.toml#L17

Build you can see here: https://github.com/le0pard/browserlist/runs/4598534242?check_suite_focus=true (used wasm-pack)

Is this possible, that wasm-pack doing some optimisation and remove from wasm package data, which package need for work?

Thanks for help.

List of supported browsers?

I am implementing a function to convert browserslist results to SWC targets, similar to https://github.com/marcofugaro/browserslist-to-esbuild/tree/main. I keep getting error messages like the following:

thread '<unnamed>' panicked at 'not implemented: Targets: {"bb": Query(Single("7")), "ie": Query(Single("5.5")), "edge": Query(Single("106")), "firefox": Query(Single("107")), "opera": Query(Single("92")), "android": Query(Single("115")), "chrome": Query(Single("107")), "samsung": Query(Single("12")), "safari": Query(Single("15.2"))}', C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\preset_env_base-0.4.5\src\query.rs:124:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
assets by status 1.1 KiB [cached] 2 assets
./src/index.ts 39 bytes [built] [code generated] [1 error]

I get these error messages from SWC but from my understanding SWC is delegating this to browserslist-rs.

I was wondering what targets does browserlist-rs support?

For example, "baidu", "kaios" and "bb" seems to be supported by the original browserslist tool but not by browserlist-rs.

Thank you!

Patrick

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.