ng-chartist: module is not compatible with rollup.js bundling and tree-shaking.

The current sample code does not cover the inclusion of the module/component via @NgModule app import.

This causes a problem for me as trying to import the ChartistModule (rather than importing the component at a page level as it used to be) results in the error Unexpected value ‘ChartistComponent’ exported by the module ‘ChartistModule’ , suggesting that I’m importing it incorrectly.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 30 (12 by maintainers)

Commits related to this issue

Most upvoted comments

I’m currently working on a fix for this to hopefully avoid any extra configuration. For now, you can use workarounds obviously. I’ll mention something here once the fix is released.

On Tue, Oct 18, 2016 at 12:21 AM Christopher Cook notifications@github.com wrote:

So my final fix/workaround for this was to install the latest @types/chartist and use a custom rollup config with the following namedExport for angular2-chartist:

commonjs({ namedExports: { // chartist ‘node_modules/angular2-chartist/dist/angular2-chartist.js’: [‘ChartistComponent’], … } }),

As an aside, I did get a weird problem where my line chart had a filled black area, even with showArea set to false, worked around with with css. Assume this is more a problem/change with base chartist library.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/paradox41/angular2-chartist/issues/48#issuecomment-254403063, or mute the thread https://github.com/notifications/unsubscribe-auth/ACqZMj32fvFvdKYoRnyAF1EwWeU3LDWSks5q1ElCgaJpZM4KVbh2 .

I’m trying to reproduce the findings here. I’ve setup two identical Ionic projects with a minimal chartist setup one with the current apps-scripts using rollup and one with the beta apps-scripts using webpack.

Rollup: Regardless of ionic serve or ionic run android I see bundle failed: 'ChartistModule' is not exported.. This is a surprise as I think it should work without AoT compilation?! Adding the custom rollup config didn’t change anything. Webpack: Using webpack the ionic serve works fine and I can see the chart being displayed. Butnpm run build / ionic run android still issues the "Chartist Module is not exported" error.

Anything screwed up in my simplified setup?`

Versions: ionic 2 Rc1 angular2-chartist@0.10.1 chartist@0.10.1 @types/chartist@0.9.33

home.ts

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { ChartType } from 'angular2-chartist';

@Component({
  selector: 'page-home',
  template: `
    <x-chartist
      [data]="data"
      [type]="type">
    </x-chartist>
  `
})

export class HomePage {
 type: ChartType;
 data: any;

  constructor(public nav:NavController) {
    this.type = 'Line';
    this.data = {
      "labels": [
        "Jan",
        ......
        "Dec"
      ],
      "series": [
        [5, 4, 3, 7, 5, 10 ,3, 4, 8, 10 ,6, 8],
        [3, 2, 9, 5, 4, 6, 4, 6, 7, 8, 7, 4]
      ]
    }
  }
}

app.modules.ts


import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
import { AboutPage } from '../pages/about/about';
import { ContactPage } from '../pages/contact/contact';
import { HomePage } from '../pages/home/home';
import { TabsPage } from '../pages/tabs/tabs';
import { ChartistModule } from 'angular2-chartist';

@NgModule({
  declarations: [
    MyApp,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ],
  imports: [
    ChartistModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ],
  providers: []
})
export class AppModule {}

I’ll do my best to fix it tonight. Sorry for the trouble.

On Wed, Oct 19, 2016 at 9:48 AM Christopher Cook notifications@github.com wrote:

Unfortunately I got 0.9.5 working, then saw your update and applied it. Should have committed my changes! Now can’t seem to get back to a working version despite trying all sorts of variations. Have currently reverted to using Chartist directly in my own component but the Ionic component lifecycle is causing issues when page navigation takes place, which is something your component seemed to handle fine (which is why I’d eventually like to get it working again).

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/paradox41/angular2-chartist/issues/48#issuecomment-254817788, or mute the thread https://github.com/notifications/unsubscribe-auth/ACqZMg7X2rs2Akyiu-6NPC84k6-RJgXmks5q1h-6gaJpZM4KVbh2 .