@regru/webpack-babel-multi-target-plugin
Version:
A Webpack plugin that works with Babel to allow deployment of ES2015 builds targeted to modern browsers, with an ES5 fallback for legacy browsers.
25 lines (23 loc) • 611 B
JavaScript
/* eslint-env browser */
/**
* nomodule fix for Safari 10.1
* from https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc
*/
(function() {
const check = document.createElement('script')
if ('onbeforeload' in check) {
let support = false
document.addEventListener('beforeload', function(e) {
if (e.target === check) {
support = true
} else if (!e.target.hasAttribute('nomodule') || !support) {
return
}
e.preventDefault()
}, true)
check.type = 'module'
check.src = '.'
document.head.appendChild(check)
check.remove()
}
}())