npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@goodforonefare/polyfills

v1.1.4-4

Published

Blessed polyfills for web platform features.

Downloads

5

Readme

@shopify/polyfills

Build Status License: MIT npm version npm bundle size (minified + gzip)

Blessed polyfills for web platform features. Exports browser, node, and Jest/ JSDom polyfills where appropriate.

The following polyfills are currently provided:

  • base: ensures that all necessary JavaScript language features are polyfilled, including Map, Set, async functions, Symbol, and more.
  • fetch: Ensures a global WHATWG fetch function is available.
  • formdata: Ensures FormData is available globally (browser/ JSDom only).
  • idle-callback: Ensures requestIdleCallback and cancelIdleCallback are available globally (browser/ JSDom only).
  • intersection-observer: Ensures IntersectionObserver is available globally (browser/ JSDom only).
  • intl: Ensures Intl.PluralRules is defined.
  • mutation-observer: Ensures MutationObserver is available globally (browser/ JSDom only).
  • unhandled-rejection: Ensures that unhandledRejection events are triggered (browser only).
  • url: Ensures URL and URLSearchParams are available globally.

Installation

$ yarn add @shopify/polyfills

Usage

All you need to do is import the polyfills you use in your application:

import '@shopify/polyfills/base';
import '@shopify/polyfills/fetch';
import '@shopify/polyfills/url';

In apps rendered on the client and server, we recommend importing these polyfills only once, in your top-level app component. Because this component is likely to be imported first by both the server and client bundles, the polyfills will be available throughout the application code. However, you may also need to import these files earlier in the execution of a Node server (if your server code uses features like fetch outside of the application). You will also likely need to import these in your test setup files, as most tests will not import the root app component.

Build configuration

This package also provides a way to configure your bundler to remap polyfill imports based on the environment being built. This allows you to import polyfills you need without worrying about whether they should be omitted in some cases, or omitted entirely. sewing-kit uses this feature automatically to ensure correct polyfills for tests, server builds, and client builds.

To make use of this feature, call mappedPolyfillsForEnv, exported from the root of this project, and pass in the environment being targeted. The environment must be one of node, jest, or a list of supported browsers (supplied as a browserslist-compatible query).

The following example shows how to use this feature to define Webpack aliases:

import {mappedPolyfillsForEnv} from '@shopify/polyfills';

// Server
module.exports = {
  resolve: {
    alias: mappedPolyfillsForEnv('node'),
  },
};

// Client
module.exports = {
  resolve: {
    alias: mappedPolyfillsForEnv(['last 2 versions']),
  },
};