AOT 编译失败。 Angular2 RC6 - 不支持函数调用 - RouterModule.forChild(ROUTES)
AOT Compilation fails. Angular2 RC6 - Function call not supported - RouterModule.forChild(ROUTES)
环境:
Windows10,IntelliJ 2016.2,节点
Angular版本:2.0.0-rc.6
语言: [全部 |打字稿 X.X | ES6/7 | ES5]
打字稿 ES6
节点(针对 AoT 问题): node --version
=
节点 4.4.7,NPM 3.10.6
AOT 编译器失败,抱怨函数调用或 lamba 引用。唯一的一个是 RouterModule.forChild(ROUTES),但以前它可以使用此引用进行编译。我看不出如果没有导入的组件,该应用程序如何工作。
// /**
// * Angular 2 decorators and services
// */
// // import { BrowserModule } from '@angular/platform-browser'
//
import { CommonModule } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
//
import { ROUTES } from './detail.routes';
/*
* Shared Utilities & Other Services
*/
import { Logging } from '../services/utility.service';
/**
* Imported Components
*/
import { DetailComponent } from './detail.component';
@NgModule({
declarations: [// Components / Directives/ Pipes
DetailComponent],
imports: [CommonModule, BrowserModule, FormsModule, RouterModule.forChild(ROUTES),]
})
export class DetailModule {
constructor() {
if (Logging.isEnabled.light) { console.log('%c Hello \"Detail\" component!', Logging.normal.lime); }
}
}
错误是
Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol DetailModule in C:/Source/POC/Microservice.Poc/src/app-components/+detail/index.ts, resolving symbol DetailModule in C:/Source/POC/Microservice.Poc/src/app-components/+detail/index.ts
at simplifyInContext (C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\static_reflector.js:473:23)
at StaticReflector.simplify (C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\static_reflector.js:476:22)
at StaticReflector.annotations (C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\static_reflector.js:61:36)
at _loop_1 (C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\codegen.js:53:54)
at CodeGenerator.readFileMetadata (C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\codegen.js:66:13)
at C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\codegen.js:100:74
at Array.map (native)
at CodeGenerator.codegen (C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\codegen.js:100:35)
at codegen (C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\main.js:7:81)
at Object.main (C:\Source\POC\Microservice.Poc\node_modules\@angular\tsc-wrapped\src\main.js:30:16)
Compilation failed
为什么 RouterModule.forChild(ROUTES)
使 AOT 编译失败,当超过 here at this repo 时,AOT 编译可以正常工作?
问题已通过从 RC6 版本切换到 github 版本解决:
这个:
"@angular/compiler-cli": "github:angular/compiler-cli-builds",
"@angular/common": "2.0.0-rc.6",
"@angular/compiler": "2.0.0-rc.6",
"@angular/core": "2.0.0-rc.6",
"@angular/forms": "^2.0.0-rc.6",
"@angular/http": "2.0.0-rc.6",
"@angular/platform-browser": "2.0.0-rc.6",
"@angular/platform-browser-dynamic": "2.0.0-rc.6",
"@angular/platform-server": "2.0.0-rc.6",
"@angular/router": "3.0.0-rc.2",
已更改为
"@angular/common": "github:angular/common-builds",
"@angular/compiler": "github:angular/compiler-builds",
"@angular/compiler-cli": "github:angular/compiler-cli-builds",
"@angular/core": "github:angular/core-builds",
"@angular/forms": "github:angular/forms-builds",
"@angular/http": "github:angular/http-builds",
"@angular/platform-browser": "github:angular/platform-browser-builds",
"@angular/platform-browser-dynamic": "github:angular/platform-browser-dynamic-builds",
"@angular/platform-server": "github:angular/platform-server-builds",
"@angular/router": "github:angular/router-builds",
"@angular/tsc-wrapped": "github:angular/tsc-wrapped-builds",
现在可以正常编译了。
环境: Windows10,IntelliJ 2016.2,节点
Angular版本:2.0.0-rc.6
语言: [全部 |打字稿 X.X | ES6/7 | ES5] 打字稿 ES6
节点(针对 AoT 问题):
node --version
=
节点 4.4.7,NPM 3.10.6
AOT 编译器失败,抱怨函数调用或 lamba 引用。唯一的一个是 RouterModule.forChild(ROUTES),但以前它可以使用此引用进行编译。我看不出如果没有导入的组件,该应用程序如何工作。
// /**
// * Angular 2 decorators and services
// */
// // import { BrowserModule } from '@angular/platform-browser'
//
import { CommonModule } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
//
import { ROUTES } from './detail.routes';
/*
* Shared Utilities & Other Services
*/
import { Logging } from '../services/utility.service';
/**
* Imported Components
*/
import { DetailComponent } from './detail.component';
@NgModule({
declarations: [// Components / Directives/ Pipes
DetailComponent],
imports: [CommonModule, BrowserModule, FormsModule, RouterModule.forChild(ROUTES),]
})
export class DetailModule {
constructor() {
if (Logging.isEnabled.light) { console.log('%c Hello \"Detail\" component!', Logging.normal.lime); }
}
}
错误是
Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol DetailModule in C:/Source/POC/Microservice.Poc/src/app-components/+detail/index.ts, resolving symbol DetailModule in C:/Source/POC/Microservice.Poc/src/app-components/+detail/index.ts
at simplifyInContext (C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\static_reflector.js:473:23)
at StaticReflector.simplify (C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\static_reflector.js:476:22)
at StaticReflector.annotations (C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\static_reflector.js:61:36)
at _loop_1 (C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\codegen.js:53:54)
at CodeGenerator.readFileMetadata (C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\codegen.js:66:13)
at C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\codegen.js:100:74
at Array.map (native)
at CodeGenerator.codegen (C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\codegen.js:100:35)
at codegen (C:\Source\POC\Microservice.Poc\node_modules\@angular\compiler-cli\src\main.js:7:81)
at Object.main (C:\Source\POC\Microservice.Poc\node_modules\@angular\tsc-wrapped\src\main.js:30:16)
Compilation failed
为什么 RouterModule.forChild(ROUTES)
使 AOT 编译失败,当超过 here at this repo 时,AOT 编译可以正常工作?
问题已通过从 RC6 版本切换到 github 版本解决:
这个:
"@angular/compiler-cli": "github:angular/compiler-cli-builds",
"@angular/common": "2.0.0-rc.6",
"@angular/compiler": "2.0.0-rc.6",
"@angular/core": "2.0.0-rc.6",
"@angular/forms": "^2.0.0-rc.6",
"@angular/http": "2.0.0-rc.6",
"@angular/platform-browser": "2.0.0-rc.6",
"@angular/platform-browser-dynamic": "2.0.0-rc.6",
"@angular/platform-server": "2.0.0-rc.6",
"@angular/router": "3.0.0-rc.2",
已更改为
"@angular/common": "github:angular/common-builds",
"@angular/compiler": "github:angular/compiler-builds",
"@angular/compiler-cli": "github:angular/compiler-cli-builds",
"@angular/core": "github:angular/core-builds",
"@angular/forms": "github:angular/forms-builds",
"@angular/http": "github:angular/http-builds",
"@angular/platform-browser": "github:angular/platform-browser-builds",
"@angular/platform-browser-dynamic": "github:angular/platform-browser-dynamic-builds",
"@angular/platform-server": "github:angular/platform-server-builds",
"@angular/router": "github:angular/router-builds",
"@angular/tsc-wrapped": "github:angular/tsc-wrapped-builds",
现在可以正常编译了。