2017-02-23 49 views
0

有一段時間,我的印象是,Angular2 Dart codegen是發展的前進方向。不幸的是,似乎到最近我不能再使用codegen了。這是我的pubspec.yaml不起作用併產生錯誤。通過僅刪除/ transform/codegen部分,錯誤消失了。酒吧構建拋出angular2飛鏢codegen的錯誤

name: frontend 
version: 0.0.1 
description: Regatta frontend 
author: 
homepage: https://regatta.atlassian.net 
documentation: 

environment: 
    sdk: '>=1.19.0 <2.0.0' 

dependencies: 
    angular2: 3.0.0-alpha 
    angular2_components: 0.3.1-alpha 
    reflectable: 1.0.1 
    sass_transformer: 0.1.2+1 
    greencat: 0.0.2 
    browser: 0.10.0+2 
    http: 0.11.3+9 
    stream_transformers: 0.3.0+3 

dev_dependencies: 
    test: 0.12.19 
    dart_to_js_script_rewriter: 1.0.2 
    dart_style: 0.2.16 
    pageloader: 2.2.5 
    mockito: 1.0.1 
    angular_test: 1.0.0-alpha+5 

transformers: 
    - sass_transformer 
    - angular2/transform/codegen: 
     platform_directives: 
     - 'package:angular2/common.dart#COMMON_DIRECTIVES' 
     platform_pipes: 
     - 'package:angular2/common.dart#COMMON_PIPES' 
     entry_points: web/main.dart 
     resolved_identifiers: 
     BrowserClient: 'package:http/browser_client.dart' 
     Client: 'package:http/http.dart' 
    - angular2/transform/reflection_remover: 
     $include: 
     - test/**_test.dart 
     - web/main.dart 
    - reflectable: 
     entry_points: 
     - web/main.dart 
     formatted: true 
    - test/pub_serve: 
     $include: test/**_test.dart 
    - dart_to_js_script_rewriter 

錯誤消息

pub build 
Loading source assets... 
Loading angular2/transform/codegen, dart_to_js_script_rewriter, sass_transformer, reflectable, test/pub_serve and reflectable/src/transform_import transformers... 
Loading angular2 and angular2/transform/reflection_remover transformers... (3.9s) 
[Error from DirectiveMetadataLinker on frontend|lib/components/navigation_bar_component/navigation_bar_component.ng_summary.json with input frontend|lib/components/navigation_bar_component/navigation_bar_component.ng_meta.json]: 
Missing identifier "materialProviders" needed by "NavigationBarComponent" from metadata map 
[Error from DirectiveMetadataLinker on frontend|lib/components/event_list_component/event_list_component.ng_summary.json with input frontend|lib/components/event_list_component/event_list_component.ng_meta.json]: 
Missing identifier "materialProviders" needed by "EventListComponent" from metadata map 
[Error from DirectiveMetadataLinker on frontend|lib/components/event_detail_component/event_detail_component.ng_summary.json with input frontend|lib/components/event_detail_component/event_detail_component.ng_meta.json]: 
Missing identifier "materialProviders" needed by "EventDetailComponent" from metadata map 
[Error from TemplateCompiler on frontend|lib/app_component.ng_meta.json]: 
Could not find Directive/Pipe entry for name: NavigationBarComponent 
. Please be aware that Dart transformers have limited support for reusable, pre-defined lists of Directives/Pipes (aka "directive/pipe aliases"). See for details. 
Building frontend... (12.2s) 
+1

嗨法比安 我快速看了一下 - 它確實看起來確實有用 - 例如畫廊應用程序(https://dart-lang.github.io/angular2_components_example/)是使用相同的配置構建的,的時間代碼生成: https://github.com/dart-lang/angular2_components_example – matanlurey

回答

1

我推薦使用標準的變壓器,因爲它包括反射去除相位已經https://github.com/dart-lang/angular2/blob/master/lib/src/transform/transformer.dart#L37

如果必須使用備用變壓器angular2 /變換/代碼生成,那麼你需要一個版本使用相同的變壓器angular2_components的。

我嘗試通過添加以下內容到pubspec.yaml:

dependency_override 
    angular2_components: 
    path: ../../angular2_components 

在我提供的路徑,我有混帳回購協議的本地克隆,我改變了pubspec.yaml文件中使用:

transformers: 
    - angular2/transform/codegen: 
    ... 

這讓包建。

+0

非常感謝,這似乎是這個問題。我不完全知道爲什麼我將變壓器改爲codegen。我想一些教程肯定會提出它,當時它也起作用。我現在再次使用原始變壓器,並對此感到滿意。至少有這個問題。另一個是在一個單獨的bugreport ... – Fabian