3.1.9 crossfilter is not a function
See original GitHub issueRecently I tried to run npm update
on a vue website that uses dc.js and it changed the crossfilter import that is exposed by dc.js.
Here is a screenshot of the updated package list in case this was not a direct result of dc.js being updated
dc version from 3.1.2 -> 3.1.9 d3 version from 5.10.0 -> 5.15.0 crossfilter2 version from 1.4.7 -> 1.5.2 (problem?)
Screenshot of package.json diff
after some quick inspection it appears that the dc.crossfilter wasn’t imported correctly and can be fixed by either:
updating the reference on on dc.js:13925
from dc.crossfilter = crossfilter
to dc.crossfilter = crossfilter.default
or
just using dc.crossfilter.default(dataArray)
without editing any dc.js source directly
I definitely feel that the workaround listed above isn’t the correct way to solve the issue I’ve come across, but judging by the version numbers, it looks like dc.js should be compatible with the version of d3 and crossfilter being used but may not be imported correctly into dc 3.1.9.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Thanks very much for your thorough testing.
It sounds like it is “simply” a bug in crossfilter2@1.5 where the interface is not backward compatible when used in the vue bundler. I suspect it’s the same issue in the above crossfilter/Angular issue. From your dependency list it doesn’t look like you are using Typescript, but maybe Babel transpilation has something to do with it.
I don’t see any reason to believe this has to do with dc.js in particular, so I’m going to open a crossfilter issue. And yeah, I supposed dc.js could peg to the old version of crossfilter but I’d rather not do that, especially since this doesn’t seem to be a JavaScript issue but a bundler issue.
I’ll leave this issue open as a reminder to remove crossfilter from the public interface of dc.js in 3.2, since it just complicates things.
I didn’t try using dc.js 4.0 as this is in a pretty large project currently and was worried about reworking the code at the moment though may not be that much work looking at your upgrade guide.
currently everything is working using dc@3.1.2 crossfilter2@1.4.7 and d3@5.15.0
It seems the d3 version doesn’t affect my current implementation as it was updated from 5.10.0 -> 5.15.0 and worked with any of the dc/crossfilter2 versions I have tried.
after retrying dc@3.1.9 and crossfilter2@1.4.7 it appears I may have been mistaken or this was a caching issue from when I had installed crossfilter2@1.5.2 because this combination appears to be working for me.
I can however confirm that dc@3.1.9 with crossfilter2@1.5.2 does not work for me running a vue project on a Mac with the error described in the original post that crossfilter is not a function.
I’m unfamiliar with how npm update actually works but could dc@3.X.X be limited to crossfilter2@1.4.X rather than crossfilter2@1.5.X?