Can I build a module that exports instantiated variables?
Module:
var module1 = require('module1')
var Module2 = require('module2')
module1.dosomething(variables)
exports.module1 = module1
//or
module2 = new Modle2(variables)
module2.dosomething(variables)
exports.module2 = module2
Can I require the module above in many other files and use the exports as instantiated variables or will they be re-instantiated every time I require them and not shared between the files requiring them.
Thanks!
Your example is confusing because you use module1 in multiple contexts, both as a module, a variable within another module, and an exported property of that module.
Think of modules as closures and exports as return values. Most likely you want to export a function/factory function and call that every time if you want to create new instances with the export, anything else will be shared since it just returns the object.
Module1
Other module