How to use @babel/polyfill - 1 common examples

To help you get started, we’ve selected a few @babel/polyfill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Atyantik / pawjs / src / components / Html.tsx View on Github external
import React from 'react';
import BabelPolyfill from '@babel/polyfill/package.json';
import { metaKeys } from '../utils/seo';

/**
 * CDN Packages for ReactJS and PolyfillJS
 */
const reactCDN = [
  `https://unpkg.com/react@${React.version}/umd/react.production.min.js`,
  `https://unpkg.com/react-dom@${React.version}/umd/react-dom.production.min.js`,
];
const polyfillVer = BabelPolyfill.version > '7.6.0' ? '7.6.0' : BabelPolyfill.version;
const polyfillCDN = [
  `https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/${polyfillVer}/polyfill.min.js`,
];

/**
 * toBase64: atob polyfill with Buffer
 */
let toBase64: (arg0: string) => string;
// Base64 polyfill
if (typeof atob === 'undefined' && typeof Buffer !== 'undefined') {
  toBase64 = (str) => {
    if (!str) return str;
    return Buffer.from(str, 'latin1').toString('base64');
  };
} else if (typeof atob !== 'undefined') {
  toBase64 = atob;

@babel/polyfill

Provides polyfills necessary for a full ES2015+ environment

MIT
Latest version published 4 years ago

Package Health Score

72 / 100
Full package analysis

Popular @babel/polyfill functions