support native es6 module loading
Created by: rpokrovskij
Bootstrap 4.3 (budnle from dist folder) fails when global is null.
From sources:
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jquery'), require('popper.js')) :
typeof define === 'function' && define.amd ? define(['exports', 'jquery', 'popper.js'], factory) :
(factory((global.bootstrap = {}),global.jQuery,global.Popper));
}(this, (function (exports,$,Popper) {...});
There this
from next line can't be null since we will get an excpetion on global.bootstrap = {}
And there are situations when this
can be null during loading e.g. importing using native module support:
<script type="module">
import Popper from "./js/popper.js"; // esm version
window.Popper = Popper;
import "./js/bootstrap.js"; // TODO : error
// expected : window.bootstrap created , plugins attached to jquery etc.
</script>
Check sources of jquery. They support this new type of loading by checking (this==null)?window:this.