#10687 closed bug (fixed)
jQuery calls the AMD define() global function too early
Reported by: | Owned by: | Timmy Willison | |
---|---|---|---|
Priority: | blocker | Milestone: | 1.7.1 |
Component: | core | Version: | 1.7 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
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 (8)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → core |
---|---|
Milestone: | None → 1.7.1 |
Priority: | undecided → blocker |
Status: | new → open |
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 12 years ago by
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 12 years ago by
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 12 years ago by
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 12 years ago by
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 12 years ago by
Owner: | set to Timmy Willison |
---|---|
Status: | open → assigned |
comment:8 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Landing pull request 586. Create exports.js for exporting jQuery to window and AMD. Fixes #10687.
More Details:
#10686 is a duplicate of this ticket.