@lite-v3/polyfills

0.1.1 • Public • Published

@lite-v3/polyfills

A standard polyfill library for tokopedia web services

By Tokopedia Version

This module is only needed for webpack 4+.

Prerequisites

Webpack 4+

Install

# Using npm
npm install @lite-v3/polyfills

# Using yarn
yarn add @lite-v3/polyfills

# Using pnpm
pnpm install @lite-v3/polyfills

Usage

Add the following to your entry client file:

import requirePolyfills, { definePolyfills } from '@lite-v3/polyfills';

requirePolyfills(condition, function () {
  runYourService();
});

or if you have additional polyfills

import requirePolyfills from '@lite-v3/polyfills';

const customPolyfills = [
  {
    test: !(window.fetch || window.self.fetch),
    load: () => {
      return new Promise(resolve => {
        resolve(import(/* webpackChunkName: "unfetch-polyfill" */ 'unfetch/polyfill/index'));
      });
    },
  },
];

requirePolyfills(condition, definePolyfills(customPolyfills), function () {
  runYourService();
});

API

requirePolyfills(condition, callback)

parameter

condition: Boolean callback: () => void

definePolyfills(polyfills)

parameter

polyfills: { test: boolean, load: () => Promise<unknown> }[]}


Code By WPE Team @Tokopedia

Dependencies (6)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @lite-v3/polyfills

    Weekly Downloads

    872

    Version

    0.1.1

    License

    none

    Unpacked Size

    16.3 kB

    Total Files

    8

    Last publish

    Collaborators

    • miqdadfwz
    • maafaishal-tkpd
    • 1nd
    • skipper.team