Reputation: 183
I made a nice folder structure with the use of require and require in require in javascript. As the require in require needs all functions to be included again I was wondering if there are easier ways to do this.
var file2 = require('./file2.js');
var IncludeAll={
func1: function(msg){
return file2.function1(msg);
},
func2: function(msg){
return file2.function2(msg);
}
};
module.exports = IncludeAll;
Upvotes: 0
Views: 66
Reputation: 41
You can create a exporter script "exporter.js" file like below.
// exporter.js
module.exports = {
File2: require('./file2'),
File3: require('./file3')
}
Then you can import and call like this.
const {File2} = require('./exporter')
const param = 5;
File2.func1(param);
File2.func2(param);
Upvotes: 1