Grunt JavaScript moodle 3.9 (upgrading from 3.5) JS Errors

Grunt JavaScript moodle 3.9 (upgrading from 3.5) JS Errors

by James Kinsman -
Number of replies: 1

There was a library c3.min.js which seemed to be causing problems:

I was getting: Mismatched anonymous define() module

So I followed Andrew Nichols help and he told me to pass through my javascript using Grunt

So I did: grunt amd --files=local/reporting/amd/src/c3.js

And then put a /* eslint-disable */ at the top of the file as he suggested because it was a library

It produced two files:

  1. local/reporting/amd/build/c3.min.js.map
  2. local/reporting/amd/build/c3.min.js
However, when I went to test the library I'm getting javascript errors:

Uncaught ReferenceError: require is not defined

    <anonymous> http://mylocal/carnegie3/src/local/reporting/classes/actions/displays/charts/view.php?actionid=39&reportid=8&charttype=line:446
moodle-core-event: Global event published: FORM_ERROR yui_combo.php:5828:31
moodle-core-event: Global event published: BLOCK_CONTENT_UPDATED yui_combo.php:5828:31
Uncaught ReferenceError: x is not defined
    <anonymous> c3.js:2
Uncaught Error: No define call for local_reporting/c3 http://requirejs.org/docs/errors.html#nodefine

What do I do? I thought I did everything right? We just upgraded from 3.5 to 3.9 and I was told I need to run my javascript through grunt....

Average of ratings: -
In reply to James Kinsman

Re: Grunt JavaScript moodle 3.9 (upgrading from 3.5) JS Errors

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Do you have the source, if so, does it have an 'define' / 'requires' call? If only the minified, then is there a 'define' in that or a 'amd.define' etc. Some 'wrapper' around the JS lib to make it an AMD module.