+1

In most cases a circular require is not what you want
Sent on the TELUS Mobility network with BlackBerry

-----Original Message-----
From: Andrew Grieve <[email protected]>
Date: Mon, 20 Aug 2012 13:12:42 
To: <[email protected]>
Reply-To: [email protected]
Subject: Circular require()s

Our module system currently allows cycles. However, the result of a cycle
is often not what you'd want. What we do when defining modules is:

module.exports = {};
factory(module) // either adds properties to or clobbers module.exports
return module.exports;

So, cycles in require()s will work only when:
a) exports is extended instead of clobbered, and
b) the result of the require is not used at the modules scope.

I think these restrictions are too hard to get right, and that we should
just make require cycles an error. Objections?

Andrew


Reply via email to