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

d3-collection dependency missing (es module usage) #1822

Closed
nomego opened this issue Apr 2, 2021 · 4 comments · Fixed by #1824
Closed

d3-collection dependency missing (es module usage) #1822

nomego opened this issue Apr 2, 2021 · 4 comments · Fixed by #1824

Comments

@nomego
Copy link
Contributor

nomego commented Apr 2, 2021

I created a sample open-wc app at https://github.com/nomego/dc-owc to highlight some ES6 issues with dc.js

First off is that just by doing import { BarChart } from 'dc' I get an error:

Error while transforming node_modules\dc\src\core\d3compat.js: Could not resolve import "d3-collection".                                                         import "d3-collection".

  1 | import {event, mouse, pointer} from 'd3-selection';
> 2 | import {nest} from 'd3-collection';
    |                    ^
  3 | import {groups} from 'd3-array';
  4 |
  5 | // d3v6 has removed `d3.mouse` in favor of `d3.pointer`

So the d3-collection dep is missing from dc.js 4.2.5 but mandatory

@gordonwoodhull
Copy link
Contributor

@kum-deepak can answer this better, but dc.js doesn't depend on d3-collection, which was removed from d3@6. This module is attempting to detect whether d3@5 or d3@6 is active and won't call nest in the latter case. It is expecting non-existent imports to yield null.

Perhaps we need better support for users doing their own transpilation.

@nomego
Copy link
Contributor Author

nomego commented Apr 2, 2021

@gordonwoodhull Well even though it's not specified in package.json, using the es6 modules approach, it's an unconditional import statement dependency, so it's technically a dependency for the es6 module approach as the code is designed right now.
There's not a strict need to transpile either, since es6 modules are supported natively in the browser. The reason it's being handled by the server is because it's a bare import without and import map.
Either it should be added as a package.json dep, imported conditionally or import removed altogether.

@nomego nomego changed the title d3-collection dependency missing d3-collection dependency missing (es module usage) Apr 2, 2021
@kum-deepak
Copy link
Collaborator

Yes, it indeed would cause issues. Let me see how to resolve it.

@nomego
Copy link
Contributor Author

nomego commented Apr 2, 2021

Thanks! The dev ux of modern web app development with es modules is amazing and the tree shaking has huge potential in the dc.js/crossfilter/d3js setup. I'll gladly compare my example bundles when this is sorted out if you're interested.

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

Successfully merging a pull request may close this issue.

3 participants