I want to achieve the following setup:
// app.js
(function () {
const add = function() {
// add
}
const substract = function() {
// substract
}
require('./module1');
require('./module2');
})()
// module1.js
add();
substract();
The problem is that when the functions are called from within the module1.js, they are undefined (all this is bundled with webpack).
I know the solution of "exporting" and "importing" between the various modules/files. I am just wondering if I can I achieve this setup in order to avoid imports in the many modules that I use (imagine, for example, having to import them to 50 modules/files).
What is the proper way to achieve this setup (if possible)?
Thanx in advance.