Skip to content

Commit e9d9800

Browse files
vprusgordonwoodhull
authored andcommitted
Make browserify case work both for npm and bower.
1 parent 3982a4b commit e9d9800

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/footer.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ return dc;}
33
if(typeof define === "function" && define.amd) {
44
define(["d3", "crossfilter"], _dc);
55
} else if(typeof module === "object" && module.exports) {
6-
// When using window global, window.crossfilter is a function
7-
// When using require, the value will be an object with 'crossfilter'
8-
// field, so we need to access it here.
9-
module.exports = _dc(require('d3'), require('crossfilter').crossfilter);
6+
var _d3 = require('d3');
7+
var _crossfilter = require('crossfilter');
8+
// When using npm + browserify, 'crossfilter' is a function,
9+
// since package.json specifies index.js as main function, and it
10+
// does special handling. When using bower + browserify,
11+
// there's no main in bower.json (in fact, there's no bower.json),
12+
// so we need to fix it.
13+
if (typeof _crossfilter !== "function") {
14+
_crossfilter = _crossfilter.crossfilter;
15+
}
16+
module.exports = _dc(_d3, _crossfilter);
1017
} else {
1118
this.dc = _dc(d3, crossfilter);
1219
}

0 commit comments

Comments
 (0)