esc-rs
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

esc-rs

[!WARNING]
Based on swc which use compat-data from babel, maybe not as same as caniuse, check this issue for more details.

usage

pnpm i esc-rs -D

Detect features with browserlist

import { detect } from 'esc-rs'

const result = detect({
  filename: 'input.js',
  code: 'const a = 1 ?? false',
  browserslist: 'IE 11',
})

// result
// {
//   features: {
//     nullishCoalescing: true,
//     ...
//   }
// }

Will output <feature>: true if <feature> not support in current browserslist.

If want to report detail line-col info

const result = detect({
  filename: 'input.js',
  code: 'const a = 1 ?? false',
  browserslist: 'IE 11',
})
for (const detail of result.details) {
  console.log(`Reason: ${detail.feature}`, code.slice(detail.s, detail.e))
}

[!WARNING]
Currently unable to check polyfill features, e.g. Async iterators. In swc it will inject core-js polyfills instead of transform

Readme

Keywords

none

Package Sidebar

Install

npm i esc-rs

Weekly Downloads

0

Version

0.1.4

License

MIT

Unpacked Size

13.6 kB

Total Files

5

Last publish

Collaborators

  • qidanta