[dojo-contributors] deferredRequire extension

Sasha Firsov suns at firsov.net
Fri Jun 1 23:10:13 EDT 2012

Foloving http://bugs.dojotoolkit.org/ticket/15445, I am trying to make 
Deferred implementation of require
with same signature and semantics as original.
Since 8kb of Deferred not necessary fit into 'nano' and to make 
acceptance easier, initial draft meant to be external module rather 
patch to dojo.js

Is there the way of original require() runtime patching?

Unfortunately I was not able to find one. The require returned by module 
is closure-based and used for current module reference for relative path 

Since closure content is different for each module, the one which is 
retrieved from in deferredRequire module has no use for relative pathes 
of caller.
Which on one side forced me to pass module require as extra parameter 
and forces user to add "require" as additional dependency:

define( ["deferredRequire","require"], function( dr, require )
     dr(require).require( ["../myMod"] )
         .than( function(myMod){ ... })
         .fail(function errback(){ });

Which is working but kind of ugly.
Is there a way to alter original require behavior?
JS aspect on require function, AMD pluging, etc?

Patch of dojo.js seems easier :)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3861 bytes
Desc: S/MIME Cryptographic Signature
Url : http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20120601/20789454/attachment-0001.p7s 

More information about the dojo-contributors mailing list