How to load papa parse js file using requirejs?

487 views Asked by At

I am trying to load papa parse min js file using requirejs but I am getting:

ReferenceError: Papa is not defined

I had checked Net section in console and it is displaying that papa parse min js loaded but it is not working in my website.

Am I doing anything wrong?

1

There are 1 answers

0
numediaweb On

Use shim like this:

require.config({
    paths: {
        'papaparse': '//cdnjs.cloudflare.com/ajax/libs/PapaParse/4.3.6/papaparse.min'
    },
    shim: {
        'papaparse': {exports: 'Papa'}
    }
});

and then use it in your module like this:

define('mymodule', ['papaparse'], function (Papa) { ... }