{"issue":{"created_at":"2011-12-10T17:21:43Z","state":"open","updated_at":"2011-12-11T05:05:28Z","comments":2,"user":{"gravatar_id":"00ac28bdce61e7db41be57fb3b7f3525","id":73359,"url":"https://api.github.com/users/jrburke","avatar_url":"https://secure.gravatar.com/avatar/00ac28bdce61e7db41be57fb3b7f3525?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"jrburke"},"body":"This came up in this [pull request for CoffeeScript](https://github.com/jashkenas/coffee-script/pull/1826), where brequire may not be able to handle this form:\r\n\r\n```javascript\r\n    define(function () { });\r\n```\r\n\r\nI am a bit unclear on the part that fails for brequire -- it looks like brequire is used to generate a transport form of CommonJS modules for use in the browser. So is the concern that the transform step does not find these anonymous define calls or that brequire uses AMD in the browser wrapping code, and cannot process the anonymous require calls?\r\n\r\nA bundling tool for AMD libraries will need to name the anonymous define calls when bundling up the libraries.","assignee":null,"id":2511822,"labels":[],"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"number":3,"title":"Support for AMD define(function () { }); form","html_url":"https://github.com/weepy/brequire/issues/3","closed_at":null,"url":"https://api.github.com/repos/weepy/brequire/issues/3","milestone":null},"action":"created","comment":{"created_at":"2011-12-11T05:05:28Z","updated_at":"2011-12-11T05:05:28Z","user":{"gravatar_id":"00ac28bdce61e7db41be57fb3b7f3525","id":73359,"url":"https://api.github.com/users/jrburke","avatar_url":"https://secure.gravatar.com/avatar/00ac28bdce61e7db41be57fb3b7f3525?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"jrburke"},"body":"So part 2 compiles the commonjs modules? As in it wraps them in a define call? If so, for anonymous calls, like the above, insert the module ID as the first arg to define, if there is not a string literal there already.\r\n\r\nThen in the code that runs in the browser, when it receives a define call, you can check the arg types. Note that the AMD spec allows this kind of define too, just passing an object literal:\r\n\r\n```javascript\r\ndefine({\r\n    prop: 'value'\r\n});\r\n```\r\nSo for bundled modules, there should be at least two args, a string ID, and something else. If there is a dependency array, there will be three args. You could try testing arguments.length. If just two, then you know the dependency array is missing and the last arg is either a function or an object literal.\r\n\r\nIf I misunderstood the question though just let me know.","id":3095694,"url":"https://api.github.com/repos/weepy/brequire/issues/comments/3095694"}}