unscriptable/curl — pull request #45 by dvdotsenko (2012-01-08 05:55:21+00:00)
Title: Curl.js stops blowing up when AMD-compatible modules are loaded outside of Curl.js

...p Curl.js

Per conversation on AMD Implement list (http://groups.google.com/group/amd-implement/browse_thread/thread/540b4e208c95aceb/626f17f238d244a9#626f17f238d244a9), one "trouble" scenario was discussed that was used as justification for making jQuery, underscore etc. named modules.

The justification was: When AMD-compatible code is loaded outside of AMD-loader, anon modules make AMD loaders blow up.

This indeed happened to Curl.js

I set up a simple simulation of such event here: https://github.com/dvdotsenko/AMDLoaderTests

test3.html is the one that makes (unmodified) Curl.js blow up. The first commit in that repo = unmodified curl.js => blow up. Second commit = modified curl => no blow up.

(Happens because anon define( is called in module, but this call happens outside of any require(. Code is just loaded in-line through SCRIPT tag. Then, any attempt to load ANY OTHER anonymous module detects args stuck in argsNet and makes an unhappy face)

Is it really important to detect nested anon defines and blow up upon detection? What's wrong with using the last one and just roll with it?