Skip to main content

core-web

What is core-web?

core-web is a set of tools to bundle polyfills together with your javascript code. Just define a browsers list and automatically receive everything you need.

Installation

Shell

npm install --save-dev @mrhenry/babel-plugin-core-web

Usage

Config

/* babel.config.js */
module.exports = function(api) {
	api.cache(true); /* optionally cache the config */

	return {
		plugins: [
			// A custom browserslist config :
			["@mrhenry/core-web", {
				browserslist: [
					"last 2 versions",
					">0.5%"
				]
			}]
		]
	};
};

See more example setups

Why use core-web?

Fully automatic

Needed polyfills are detected in your source code.

Just define your browser targets and start writing features.

One less blocking http request

Most visitors use a modern browser which doesn't need any polyfills.

Only your bundle(s) for older browsers will include polyfills, allowing you to optimize performance for modern browsers.

One less point of failure

Any external client-side dependency has some inherent risk.

Bundling polyfills removes this dependency on a 3rd party provider.

Reproducible builds

When an external polyfill provider changes or updates code they potentially introduce bugs (or unexpected fixes) impacting your code.

Packaging polyfills with your code adds an extra level of checks to prevent unwanted changes.

Sourcemaps

Because your build tool sees every polyfill file, you can have sourcemaps.

This makes it easier to debug and report issues.