http-vue-loader
http-vue-loader copied to clipboard
Use 'self' if 'root' is undefined
I try to load libs with import():
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script>
function bootstrap() {
// load all libraries then create & start application
Promise.all([
import("./lib/http_vue_loader.js"),
import("./lib/vue-router.js"),
import("./lib/vue_esm_browser.js"),
]).then(([modLoader, modRouter, modVue, ...other]) => {
debugger;
});
}
window.addEventListener("load", () => bootstrap());
</script>
</head>
<body>
</body>
</html>
but root is undefined in this case:
(function umd(root,factory){
if(typeof module==='object' && typeof exports === 'object' )
module.exports=factory()
else if(typeof define==='function' && define.amd)
define([],factory)
else
root.httpVueLoader=factory()
})(this,function factory() {...});
and I have an error "Cannot set property 'httpVueLoader' of undefined" at
root.httpVueLoader=factory()
vue-router.js uses self in the same situation.