Skip to content

Instantly share code, notes, and snippets.

@borismus
Created August 3, 2011 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borismus/1123866 to your computer and use it in GitHub Desktop.
Save borismus/1123866 to your computer and use it in GitHub Desktop.
shared client/server javascript for node.js
load in node:
require('../common/module.js');
load in browser:
<script src="../common/module.js"></script>
module.js:
(function(exports) {
var MyClass = function() { /* ... */ };
var myObject = {};
exports.MyClass = MyClass;
exports.myObject = MyObject;
})(typeof global === "undefined" ? window : exports);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment