In my project a typical structure of a file shared between client and
server looks like this.

This avoids using any precompilers for client side in development,
thus you get useful error messages with linenumbers just as they are.
It uses shared globals on browser javascript and proper requires for
server. For release mode I just concat all client files into one big
file, push it through uglify and gzip it. The order in which the files
are concated or added as <script> into the devel html can be important
for subclassing or so, but I just work that manually out.

This would be for "ModuleF" exporting the prototype "ModuleF"

/**
| Imports
*/
var ModuleA;
var ModuleB;
var ModuleC;

/**
| Exports
*/
var ModuleF;

/**
| Capsule
*/
(function() {
"use strict";

/**
| Node includes.
*/
if (typeof(window) === 'undefined') {
        ModuleA = require('./modulea');
        ModuleB = require('./moduleb');
        MoudleC = require('./modulec');
}

ModuleF = function(bla) {
   // code
};

ModuleF.prototype.foobar = function() {
  // code
};

// .. and so on ...

/**
| Node
*/
if (typeof(window) === 'undefined') {
        module.exports = ModuleF;
}

}());

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to