requirejs / almond

A minimal AMD API implementation for use after optimized builds
Other
2.42k stars 169 forks source link

Fails to require module without callback from inside another module #87

Closed ungesaeuertesbrot closed 10 years ago

ungesaeuertesbrot commented 10 years ago

When issuing a require(['foo']) call (i.e. without a callback) from within a module, e.g.

define('foo', function () { require(['bar']); });

the require function generated by makeRequire will call req with a wrong second argument (callback) -- namely relName will get passed here. This is because it silently assumes arguments to be 2 or 3 items long if deps is an array. req then does not replace the now (wrongly) defined callback with a noop and passes the relName as a callback to main instead (and undefined for relName). Subsequently, loading of the module fails.