Skip to content

Latest commit

 

History

History
39 lines (32 loc) · 970 Bytes

README.md

File metadata and controls

39 lines (32 loc) · 970 Bytes

Polyfills!

The polyfills contained in this folder can be imported as necessary. They should export either the builtin native function(s), if found on the global, or the polyfill itself.

Usage

In code

const Promise = require('bv-ui-core/lib/polyfills/promise')
// Do things with the Promise polyfill!
const myPromise = new Promise((resolve, reject) => {/*...*/})
const { fetch, Headers } = require('bv-ui-core/lib/polyfills/fetch')
// Do things with the fetch polyfill!
fetch(url, {
  headers: new Headers({
    'Accept': 'application/json',
  }),
}).then(myCallback)

In webpack

plugins: [
  // Any references to these items in the bundle will be wrapped in
  // references to their respective polyfill module exports.
  new webpack.ProvidePlugin({
    Promise: 'bv-ui-core/lib/polyfills/promise',
    fetch: ['bv-ui-core/lib/polyfills/fetch', 'fetch'],
    Headers: ['bv-ui-core/lib/polyfills/fetch', 'Headers'],
  })
]