Skip to content

Instantly share code, notes, and snippets.

View bobzhang's full-sized avatar
🎯
Focusing

Hongbo Zhang bobzhang

🎯
Focusing
View GitHub Profile
@bobzhang
bobzhang / define-node.js
Last active August 29, 2015 14:27 — forked from neonstalwart/define-node.js
Add AMD/define() support to NodeJS
// Credit: this is derived from a combination of
// - https://gist.github.com/650000
// - https://github.com/joyent/node/pull/350
// - https://github.com/ajaxorg/cloud9/blob/master/support/requireJS-node.js
var path = require('path'),
fs = require('fs'),
defaultCompile = module.constructor.prototype._compile,
defaultResolveFilename = module.constructor._resolveFilename,
// this gives the main module a chance to use define iff it does so before any other module