0

有一段时间我的印象是 Angular2 Dart 代码生成是开发的前进方向。不幸的是,最近我似乎不能再使用 codegen 了。这是我的 pubspec.yaml,它不起作用并产生错误。通过仅删除 /transform/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)
4

1 回答 1

1

我建议使用标准变压器,因为它已经包含反射去除器阶段https://github.com/dart-lang/angular2/blob/master/lib/src/transform/transformer.dart#L37

如果您必须使用备用变压器 angular2/transform/codegen,那么您需要使用相同变压器的 angular2_components 版本。

我通过将其添加到您的 pubspec.yaml 进行了实验:

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

在我提供的路径中,我有一个 git repo 的本地克隆,我在其中更改了要使用的 pubspec.yaml 文件:

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

这允许构建包。

于 2017-02-27T22:59:27.580 回答