Circular dependencies should work fine in Narwhal and any other
CommonJS-compliant module system.
The only issue (until we have module.exports/setExports) is if you
access a property which has not yet been defined in the module. e.x.
foo.js:
require("bar");
exports.baz = function() { print("ok"); }
bar.js:
var foo = require("foo");
foo.baz();
If you do require("foo") from another file the following happens:
1. foo.js is loaded, foo exports object created, and begins to be
executed
2. require("bar") gets called
3. bar.js is loaded, bar exports object created, and begins to be
executed
4. require("foo") is called
5. the module system see foo has already been loaded and is being
executed, so it returns foo's exports object
6. exports.baz has not yet been defined so you'll get an exception
Is this the problem you're experiencing? If not can you give me an
example?
-tom
> --
>
> You received this message because you are subscribed to the Google
> Groups "CommonJS" group.
> To post to this group, send email to
comm...@googlegroups.com.
> To unsubscribe from this group, send email to
commonjs+u...@googlegroups.com
> .
> For more options, visit this group at
http://groups.google.com/group/commonjs?hl=en
> .