0
votes

I'm developing a JavaScript plugin for webshops which is module based and I'm using require.js as module loader to integrate it into the customer's HTML template.

The idea behind that is to let the customer put only one line of code into their template and everything is loaded automatically.

I get problems when the webshop has third party scripts which define themself anonymously as AMD module but are included by a separate <script> tag. In this case I get errors like:

Uncaught Error: Mismatched anonymous define() module:
[..]
http://requirejs.org/docs/errors.html#mismatch

There is no way to me to take influence on that. It is also not possible for me to influence where in the template my one-liner is put by our customers.

Is there a way to tell require.js to just focus on the modules I name in my code and to ignore any other referenced module-define JavaScripts?

1

1 Answers

0
votes

I had the same problem. My workaround has been to put all the require/define/requirejs objects under another object such as foo.require, foo.define, foo.requirjs. I've now found in the require page something like what I did:

http://requirejs.org/docs/faq-advanced.html

Hope this can help you!