I am building my bundle using Browserify.
I have the following service.js:
(function (exports, require) {
// ...
var Service = function (name, region) {
this.name = name;
this.region = region;
// ...
}
exports = Service;
})(module.exports, require);
Whenever I try to require('./service') on another module, I get an empty object as if the exports object was never set.
If I use module.exports without the argument encapsulation, everything works fine:
(function (require) {
// ...
var Service = function (name, region) {
this.name = name;
this.region = region;
// ...
}
module.exports = Service;
})(require);
Why does this happen and why is this required?