Skip to content

Instantly share code, notes, and snippets.

@richmarr
richmarr / index.js
Created August 3, 2011 09:04
Export all JS modules in a directory as submodules
/*
I found it handy to reduce the amount of manual require() lines in a big
project by grouping small modules together like below.
If you put this code into "index.js" then it'll pick up any other
JS modules in that directory and expose them as sub-modules.
- Any exports in *this* module would be myPackage.exportName
- Any exports in other modules would be myPackage.moduleName.exportName