TL; DR . How can I make a module (imported through ES6 syntax) globally (or refer to an imported class inside another class)?
I am importing a module from a package that was not implemented correctly (without export, etc.), but I am encountering some problems.
I use varto install the module in global (not big), for example.
var Example = require('./node_modules/example/long_path_to_file.js');
How do I need to use it in my class (the module takes control this, and class instances are not available in the global scope, so I can not use my class as usual):
new window.Example(...)
This works, but it’s not great since I use webpack and prefer to use the correct es6 syntax
import Example from './example';
and then in example.js
export default Example = require('./node_modules/example/long_path_to_file.js');
, , .
, window.Example = Example, .