I try to build my application with production flag i have an error like this.
Error: Error encountered resolving symbol values statically. Reference to a local (non-exported) symbol 'require'. Consider exporting the symbol (position 38:13 in the origi
nal .ts file), resolving symbol AppModule in C:/Users/fs/Desktop/venky/new futures/futures-services latest/src/app/app.module.ts
this error because of i have used used require for highcharts like this and i am not allow to use ChartModule directly
ChartModule.forRoot(require('highcharts'),require ('../../node_modules/highcharts/highcharts-more.js'))
i have followed this post and i did not get any errors but my charts are not displaying. give me help to sort this.
Angular 2 - AOT - Calling function 'ChartModule', function calls not supported
This is what i did to get production build successfully
import { HighchartsStatic } from 'angular2-highcharts/dist/HighchartsService';
import { ChartModule } from 'angular2-highcharts';
declare var require: any;
export function highchartsFactory() {
var hc = require('highcharts');
var hcm = require('highcharts/highcharts-more');
hcm(hc);
return hc;
}
providers: [
{
provide: HighchartsStatic,
useFactory: highchartsFactory
},
],
bootstrap: [AppComponent]
})
export class AppModule