This package includes several configurations for required polyfills for Calypso, targeting three different environments: node, evergreen (newer browsers) and fallback (older browsers).
calypso-polyfills ties into the Calypso build process, to ensure that only the required polyfills for each build target are needed. Through the use of Babel's
browserslist configurations, we strip out any polyfills that are supported for all browsers that are supported by that build target.
See the root directory's
package.json for the list of supported browsers for each build target.
In Node.js, simply require the package:
require( '@automattic/calypso-polyfills' );
In a browser, a similar naked import will include the polyfills (defaulting to the
import from '@automattic/calypso-polyfills';
If you want to explicitly include the
fallback polyfills, you can append to the import path:
import from '@automattic/calypso-polyfills/browser-evergreen'; import from '@automattic/calypso-polyfills/browser-fallback';