I want to include d3.js as an external library for a plugin.
d3.js already supports the AMD format, so it seems like it should be possible to include it in an AMD specific way, without needing to touch php to require it specifically into certain pages, (i.e it can be made a dependency of a downstream item), but what is the correct way to include it?
Based on what other developers have done in this space (see Damyon's answer here https://moodle.org/mod/forum/discuss.php?d=333296#p1348185) I created a shim file that modifies the require.js config to point to the appropriate minified paths.
Loader (this module can then be required in other scripts like this: define(['local_d3js/md3'...
However, it seems this is not the "correct" way to do this as per https://tracker.moodle.org/browse/MDL-67495 (it won't work long run because the loading is supposed to be async), and furthermore it doesn't work when trying to include d3-simple-slider as well.
But I can't find the correct way to include external AMD supporting libraries, are we supposed to take the source only and drop it in our plugins amd/src folder and then refer to it as mod_frankenstyle/d3
What about the minified version? and what do we do when the standard grunt task hits on all the syntax errors in the plugin?, and then on top of that, how do I add another d3js addon that builds upon the first? e.g https://github.com/johnwalley/d3-simple-slider
It seems like I'm either missing something super obvious, or we have to fall back to including in the extjs folder and using `$PAGE->requires->js`