Export all objects in node.js

A node.js module of mine got too big, so I split it into several smaller (sub)modules.

I copy & pasted all relevant objects into each of the submodules, which now look like

var SOME_CONSTANT = 10;

function my_func() { etc... };

Now I want to export everything in each submodule, en masse, without having to explicitly say exports.SOME_CONSTANT = SOME_CONSTANT a million times (I find that both ugly and error prone).

What is the best way to achieve this?

I assume you do not want to export every local variable.

I will get around to automating this one of these days, but for now I often use this technique.

 var x1 = { shouldExport: true  } ; 

// create a macro in your favorite editor to search and replace so that

x1.name = value ; // instead of var name  = value

and

name becomes x1.name   

// main body of module

for ( var i in x1) { exports.better_longer_name[i]   = x1[i] ;} 
//or if you want to add all directly to the export scope  
for ( var i in x1) {  exports[i] = x1[i] ; }  

module.exports = {
    SOME_CONSTANT_0 : SOME_CONSTANT_1 ,
    SOME_CONSTANT_1 : SOME_CONSTANT_2 ,
    SOME_CONSTANT_2 : SOME_CONSTANT_3
}

so why you need that "million" constant to exports?