title: Angular 2 - AOT - Calling function 'ChartModule', function calls not supported
body: <p>I am losing my mind and hair over this. I am importing HighCharts in Angular 2 but need to require some of its extra libraries. So far in my code I have</p>
  
  <pre><code>import {ChartModule} from 'angular2-highcharts';
  @NgModule({
  ....
  imports:[
  ChartModule.forRoot(require('highcharts'), require('highcharts/modules/drilldown'))})
  ]
  </code></pre>
  
  <p>But I keep getting this error</p>
  
  <blockquote>
    <p>ERROR in Error encountered resolving symbol values statically. Calling function 'ChartModule'. function calls are not supported. Consider replacing the function or lambda with a reference to an exported fucntion.</p>
  </blockquote>
  
  <p>So I tried</p>
  
  <pre><code>export function highchartsRequire:any {
     return{
       require('highcharts'), 
       require('highcharts/modules/drilldown')
     }
  }
  ...
  ChartModule.forRoot(highchartsRequire())
  </code></pre>
  
  <p>Still doesn't work. Any ideas?</p>
  
  <p>Using angular 2
  angular cli: 1.0.0-beta.30</p>
  
  <p><strong>UPDATE - got it partially working thanks to JayChase</strong></p>
  
  <p><strong>This works</strong></p>
  
  <pre><code>export function highchartsFactory() {
        return require('highcharts');
  
      }
  </code></pre>
  
  <p><strong>But I cannot require two at a time</strong></p>
  
  <pre><code>declare var require: any;
  export function highchartsFactory() {
    return function () {
      require('highcharts');
      require('highcharts/modules/drilldown')
    };
  }
  
  @NgModule({
    imports: [
      ChartModule
    ],
    providers: [
      {
        provide: HighchartsStatic,
        useFactory: highchartsFactory
      }
    ],
  </code></pre>
  
  <p>Any ideas? Thank you.</p>