I have this situation where I am trying to import an existing library, which I\'ll call troublesome
(using Webpack/Babel FWIW) and it has a global reference to
Importing jQuery
into your module does not make it available for 'troublesome'
. Instead, you could create a thin wrapper module for 'troublesome'
that provides jQuery
and any other required "globals".
troublesome-module.js:
// Bring jQuery into scope for troublesome.
import jQuery from 'jquery';
// Import any other 'troublesome'-assumed globals.
// Paste or have build tool interpolate existing troublesome.js code here.
Then in your code you should be able to
import 'troublesome-module';