Search code examples
requirejsamd

requireJS - Mismatched anonymous define() module in multipage shim


I'm following the multipage shim sharing pattern here: https://github.com/requirejs/example-multipage-shim

I'm using the same common.js and have a very similar and simple set up:

<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 running operations inside the require closure, but I keep getting an error in Firefox complaining about a mismatched anonymous define() module with the above code. Given how simple it is and that I'm following the example pattern pretty much exactly I'm a bit confused as to why I'm getting it. I haven't used define() anywhere. Has something in requireJS changed in the last 24 days (since the multipage git repo was updated)?


Solution

  • Answer was this, hopefully it helps someone:

    Given this was a big platform, lots of other stuff was being loaded outside of the require flow (we're slowly transitioning).

    Some of these assets, i.e. jquery 1.10, spin.js, etc., were compatible with AMD, and were calling define(). In the spin.js case, it was calling define() anonymously, which was tripping up the loading as is explained in the second point of the Mismatched Anonymous error in the resolve docs.

    Good grief.