substack/wreq — Issue #1: requires with expressions fail to load
Author: nanodocumet
Created: 2012-02-18 09:46:47+00:00
State: open

Right now `detective` returns only the modules that are strings but not the expressions, thus, something like this will not work (taken from the example):

var b = 'boop';
var boop = require('./'+b+'.js');

instead of (this one works)

var boop = require('./boop.js');

I got to the point to understand that wreq gets all dependencies found using `require` before running the code itself. However, at line 4884 (https://github.com/substack/wreq/blob/master/wreq.js#L4884) an error will be thrown because `src.requires[p]` is undefined (was not fetched because was an expression, not an string).

I believe we should fetch the new file before returning the `exports` from that module, but `fetch` is a asynchronous call, thus, the return of `m.exports` (line 4887: https://github.com/substack/wreq/blob/master/wreq.js#L4887) happens before the module is fully loaded.

Any hints? Any plans on implementing this?

Thanks,

Nano.