Search code examples
javascriptbrowserifycommonjs

Exporting directly from another CommonJS module


I'm using CommonJS and Browserify, is there anything wrong with creating a module that all it does is to unite exports from other modules? For example:

var submodule1 = require('sub-module-1');
var submodule2 = require('sub-module-2');

module.exports = {
  widget1: submodule1.widget1,
  widget2: submodule2.widget2,
  widget3: submodule2.widget3,
};

Solution

  • No. There's nothing "wrong" with this. It's up to your discretion how best to modularize and package your code so that it makes the most sense for you, your colleagues and fellow developers.