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
open Format
open Dynlink
let () = try
print_endline "init";
Dynlink.init ();
print_endline "allowing unsafe modules";
Dynlink.allow_unsafe_modules true;
Dynlink.loadfile "/home1/h/hongboz/ocaml/lib/ocaml/stdlib.cma";
Dynlink.loadfile