Ticket #10687 (closed bug: fixed)
jQuery calls the AMD define() global function too early
| Reported by: | john@… | Owned by: | timmywil |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.7.1 |
| Component: | core | Version: | 1.7 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Hey guys!
Sorry I didn't discover this until after release. :(
jQuery shouldn't call the global AMD define() function until jQuery is fully defined. By "fully defined" I mean jQuery and all of its core helpers such as jQuery.Deferred, jQuery.Callbacks, etc.
Since jQuery doesn't expose these to AMD as individual modules, other AMD modules have to assume that they are defined when the jQuery object itself is defined.
See jsFiddle: http://jsfiddle.net/unscriptable/GqfFM/
The easiest solution, imho, is to place the call to define() at the very end of the file.
Regards,
-- John "@unscriptable" Hann
Change History
comment:2 Changed 19 months ago by timmywil
- Priority changed from undecided to blocker
- Status changed from new to open
- Component changed from unfiled to core
- Milestone changed from None to 1.7.1
Thanks John! We'll get a fix in for 1.7.1.
I'd like to have tests for as many amd loaders as possible for the next release, including curl.js and require.
comment:3 Changed 19 months ago by jrburke
I would like to discuss this on the amd-implement list first before a patch is applied. Normally an AMD loader needs to wait for the script to be defined for an anonymous module, so I think it may be useful to just standardize on that behavior even for named modules, more consistent execution behavior. I also thinks it makes it easier for libaries to implement calling AMD, less reworking of their codebase.
I will post back with a link to the amd-implement discussion once it gets set up.
comment:4 Changed 19 months ago by jrburke
Link to the amd-implement discussion I just started, for future reference:
https://groups.google.com/group/amd-implement/browse_thread/thread/a2b113e38a42ea01
comment:5 Changed 19 months ago by jrburke
In the amd-implement thread, John makes a good case that an AMD loader should consider the module completely constructed once the factory function has finished. So I worked up the following patch for this ticket:
comment:6 Changed 19 months ago by jrburke
A new pull request was done for this ticket based on feedback from timmywil:
https://github.com/jquery/jquery/pull/586
This one replaces #584.
comment:7 Changed 18 months ago by dmethvin
- Owner set to timmywil
- Status changed from open to assigned
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

#10686 is a duplicate of this ticket.