Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with crossfilter dependency #1261

Closed
eapyl opened this issue Jan 14, 2017 · 20 comments
Closed

Issue with crossfilter dependency #1261

eapyl opened this issue Jan 14, 2017 · 20 comments
Labels
Milestone

Comments

@eapyl
Copy link

eapyl commented Jan 14, 2017

Hi there, I have a small problem with running dc example (stock.js). I added the next dependencies to my package.json:

  "dependencies": {
    "colorbrewer": "^1.0.0",
    "dc": "^2.1.1",

After that I got the next error: Uncaught Error: Cannot find module 'crossfilter'.
To fix this issue I changed node_modules/dc/index.js:

d3 = require("d3");
crossfilter = require("crossfilter2");
module.exports = require("./dc");

from crossfilter to crossfilter2. Could you please help me with this issue? What is the proper fix? Or it is a problem with crossfilter ?
Thank you for your help in advance.

@gordonwoodhull
Copy link
Contributor

gordonwoodhull commented Jan 14, 2017

Unfortunately I am not familiar with Node, and the folks who contributed Node support are no longer here.

Should the argument to require be the name of the module, or the filename of the js file? This varies in the crazy ridiculous number of JavaScript module loaders.

The underlying issue is that crossfilter2 is the name of a drop-in replacement for crossfilter. So the name of the module is not the name of the file (crossfilter.js).

See #1214 for the related problem when using webpack.

@eapyl
Copy link
Author

eapyl commented Jan 14, 2017

Hmm, I just checked what npm loaded using npm install:
image
As I know, nodejs just looked at the name of folder. But the name of module is also crossfilter2.

@eapyl
Copy link
Author

eapyl commented Jan 14, 2017

Anyway, I am planning to use webpack also. So the issue will be solved using resolve functionality from webpack (as in #1214, thanks for the link).
So feel free to close the issue.
Thank you for your quick help and response!

@gordonwoodhull
Copy link
Contributor

We probably need to update index.js then. Thanks for the report! I'll change it in the next release.

Probably not a lot of people are using dc.js in Node. The switch to crossfilter2 was almost nine months ago.

@gordonwoodhull gordonwoodhull added this to the v2.0 milestone Jan 14, 2017
@jdylanstewart
Copy link

jdylanstewart commented Jan 15, 2017 via email

@gordonwoodhull
Copy link
Contributor

Thanks @jdylanstewart - you mean you alias it using webpack? Or are there other ways?

@jdylanstewart
Copy link

jdylanstewart commented Jan 15, 2017 via email

@akuji1993
Copy link

akuji1993 commented Jan 17, 2017

Hm, why can't you just import the crossfilter library in your package.json. Using webpack here, I just added these three lines:

"crossfilter": "^1.3.12", "d3": "^3.5.17", "dc": "^2.1.1",

to my dependencies in package.json and import them like this:

import * as d3 from 'd3'; import * as dc from 'dc'; import crossfilter from 'crossfilter';

Works fine for me.

As a sidenote for you Gordon, dc.js works pretty well with Node and ES6. I imagined having more trouble with it.

@emiguevara
Copy link

emiguevara commented Jan 17, 2017

I am also getting this issue, using webpack and yarn. If I let dc install its own dependencies, crossfilter2 is fetched correctly (I can see it in mu modules folder), but dc still complains about crossfilter not being available:

Uncaught Error: Cannot find module "crossfilter"
    at webpackMissingModule (dc.js:10707)
    at eval (dc.js:10707)
    at eval (dc.js:10724)
    at Object.<anonymous> (app.bundle.js?68580d4…:12370)
    at __webpack_require__ (app.bundle.js?68580d4…:556)
    at fn (app.bundle.js?68580d4…:87)
    at Object.eval (directives.js:42)
    at Object.eval (directives.js:3725)
    at eval (directives.js:3726)
    at Object.<anonymous> (app.bundle.js?68580d4…:12352)

Using the proposal by @akuji1993 is wrong: "crossfilter": "^1.3.12" will install the last version by https://github.com/square/crossfilter which is not maintained and is missing functionality in "crossfilter2": "^1.3.14". However wrong, this will make dc find the module it wants, and most of it will actually work ok...

@akuji1993
Copy link

Good to know. Still works for the stuff, that I have to do with it, but then it's probably not the right way if you want the newer stuff. Have to keep this in mind for more recent projects, thank you.

@gordonwoodhull
Copy link
Contributor

@emiguevara did you try the alias solution from #1214?

@emiguevara
Copy link

@gordonwoodhull yes, just tried it now. I can confirm that resolve.alias in webpack solves the issue with yarn and webpack. Thanks!

@gordonwoodhull
Copy link
Contributor

I'm going to close this. If there are any recommendations to help dc.js work with webpack without requiring special configuration, please lmk.

@KhodeN
Copy link

KhodeN commented Feb 28, 2017

define(["d3", "crossfilter"], _dc);
You can just change to
define(["d3", "crossfilter2"], _dc);

Why not? I can't edit webpack config in my angular-cli project, so the way to use resolve.alias is not available for me.

@gordonwoodhull
Copy link
Contributor

As explained in #1214, this does not work in AMD environments, where this specifies the name of the file instead of the name of the module.

Sorry for the inconvenience - it seems that the only way to make both AMD and Webpack happy is to make http://github.com/crossfilter/crossfilter use the same name for its filename as for its NPM project name.

@shusson
Copy link

shusson commented May 24, 2017

Any updates on this issue?

@gordonwoodhull
Copy link
Contributor

gordonwoodhull commented May 24, 2017

Hi @shusson.

We discussed it in crossfilter/crossfilter#75, and I will release new 2.0.* and 2.1.* versions of dc.js which break requireJS in favor of webpack. Both index.js and the UMD asynchronous-looking require() will refer to crossfilter2 instead of crossfilter.

requireJS users will have to either set up their builds to copy crossfilter.js as crossfilter2.js, or do the aliasing in their requireJS configurations.

@shusson
Copy link

shusson commented May 24, 2017

👍 awesome, thanks @gordonwoodhull

gordonwoodhull added a commit that referenced this issue May 24, 2017
this breaks requireJS but fixes webpack - since the community fork of
crossfilter has a different package name from its filename, one or the
other packaging system is going to be unhappy.

requireJS users will need to rename crossfilter.js to crossfilter2.js
when copying it into position, or use the requireJS paths or map
configuration options to specify that the filename is different from the
module name.

http://requirejs.org/docs/api.html#config-paths
http://requirejs.org/docs/api.html#config-map

fixes #1213
fixes #1214
fixes #1261
fixes #1293
fixes #1302
breaks #1304!
@gordonwoodhull
Copy link
Contributor

As of dc.js 2.0.3 / 2.1.6, we'll break requireJS compatibility in favor of webpack compatibility.

See #1304 if this creates problems for you.

@KhodeN
Copy link

KhodeN commented May 25, 2017

Thanks! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants