I'm trying to load d3-path using RequireJS. Looking at the minified d3-path source code, it looks like it's AMD-compliant since I see this in the first line:
!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports):"function"==typeof define&&define.amd?define(["exports"],s):s(t.d3=t.d3||{})}
My index.html looks like
<script>
require.config({
paths: {
"d3": "https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min",
"d3-path": "https://d3js.org/d3-path.v1.min",
"underscore": "https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min",
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"
}
});
</script>
And my JS file that I'm trying to load d3.path() looks like
require([
"d3",
"d3-path",
"underscore"
],
function(
d3,
d3_path,
_
) {
// d3, d3_path, and _ are defined
// but d3.path() isn't defined
});
I can use d3-path by doing d3_path.path() but I would ideally like to do d3.path(). However if I set both d3 and d3-path to d3 then d3-path overrides d3 and I lose the main d3 functions.
I'm also open to RequireJS best practices since I'm not sure if I'm using the best method. Thanks!