Reputation: 7729
I've got a bug with requireJS and ie8 :
Mismatched anonymous define() module
This error appears only in IE8.
I know the origin :
I'm usign es5shim and json3 library added by an HTML comment like that :
<!--[if lt IE 9]>
<script src="bower_components/es5-shim/es5-shim.js"></script>
<script src="bower_components/json3/lib/json3.min.js"></script>
<![endif]-->
In fact it seems that es5shim and json3 use a define() function. This is the origin of the error.
I can solve it removing the HTML comment and loading these librairies like other in requirejs.
But i wan't these librairies only for IE8 !
I don't know what to do !!
Thx guys
Upvotes: 1
Views: 1083
Reputation: 7729
I've found the solution. In fact es5shim and json3 use the define() function for AMD compatibility.
But i have to load them out of requirejs via an HTML comment :
<!--[if lt IE 9]>
<script src="bower_components/es5-shim/es5-shim.js"></script>
<script src="bower_components/json3/lib/json3.min.js"></script>
<![endif]-->
The matter was i add this comment after the data-main
:
<!-- build:js scripts/amd-app.js -->
<script src="bower_components/requirejs/require.js" data-main="/scripts/main" </script>
<!-- endbuild -->
<!--[if lt IE 9]>
<script src="bower_components/es5-shim/es5-shim.js"></script>
<script src="bower_components/json3/lib/json3.min.js"></script>
<![endif]-->
So it fails. If i put the comment before the data-main
it works :
<!--[if lt IE 9]>
<script src="bower_components/es5-shim/es5-shim.js"></script>
<script src="bower_components/json3/lib/json3.min.js"></script>
<![endif]-->
<!-- build:js scripts/amd-app.js -->
<script src="bower_components/requirejs/require.js" data-main="/scripts/main" </script>
<!-- endbuild -->
Upvotes: 1