Closed tiagondelgado closed 7 years ago
So - I don't use require.js, but it seems like maybe this is caused because I'm importing 'd3-transition' and 'd3-selection' instead of d3 here.
I'm using the rollup.js module bundler, and the command is 'rollup -g d3-selection:d3,d3-transition:d3' to handle this. Maybe you need something similar with require.js?
Workaround: use map
to fix the imports.
http://stackoverflow.com/questions/38912143/how-to-load-a-d3-dependent-script-using-requirejs
Working example that imports Venn.js and D3 using Require.js:
<script src="http://requirejs.org/docs/release/2.3.2/minified/require.js"></script>
<script>
require.config({
paths: {
d3src: "https://d3js.org",
venn:'https://rawgit.com/benfred/venn.js/master/venn'
},
map: {
'*': {
'd3' : 'd3src/d3.v4.min',
'd3-selection' : 'd3src/d3-selection.v1.min',
'd3-transition' : 'd3src/d3-transition.v1.min',
'd3-dispatch' : 'd3src/d3-dispatch.v1.min',
'd3-timer' : 'd3src/d3-timer.v1.min',
'd3-interpolate' : 'd3src/d3-interpolate.v1.min',
'd3-color' : 'd3src/d3-color.v1.min',
'd3-ease' : 'd3src/d3-ease.v1.min',
}
}
});
require(['d3', 'venn', 'd3-selection', 'd3-transition',
'd3-dispatch', 'd3-timer', 'd3-interpolate', 'd3-color', 'd3-ease'],
function(d3, venn, selection, transition, dispatch, timer, interpolate, color, ease) {
d3.select("body").append("h1").text("Successfully loaded D3 and Venn.js");
});
</script>
require.min.js:1 Uncaught Error: Script error for: d3-transition require.min.js:1 Uncaught Error: Script error for: d3-transition