-
Notifications
You must be signed in to change notification settings - Fork 890
define should be anonymous #472
Conversation
Why is an anonymous define preferable? |
@mikesamuel define should either be anonymous or match the npm+bower name. Because these are now different you need to use anonymous define. |
It makes it very difficult to include a package in your build system if it's not an anonymous define. When it's named, your build system either needs to detect that (it usually doesn't) and alias local imports for you, or you need to explicitly map the defined name to the file location, so you that you can still import it. It actually causes enough issues that there's a dedicated page for RequireJS explaining how to use jQuery with it. |
Ok. I see
// THIS WILL NOT WORK
define(['lib/jquery'], function ($) {...});
|
This looks good to me. @amroamroamro has a number of large patches in flight so I'm not going to merge yet. It's much easier to redo a one liner manually than to merge one into a multi-file multi-commit PR. |
@mikesamuel that's definitionally false. You can transform the problem of |
@mikesamuel patches 3 and 4 (demos and tests) are ready to merge if there are no further reviews/comments. |
Now I'm thinking out loud, but do we need to keep the AMD What is the convention these days regarding module loaders, bundlers, and such? I don't want to propose any major changes for now, just to get an idea. Also keep in mind that the source is fed to closure-compiler, so these solutions would have to be compatible with that, which can be tricky at times in ADVANCED compilation mode. |
@graingert I remembered, you need to also update the definition in amd-externs.js for this PR, otherwise you'll get a warning from closure-compiler.
In fact, the first line One more thing, you must not manually edit |
I'm not up on DARCS theory of patches, but I do know that if I try to apply a single line patch after merging a change that changes indentation of the block containing it, then I have to do more work. |
I'd marked them approved through the code review interface. I'm happy to do the merge though. |
@mikesamuel oh noted. I wasn't sure if you wanted me to do the merge, thanks. |
@mikesamuel glorious. can we get a |
No description provided.