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

When using with webpack, crossfilter is undefined #1214

Closed
cramatt opened this issue Oct 13, 2016 · 7 comments
Closed

When using with webpack, crossfilter is undefined #1214

cramatt opened this issue Oct 13, 2016 · 7 comments

Comments

@cramatt
Copy link

cramatt commented Oct 13, 2016

Using the latest 2-beta.32

When using with webpack the following check is true

if(typeof define === "function" && define.amd) {
  define(["d3", "crossfilter"], _dc);
}

But since you are using crossfilter2 this is undefined.

Changing this line to define(["d3", "crossfilter2"], _dc); fixes things.

@gordonwoodhull
Copy link
Contributor

gordonwoodhull commented Oct 13, 2016

Thanks @cramatt, I think there are differences between how different module systems treat module names. We've been trying to keep crossfilter2 as a drop-in replacement for crossfilter, so we didn't change the filename crossfilter.js. And this is okay for npm but I guess it doesn't work in webpack.

#1213 addresses this too.

+@esjewett

@cramatt
Copy link
Author

cramatt commented Oct 14, 2016

Makes sense - I'm not really sure why webpack environment causes the first condition to evaluate to true - I guess webpack uses amd but this is not really clear.

Short of changing the name it might be something that can be fixed with a webpack config, maybe something like resolve?

@gordonwoodhull
Copy link
Contributor

gordonwoodhull commented Oct 14, 2016

I don't know much about webpack. I guess the way it imports modules looks sufficiently like AMD to follow that path. (RequireJS can also do bundling, so maybe it's doing something similar.)

resolve.alias does look promising. If you can figure out a small webpack config file to contribute to dc.js, that would be awesome!

@nordfjord
Copy link

In my config it's a simple:

{
  resolve: {
    alias: {
     'crossfilter': 'crossfilter2'
    }
  }
}

@Anima-t3d
Copy link

For anyone else using webpack and doesn't get the resolve fix working... just make sure that it's the only resolve in the config. My config is quite long and I forgot I declared a resolve at the bottom.. ended up overwriting my resolve fix from @nordfjord . Once I consolidated it, it worked like a charm! Thanks.

@gordonwoodhull
Copy link
Contributor

It is too bad about the confusion of crossfilter names but unless someone suggests something dc.js can do about it, I consider this solved.

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.

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

No branches or pull requests

4 participants