mirror of https://github.com/nodejs/node.git
Fix: Module cache did not propagate
This patch makes sure nested modules are available in their parents
cache. The module simplification broke this behavior.
See:
http://groups.google.com/group/nodejs/browse_thread/thread/e875132469547d2
b73f61a137
v0.7.4-release
parent
3337e9da1a
commit
b02b54e003
|
@ -48,12 +48,12 @@ function Module (id, parent) {
|
|||
this.exports = {};
|
||||
this.parent = parent;
|
||||
|
||||
this.moduleCache = {};
|
||||
|
||||
if (parent) {
|
||||
process.mixin(this.moduleCache, parent.moduleCache);
|
||||
this.moduleCache[parent.id] = parent;
|
||||
this.moduleCache = parent.moduleCache;
|
||||
} else {
|
||||
this.moduleCache = {};
|
||||
}
|
||||
this.moduleCache[this.id] = this;
|
||||
|
||||
this.filename = null;
|
||||
this.loaded = false;
|
||||
|
|
|
@ -4,6 +4,7 @@ debug("load fixtures/a.js");
|
|||
|
||||
var string = "A";
|
||||
|
||||
exports.SomeClass = c.SomeClass;
|
||||
|
||||
exports.A = function () {
|
||||
return string;
|
||||
|
|
|
@ -10,6 +10,10 @@ debug("load fixtures/b/c.js");
|
|||
|
||||
var string = "C";
|
||||
|
||||
exports.SomeClass = function() {
|
||||
|
||||
};
|
||||
|
||||
exports.C = function () {
|
||||
return string;
|
||||
};
|
||||
|
|
|
@ -3,6 +3,7 @@ process.mixin(require("./common"));
|
|||
debug("load test-module-loading.js");
|
||||
|
||||
var a = require("./fixtures/a");
|
||||
var c = require("./fixtures/b/c");
|
||||
var d = require("./fixtures/b/d");
|
||||
var d2 = require("./fixtures/b/d");
|
||||
// Absolute
|
||||
|
@ -33,6 +34,8 @@ assert.equal("D", d3.D());
|
|||
assert.equal(true, d4.D instanceof Function);
|
||||
assert.equal("D", d4.D());
|
||||
|
||||
assert.ok((new a.SomeClass) instanceof c.SomeClass);
|
||||
|
||||
debug("test index.js modules ids and relative loading")
|
||||
var one = require("./fixtures/nested-index/one"),
|
||||
two = require("./fixtures/nested-index/two");
|
||||
|
@ -41,6 +44,7 @@ assert.notEqual(one.hello, two.hello);
|
|||
debug("test cycles containing a .. path");
|
||||
var root = require("./fixtures/cycles/root"),
|
||||
foo = require("./fixtures/cycles/folder/foo");
|
||||
assert.equal(root.foo, foo);
|
||||
assert.equal(root.sayHello(), root.hello);
|
||||
|
||||
var errorThrown = false;
|
||||
|
|
Loading…
Reference in New Issue