diff options
author | isaacs <i@izs.me> | 2011-07-29 22:56:05 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-07-29 22:56:38 +0400 |
commit | 703a1ffe52b66972f38db19fb68e0f70c3dd2631 (patch) | |
tree | c9c3c65d0706a42c990ad62d02d1861722704080 /lib | |
parent | bffb758243ca19d334696a07c8091cf5fb75fe7b (diff) |
Revert "AMD compatibility for node"
This reverts commit 9967c369c9272335bb0343558673b689725c6d7c.
Conflicts:
test/simple/test-module-loading.js
Diffstat (limited to 'lib')
-rw-r--r-- | lib/module.js | 39 |
1 files changed, 1 insertions, 38 deletions
diff --git a/lib/module.js b/lib/module.js index 6f32620e2c2..5a80c0fb2eb 100644 --- a/lib/module.js +++ b/lib/module.js @@ -374,7 +374,6 @@ Module.prototype._compile = function(content, filename) { require.cache = Module._cache; var dirname = path.dirname(filename); - var define = makeDefine(require, self); if (Module._contextLoad) { if (self.id !== '.') { @@ -391,7 +390,6 @@ Module.prototype._compile = function(content, filename) { sandbox.module = self; sandbox.global = sandbox; sandbox.root = root; - sandbox.define = define; return runInNewContext(content, sandbox, filename, true); } @@ -403,7 +401,6 @@ Module.prototype._compile = function(content, filename) { global.__filename = filename; global.__dirname = dirname; global.module = self; - global.define = define; return runInThisContext(content, filename, true); } @@ -415,44 +412,10 @@ Module.prototype._compile = function(content, filename) { if (filename === process.argv[1] && global.v8debug) { global.v8debug.Debug.setBreakPoint(compiledWrapper, 0, 0); } - - var args = [self.exports, require, self, filename, dirname, define]; + var args = [self.exports, require, self, filename, dirname]; return compiledWrapper.apply(self.exports, args); }; -// AMD compatibility -function makeDefine(require, module) { - var called = false; - function define() { - if (called) { - throw new Error("define() may only be called once."); - } - called = true; - - // only care about the last argument - var cb = arguments[ arguments.length - 1 ]; - - // set exports immediately: - // define({ foo: "bar" }) - if (typeof cb !== 'function') { - module.exports = cb; - return; - } - - var ret = cb(require, module.exports, module); - - if (ret !== undefined) { - // set exports with return statement - // define(function () { return { foo: "bar" } }) - module.exports = ret; - } - } - - return define; -} - - - // Native extension for .js Module._extensions['.js'] = function(module, filename) { var content = NativeModule.require('fs').readFileSync(filename, 'utf8'); |