RequireJS - Inappropriate anonymous define () module in multi-page layout

I follow the multi-page pad sharing pattern here: https://github.com/requirejs/example-multipage-shim

I use the same common.js and have a very similar and simple setup:

<script src="js/library/requirejs/require.min.js"></script> <script> require(['./js/config/common'], function (common) { //go on... }); </script> 

Everything loads fine, and I can continue to perform operations inside the closing of the request, but I continue to receive an error in Firefox complaining about an inconsistent anonymous module define () with the above code. Given how simple it is and that I follow the pattern example pretty much exactly, I'm a little confused about why I get it. I have not used define () anywhere. Has something been replaced in requireJS in the last 24 days (after updating the multi-page git repository)?

+6
source share
2 answers

The answer was, I hope this helps someone:

Given that it was a large platform, many other things loaded outside the required stream (we are slowly moving on).

Some of these assets, i.e. jquery 1.10, spin.js, etc., were AMD compatible and called define (). In the case of spin.js, it called the anonymous definition of definition (), which included loading, as explained in the second point of the Mismatched Anonymous error in the permission documents.

Good grief.

+7
source

Clearly what is happening. You are trying to load a module, but your common.js only has require.config and no module. Therefore, an updated RequireJS (not Firefox) causes an error. Include the definition in your generic JS and the error should go away.

 // common.js stuff... define({}); 
0
source

Source: https://habr.com/ru/post/946434/


All Articles