marijnh/tern — pull request #189 by sqs (2013-07-08 00:07:33+00:00)
Title: Support nested node.js module dependencies

This PR handles nested node.js module dependencies (e.g., mod1 requires mod2, which requires mod3, where mod3 is in `mod2/node_modules/mod3`). It includes both a test case (that fails pre-PR and passes post-PR) and a patch.

The patch is somewhat sketchy because it replaces the old `resolveModule` with one that uses private node.js API functions in the `module` module (e.g., https://github.com/joyent/node/blob/master/lib/module.js#L316).

Pros of using the private node.js module API:
* handles all of the edge cases
* much less code

Cons:
* might break on old or future versions of node.js
* it is easier for the `require` behavior to diverge from the non-node.js implementation in plugin/node.js

@marijnh, your call on whether to use this patch. Also, it could probably be optimized (by caching `currentModule` per-module), but I didn't want to spend too much time on it if you want to avoid using node.js private APIs. If you decline, I can work on a patch that modifies the existing `resolveModule` func and just try to stay on top of other edge cases.