I recently switched from using Require.js to using WebPack with Babel. In the past I would use the CommonJS standard in my JS modules, like this
var $ = require('jquery');
require('bootstrap');
Since Bootstrap is a jQuery plugin, jQuery would load first and bootstrap would load second.
Babel allows me to use ES6 import statements. But when I write
import $ from 'jquery';
import Bootstrap from 'bootstrap';
I get the error that $ is undefined. Bootstrap assumes that window.$ is present, but import does not pollute the window object, which is a good thing, but leaves my code like this:
// legacy loading for bootstrap
var $ = require('jquery');
window.$ = $;
require('bootstrap');
// the rest of the imports
import _ from 'underscore';
There must be a better solution. Any help appreciated.
 
     
     
     
     
     
     
     
    