0.0.0 • Published 2 years ago
bundlyzer v0.0.0
bundlyzer
A utility for analyzing package API requirements
Motivation
polyfill.io is a great step forward in the field of polyfills. It builds bundle on the fly by 'useragent' string (awesome!), but we still need to declare which polyfills are required by the app. This package is a tool for this purpose — to analyze the bundle code and find out which polyfills should be injected if the runtime does not provide them natively.
Install
npm i --save-dev bundlyzer
npm add -D bundlyzer
Usage
import fs from 'node:fs/promises'
import {bundlyzer} from 'bundlyzer'
const bundle = await fs.readFile('path/to/bundle.js', 'utf8')
await bundlyzer(bundle)
// →
{
runtime: 'browser', // 'node' | 'browser' | 'any'
// https://polyfill.io/v3/url-builder/
es2017: true
fetch: true,
URL: true
}
await bundlyzer(bundle, { es2017: true, es2021: true }) // {es2017: true}
License
0.0.0
2 years ago