dc-js / dc.datatables.js

integration of datatables.js with dc.js
Other
12 stars 10 forks source link

Can't resolve dc_datatables #1

Closed jackcrymble closed 5 years ago

jackcrymble commented 5 years ago

I am trying to integrate this package with my existing project but am currently unable to correctly import due to a ' ERROR in ./node_modules/dc.datatables/dc.datatables.js' where it cannot resolve dc_datatables. datatables_error

By importing in a similar way to dc : import * as dctable from 'dc.datatables';), i get a 'cannot find module' error.

By importing the file directly: (import * as dctable from 'dc.datatables/dc.datatables') the 'Can't resolve dc_datatables error is produced.

gordonwoodhull commented 5 years ago

Hi @jackcrymble, thanks for the report!

Unfortunately I have not tested this package in ES6. I still live in an ES5 world and don't transpile any of my packages. I know that it works well with AMD. 😕

Would you be able to create a minimal example for me to test with?

jackcrymble commented 5 years ago

Hi @gordonwoodhull!

Thanks for the quick reply!

I have been unable to reproduce the issue on stackblitz, however I have created a repo for you to clone with the issue. https://github.com/jackcrymble/reproduction

The reproduction steps are very basic:

  1. Create a new Angular 6 Project (ng new )
  2. Install dc.datatables (npm install --save dc.datatables)
  3. In the generated app.component.ts file import dc.datatables (import * as dctable from 'dc.datatables/dc.datatables';)
  4. Try to use the import such as a console log of dctable as in my example. (console.log(dctable);)

Versions: Angular: 6.1.9 Angular CLI: 6.1.5 NPM: 6.4.1 Node: 10.8.0 OS: linux x64 (Ubuntu 18.04.1)

gordonwoodhull commented 5 years ago

Thanks @jackcrymble! The repo seemed to be blank but I was able to repro using your clear instructions.

Always interesting to try out a new web platform - there are so many.

Turns out the AMD was not valid (it was trying to import itself!) and also it needed the main entry point in package.json - should be fixed for all ES6 & Typescript now in 0.0.4

gordonwoodhull commented 5 years ago

This is a brand new package (obviously) so any contributions are welcome.

The main point is to show an efficient way to get data into DataTables since a lot of people were hacking this via dc.dataTable - i.e. creating a <table> and then having DataTables interpret the DOM as data. This is slow for big tables and it's a bad idea.

I hope that most customization can be done via the exposed DataTable object datatable.dt() - but if there are things that need to be built in, I am game.

To help users upgrade from dc.dataTable, the columns format loosely follows what dc.dataTable expects.

I hope this can evolve so that it more directly follows the Columns options described in the DataTables Options documentation.

So if you run into column type problems, please raise another issue.

jackcrymble commented 5 years ago

Hi @gordonwoodhull

I've installed the new changes, and the dc_datatables error appears to be fixed. However, there is a new issue with the import of crossfilter.

crossfilter_not_defined ^ Taken from debugger logs on Chrome ^

Any thoughts on this?

gordonwoodhull commented 5 years ago

Thanks @jackcrymble! Clearly I need to test end-to-end in an ES6 environment.

I'll use Observable. I'm able to reproduce the problem here: https://beta.observablehq.com/@gordonwoodhull/hello-dc-datatables-js

Hope to fix this later today, if time allows.

gordonwoodhull commented 5 years ago

The library has four direct dependencies: d3, dc, jquery, datatables, published as 0.0.6

It tests correctly in the observable notebook above, which should mean it is now compatible with all ES6 environments including Typescript.

Thanks for your patience @jackcrymble - please lmk if you run into further problems!

gordonwoodhull commented 5 years ago

For future testing, I created a repo here: https://github.com/dc-js/ang-dctable