polyfill-service-webpack

0.1.0 • Public • Published

PolyfillServicePlugin

This is a webpack plugin that detects required polyfills using autopolyfiller and loads them from Polyfill service.

Installation

npm install polyfill-service-webpack

and then add the PolyfillServicePlugin to the webpack config:

var PolyfillServicePlugin = require("polyfill-service-webpack");
var webpackConfig = {
    plugins: [
        new PolyfillServicePlugin({
            minify: true,
            callback: "onPolyfillsLoaded",
            defaultFeatures: {
                "Object.assing": ["always"],
            },
            flags: [],
            libVersion: ">0.0.0",
            unknown: "polyfill",
        }),
    ],
};

After that, you can invoke the special function __load_polyfills__ from your JS:

// request the polyfills
var polyfillsLoaded = __load_polyfills__();
 
polyfillsLoaded(function () {
    // do something when the polyfills have loaded
});

Options

minify

  • type: boolean.
  • default: false.

Whether to minify the result. If false, debugging information will be inserted.

callback

  • type: string.
  • default: onPolyfillsLoaded.

What name to use for the global callback triggered when the polyfills have loaded.

defaultFeatures

  • type: object.
  • default: {}.

A map of features to include regardless of whether they're detected. The keys are the feature names and the values are arrays of flags to apply. See the docs for further information about the flags.

flags

  • type: array.
  • default: [].

A list of flags to apply to every feature.

libVersion

  • type: string.
  • default: empty.

Version of the polyfill collection to use. Accepts any valid semver expression. If not specified, the latest version of the library is used.

unknown

  • type: string
  • default: empty

What to do when the user agent is not recognized. See the docs.

Package Sidebar

Install

npm i polyfill-service-webpack

Weekly Downloads

1

Version

0.1.0

License

ISC

Last publish

Collaborators

  • jussi-kalliokoski