Skip to content

Latest commit

 

History

History
 
 

polyfills

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

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'],
  })
]