Search code examples
javascriptrequirejsvis.js

Can't use vis with require.js


I'm trying to add vis.js to a 4-year-old web application.

When I run the application without packaging everything, it works. However, when I package everything with grunt, I get the following error in the browser's console:

Mismatched anonymous define() module

When I comment out the code

require(['vis'], function(vis)) { ... }

The error disappears, but obviously I don't have any access to vis any more.

I seem to be doing everything that is shown in the example , with the exception of using data-main when loading require.js. That's because it is no longer supported by use-min.


Solution

  • I had the same issue with other library (NanoModal). The only solution which worked for me was to exclude that library from packaging using the paths configuration of the r.js optimizer:

    paths: {
       "nanomodal": "empty:"
    }