Skip to content

Latest commit

 

History

History
49 lines (28 loc) · 1.48 KB

File metadata and controls

49 lines (28 loc) · 1.48 KB

polyfill-plan

Explicit polyfill planning helpers for JavaScript and TypeScript.

babel-polyfill belongs to the Babel 6 era and pulls in a broad ES2015+ environment. Modern projects are better served by explicit core-js and regenerator-runtime imports, or by Babel preset-env with useBuiltIns. This package helps migration scripts produce predictable polyfill entry files.

Install

npm install polyfill-plan

Usage

import { createPolyfillPlan, generatePolyfillEntry } from "polyfill-plan";

const plan = createPolyfillPlan({
  features: ["promise", "array-from", "object-assign"],
  includeRegenerator: true
});

console.log(generatePolyfillEntry(plan));

API

createPolyfillPlan(options?)

Returns { imports, warnings, features }.

generatePolyfillEntry(plan)

Creates import statements for a polyfill entry file.

replaceBabelPolyfillImports(source, plan)

Replaces simple import "babel-polyfill" and require("babel-polyfill") statements.

featureImport(feature)

Maps a known feature name to its core-js import.

Migration Position

polyfill-plan is an independent alternative or migration helper for projects moving away from babel-polyfill. It is not affiliated with the original package maintainers or project.

For release context, see the local migration guide, examples, compatibility notes, source metadata, and adoption plan.