We have a Node.js widget that gets exported like so:
module.exports = ourWidget;
I then import it into our server.js like so:
var ourWidget = require('./ourWidget');
var ow = new ourWidget;
This works as expected, but could it be done in a single line? EG:
var ow = new (require('./ourWidget'));
Which doesn't work, I've also tried this:
var ow = new (require('./ourWidget')());
Both of which resembles the code in this SO question: How does require work with new operator in node.js?, but both fail as soon as I try to run the code.