Let's say I have an old school 3rd party javascript library in the following format, which effectively creates the global SomeModule
:
SomeModule.js
(function() { this.SomeModule = ... })();
I'd rather avoid the global and use ES6 syntax to import SomeModule
into just the files where I need it. I figure I can wrap the 3rd party library using something like this:
SomeModuleES6.js
var dummy; (function(){ require("SomeModule.js"); }.bind(dummy))(); export default dummy.SomeModule;
Files where
SomeModule
is neededimport SomeModule from "SomeModuleES6";
There's gotta be a better way though. Is there a standard practice for this situation? How would this work through WebPack and package.json? Should I just fork the 3rd party library and use my own updated version instead?