fix: fix non standard esm modifications

This commit is contained in:
pooya parsa 2019-02-06 22:28:36 +03:30
parent 5ec5932bad
commit fb87a559c2
2 changed files with 8 additions and 6 deletions

View File

@ -8,6 +8,9 @@ import EventEmitter from 'events'
const assetsMap = {}
const watcher = new EventEmitter()
// https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc
const safariFix = `!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();`
export default class ModernModePlugin {
constructor({ targetDir, isModernBuild }) {
this.targetDir = targetDir
@ -97,12 +100,9 @@ export default class ModernModePlugin {
// inject Safari 10 nomodule fix
data.html = data.html.replace(
/(<\/body\s*>)/i,
match => `<script>${ModernModePlugin.safariFix}</script>${match}`
match => `<script>${safariFix}</script>${match}`
)
})
})
}
}
// https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc
ModernModePlugin.safariFix = `!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();`

View File

@ -34,6 +34,10 @@ export default class PerfLoader {
PerfLoader.warmup(options.css, ['css-loader'])
}
static warmup(...args) {
warmup(...args)
}
use(poolName) {
const loaders = []
@ -59,5 +63,3 @@ export default class PerfLoader {
return loaders
}
}
PerfLoader.warmup = warmup