Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aofl/polyfill-service

Package Overview
Dependencies
Maintainers
2
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aofl/polyfill-service

Uses dynamic imports to load polyfills

  • 3.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

@aofl/polyfill-service

Implements a customized version of @webcomponents/webcomponentsjs/webcomponents-loader.js that uses dynamic imports to load polyfills. It also allows for lazy loading other polyfills based on a config file.

Api Documentation

Installation

npm i -S @aofl/polyfill-service

Config file

// sample-config.js
export default {
  'Object.assign': () => import('@aofl/polyfill-service/src/object-assign-polyfill'),
  'fetch': () => import('isomorphic-fetch'),
  'Reflect': () => import('harmony-reflect'),
  'Array.prototype.find': () => import('array.prototype.find'),
  'html-imports': {
    test() {
      return !('import' in document.createElement('link'));
    },
    load: () => import('@webcomponents/webcomponentsjs/webcomponents-bundle')
  }
};

Usage

// init-polyfill-service.js
import {Polyfill} from '@aofl/polyfill-service';
import polyfills from './sample-config';

const ready = Polyfill.loadAll(polyfills); // promise

export default ready;

polyfill.loadAll() returns a promise. In addition to this WebComponentsReady is fired once all promises are loaded.

Gotchas

If using webpack you will have to use imports-loader to fix the global variable in webcomponents polyfills.

// webpack.config.js
...
  module: {
    rules: [
      {
        test: /@webcomponents/,
        loader: 'imports-loader?this=>window'
      },
    ]
  }
...

Keywords

FAQs

Package last updated on 03 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc