swimlane / ngx-datatable

✨ A feature-rich yet lightweight data-table crafted for Angular
http://swimlane.github.io/ngx-datatable/
MIT License
4.62k stars 1.68k forks source link

Filter demo will not build with the -prod or -aot flags #1175

Open moose4lord opened 6 years ago

moose4lord commented 6 years ago

I'm submitting a ... (check one with "x")

[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior Currently when the filter demo described here is built with the -prod flag (i.e. ng build -prod), the build fails with the following errors:

ERROR in Error: Cannot determine the module for class DataTableColumnHeaderDirective in C:/Users/IBM_ADMIN/Desktop/Angular5/my-app-cli-v1.5.5/node_modules/@swimlane/ngx-datatable/src/components/columns/column-header.directive.ts! Add DataTableColumnHeaderDirective to the NgModule to fix it.
Cannot determine the module for class DataTableColumnCellDirective in C:/Users/IBM_ADMIN/Desktop/Angular5/my-app-cli-v1.5.5/node_modules/@swimlane/ngx-datatable/src/components/columns/column-cell.directive.ts! Add DataTableColumnCellDirective to the NgModule to fix it.
Cannot determine the module for class DataTableColumnDirective in C:/Users/IBM_ADMIN/Desktop/Angular5/my-app-cli-v1.5.5/node_modules/@swimlane/ngx-datatable/src/components/columns/column.directive.ts! Add DataTableColumnDirective to the NgModule to fix it.
(and several other similar errors)

"ng serve" and ng build without the -prod flag work fine.

Expected behavior The filter demo should build successfully with the -prod flag.

Reproduction of the problem The filter demo shows the problem, although only when trying to build with the -prod flag.

What is the motivation / use case for changing the behavior? Would like to use the filter feature in a production env.

Please tell us about your environment: Windows 7 @swimlane/ngx-datatable@11.1.5 @angular/cli@1.5.5 @angular/core@5.0.5 rxjs@5.5.3 typescript@2.4.2

This issue was flagged a couple months ago here: https://github.com/swimlane/ngx-datatable/issues/925 which was closed as fixed, but seems like it wasn't fixed completely.

The issue seems to be related to this import statement at the top of the filter demo file: import {DatatableComponent} from '../../src/components/datatable.component'; If I comment out that line (and the bits of code that use DatatableComponent), then a build with the -prod flag works fine.

moose4lord commented 6 years ago

OK, after looking through some other ngx-datatable examples on the web I found this solution. Change the import in the filter demo from this: import {DatatableComponent} from '../../src/components/datatable.component'; to this: import { DatatableComponent } from '@swimlane/ngx-datatable';

That fixed my "ng build -prod" issue. Someone from swimlane should probably update their filter demo.