Hi, one year has elapsed since the last replies to this post. Probably requirejs has evolved, in the meantime.
I faced the same problem but i fixed it easily without a wrapper package, using requirejs shim. Using the shim, you can export a variable, and you can also define dependencies:
d3: { exports: 'd3' },
nvd3: {
exports: 'nv',
deps: ['d3']
},
In this way, i simply install d3 and other packages with bower, and include them with require, and it is really quick and clean.
Nonetheless, i faced the following problem: there are probably some clashes between the global d3 variable and the local one (the one injected in the requiring modules). It is a d3 / require / nvd3 integration problem related to transitions and selections. I don't fully understand the problem, but i can already make some considerations.
- jquery has the same problem with require, and they provide the noconflict method to fix it
- many libraries have this behavior, they export a global symbol, but as far as i know there is no ready fix from requirejs for the general problem
- the problem is fixed if i rename all global references to `d3` into d3 source to another name. I still have `d3` in the injected module, but it is not conflicting anymore
I'm posting this here to show an easier way to include d3, and to ask your help about the global symbol. Many d3 functionalities work this way, but one of the nvd3 charts has transitions broken probably because a selection or dispatcher is overwritten. It requires deep understanding of d3 internals to spot precisely the error, but probably a simple yet correct handling of the global symbol will clear the whole tally of similar problems.