Recently transitioning to Meteor 1.3 with npm module support, I've encountered the following issue:
TypeError: Cannot set property 'tip' of undefined
Below is the relevant code snippet in myFile.js:
import d3 from 'd3';
import d3tip from 'd3-tip';
//...
chart.tip = d3tip()
.attr('class', 'd3-tip')
.offset([-10, 0])
.html(function(d) {
//...
});
The error seems to be originating from the package d3-tip
:
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module with d3 as a dependency.
define(['d3'], factory)
} else if (typeof module === 'object' && module.exports) {
// CommonJS
module.exports = function(d3) {
d3.tip = factory(d3) // HERE THE ERROR (d3 probably not defined)
return d3.tip
}
} else {
// Browser global.
root.d3.tip = factory(root.d3)
}
}(this, function (d3) { //...}
It appears that the package d3-tip
is unable to find d3
, although both d3
and d3-tip
are imported in myFile.js
.
Is there a manual method to inject d3 into d3-tooltip?