Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mismatched anonymous define for jQuery plugin example #11

Closed
akre54 opened this issue Jan 23, 2013 · 5 comments
Closed

mismatched anonymous define for jQuery plugin example #11

akre54 opened this issue Jan 23, 2013 · 5 comments

Comments

@akre54
Copy link

akre54 commented Jan 23, 2013

I tried following the jquery plugin example with the jQuery plugin for valums/file-uploader (see akre54/file-uploader@6972e0e) but got a "Uncaught Error: Mismatched anonymous define() module:" error, where the rest of the code block printed to the console.

Can you give me some pointers on what I might be doing wrong? requirejs version is 2.1.2. Thanks!

@jrburke
Copy link
Member

jrburke commented Jan 23, 2013

This usually happens if there is a requirejs on the page, but the script is loaded by just a plain HTML script tag, and not loaded by requirejs. Anonymous modules need to be loaded via a require/define call to properly resolve their IDs.

Closing as I believe that is the issue, but we can continue discussion and reopen as necessary.

@jrburke jrburke closed this as completed Jan 23, 2013
@akre54
Copy link
Author

akre54 commented Jan 23, 2013

Yup, that's the case. But it would seem that this particular shim is broken then, no? A plugin distributor can't assume that jQuery was loaded through require, nor that the plugin was requested through a require call if it's merely loaded on the same page. Any fix to this?

@jrburke
Copy link
Member

jrburke commented Jan 23, 2013

The plugin can insert a name in the define call define('myplugin', ....); but that forces consumers of that plugin to use that ID to refer to that module.

However, normally, either an AMD loader is in play or it is not. If the plugin should not be registered with the AMD loader, then the plugin can be loaded before the AMD loader is loaded. If the plugin should be loaded with the AMD loader, then it should get loaded after the AMD loader loads, via the require/define call. Those are about the only set of options since there are not encapsulated loading containres (ES modules will have them).

@akre54
Copy link
Author

akre54 commented Jan 23, 2013

got it. Thanks for the fast response.

@dustinlarimer
Copy link

@jrburke how would you recommend a vendor script be authored if there's no way to control when, where or how we're loaded into a page?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants