mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix: fix non standard esm modifications
This commit is contained in:
parent
5ec5932bad
commit
fb87a559c2
@ -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()}}();`
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user