1.1.1 • Published 6 years ago

polywrath v1.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

polywrath

Include JavaScript polyfills (core-js) based on usage and wanted browsers (browserslist).

const polyfills = require("polywrath")({
   contents: "alert(typeof Symbol)",  // String(s) to scan. Optional if .src set.
   src: "source.js",                  // Path(s) to scan. Optional if .contents set.
   dest: "polyfills.js",              // Synchronously output to file. Optional.
   browsers: "ie > 9",                // Browserslist query.
   exclude: ["es6.symbol"],           // Polyfills from `core-js/modules/` not to include. Optional.
   module: "cjs",                     // Module format; "es" or "cjs" (default).
   root: "../.."                      // Relative path to directory with node_modules. Defaults to ".".
})
// source.js
Promise.resolve(Symbol())
// polyfills.js
require("../../node_modules/core-js/modules/es6.symbol");
require("../../node_modules/core-js/modules/es6.promise");

The entire code is transformed with babel 7, polyfills are extracted and everything else dismissed.

The package is shipped with core-js.