2017-04-11 72 views
5

我的一个功能模块有这样的内容:角4 - 遇到错误解析符号值静态

declare function require(name: string); 

@NgModule({ 
imports: [ 
// other modules here 
ChartModule.forRoot(
    require('highcharts'), 
    require('highcharts/highcharts-more'), 
    require('highcharts/modules/funnel'), 
    require('highcharts/modules/heatmap') 
) 

它运行在本地正常,但当我与督促标志构建它失败。我得到的错误是:

ERROR in Error encountered resolving symbol values statically. Reference to a non-exported function (position 26 :18 in the original .ts file), resolving symbol ....

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in ...

有关如何解决此问题的任何想法?

+1

我有类似的问题,但随着出口'const' – KarolDepka

回答

1

我不能指出你的确切路线,因为你没有包括完整的@NgModule修饰符。此故障通常是providers数组中,当你有这样的事情:

@NgModule({ 
// imports, exports and declarations 
    providers: [{ 
    provide: XSRFStrategy, 
    useValue: new CookieXSRFStrategy('RESPONSE_TOKEN', 'RESPONSE_TOKEN') 
    }] 
}) 
export class MyModule {} 

,当你有一个内联函数调用,比如,你不能使用AOT。相反,将useValue替换为useFactory和导出的函数(如错误消息中所述)。

这是我的第一个上市的AOT安全版本:

export function xsrfFactory() { 
    return new CookieXSRFStrategy('XSRF-TOKEN', 'X-XSRF-TOKEN'); 
} 
@NgModule({ 
// imports, exports and declarations 
    providers: [{ 
    provide: XSRFStrategy, 
    useFactory: xsrfFactory 
    }] 
}) 
export class MyModule {} 
相关问题