crossfilter / reductio

Reductio: Crossfilter grouping
Other
250 stars 42 forks source link

crossfilter not found #36

Closed jefffriesen closed 8 years ago

jefffriesen commented 8 years ago

I'm using reductio 0.5.3 in a CommonJS environment (webpack in my case).

I'm getting Module not found: Error: Cannot resolve module 'cross filter' in these reductio modules:

@ ./~/reductio/src/reductio.js 5:18-40
@ ./~/reductio/src/value-count.js 1:18-40
@ ./~/reductio/src/value-list.js 1:18-40
@ ./~/reductio/src/histogram.js 1:18-40
 @ ./~/reductio/src/nest.js 1:18-40

Reductio 0.5.3 has this dependency: "crossfilter2": "^2.0.0-alpha.03". I don't know if there is a problem in reductio or crossfilter2. Previously I actually tried to use crossfilter2 with dc.js but gave up because I couldn't get dc.js to require it properly. Maybe crossfilter2 isn't exporting it's modules properly? Maybe this belongs in crossfilter2's repo, but the error is originating from Reductio so I wanted to let you know about it.

I've tried quite a few webpack shenanigans to get it to work, including the ones that are used with modules that weren't originally built to work in a CommonJS environment. But none of them worked. I've got lots of other modules working in my environment, which leads me to think it has something to do with reductio or crossfilter2.

Thanks

jefffriesen commented 8 years ago

I tested reductio@0.4.0, which uses crossfilter2 but got the same Module not found errors. Installing reductio@0.3.0 which depends on crossfilter 1 ("crossfilter": "^1.3.7") works properly.

esjewett commented 8 years ago

Sigh :-( I suspect it is because the package.json didn't get updated properly. It still has

"browserify-shim": {
    "crossfilter": "global:crossfilter"
  }

and I suspect it should be

"browserify-shim": {
    "crossfilter2": "global:crossfilter"
  }

Would you mind trying that locally and seeing if it fixes your problem?

esjewett commented 8 years ago

Hmmm. I guess those require's in the files you list will need to be changed to require crossfilter2 as well. I'll see if I can get a new release pushed shortly that fixes this.

esjewett commented 8 years ago

Can you try version 0.5.4?

jefffriesen commented 8 years ago

Ok. That may fix it. But I'm not using browserify. I'm using webpack, which I think just pays attention to the normal package.json's dependencies. There are ways to shim non-standard modules (https://webpack.github.io/docs/shimming-modules.html). I've tried the webpack.ProvidePlugin plugin on this page. I know debugging webpack and other bundlers can go down a black hole though. I think if the modules are exported properly for commonJS format it should just work (famous last words).

jefffriesen commented 8 years ago

Just saw your commit - I'll try 0.5.4

esjewett commented 8 years ago

Yeah, I expect if you are using web pack you are going to use the dependency. I only realized that the Browserify-specific stuff is irrelevant after my first response. Sorry.

I'm using Browserify as part of my distribution build. I don't want to include Crossfilter in the distro - therefore the browserify-shim, but you're not using the distribution file, so it's beside the point. If you have Crossfilter on your page directly, you may want to shim it yourself so that you aren't sending it to the browser twice.

jefffriesen commented 8 years ago

Yep - that loaded everything fine. Thanks. Good call on de-duplicating crossfilter. I'm not sure if I can do that because I can't get dc.js working with crossfilter2. I wonder if it needs similar changes.

In this particular instance having crossfilter1 and crossfilter2 should be fine because it's an Electron app and the incremental weight for distribution is negligible for our use case.

Thanks again.

esjewett commented 8 years ago

@jefffriesen The dc.js develop branch just switched to Crossfilter2, but no release yet. Almost there :-)

Oh, also, the next release of Crossfilter 2 is going to be 1.4.x, so look for the 1.4.0-alpha releases for the immediate future. Reductio will switch to 1.4.0-alpha.x eventually, as those are newer than the 2.0.0-alpha releases (which should now be ignored). Sorry for the confusion.

jefffriesen commented 8 years ago

Great. Thanks for fixing this.