Friday, June 10, 2011

Latest RequireJS throws Mismatched anonymous require.def modules

Symptoms
Latest RequireJS throws Mismatched anonymous require.def modules

Here is a list of known situations where this error can occur:

1) You are using the loader plugins or other anonymous modules in your code, but you do not use the RequireJS optimizer to concatenate files. The RequireJS optimizer knows how to name anonymous modules to avoid this error.

2) If you manually code a script tag in HTML to load a script with an anonymous define() call, this error can occur.

3) Also seen if you manually code a script tag in HTML to load a script that has a few named modules, but then try to load an anonymous module that ends up having the same name as one of the named modules in the script loaded by the manually coded script tag.

And if you are upgrading from older versions, you may be still using require.def() function, try to change to use the define() function instead.  And also, for your modules that using define() function, please check if you are using order!,  you probably want to take that out.  In the old version require.def() won't throw error when you use order!, but after I upgrade to the latest version, and it throws error when I include order! in my define() function.  So in my case, it fixed after I took out all the order! from my define() function. I believe the order! is not suppose to go into the define() function, as I didn't see that mention at all in the documentation.

For more information, please read the RequireJS documentations.

No comments:

Post a Comment