feat(dart/transform): Add a di
transformer
Add a transformer for `di` which generates `.ng_deps.dart` files for all `.dart` files it is run on. These `.ng_deps.dart` files register metadata for any `@Injectable` classes. Fix unit tests for changes introduced by the di transformer. When using `pub (build|serve) --mode=ngstatic`, we will also generate getters and setters, parse templates, and remove import of `dart:mirrors` in the Angular transform. Because this is still relatively immature, we use the mode to keep it opt-in for now. Closes #700
This commit is contained in:
@ -9,20 +9,27 @@ import 'bind_generator/transformer.dart';
|
||||
import 'reflection_remover/transformer.dart';
|
||||
import 'template_compiler/transformer.dart';
|
||||
import 'common/formatter.dart' as formatter;
|
||||
import 'common/names.dart';
|
||||
import 'common/options.dart';
|
||||
|
||||
export 'common/options.dart';
|
||||
|
||||
/// Replaces Angular 2 mirror use with generated code.
|
||||
class AngularTransformerGroup extends TransformerGroup {
|
||||
AngularTransformerGroup(TransformerOptions options) : super([
|
||||
[new DirectiveProcessor(options)],
|
||||
[new DirectiveLinker(options)],
|
||||
AngularTransformerGroup._(phases) : super(phases) {
|
||||
formatter.init(new DartFormatter());
|
||||
}
|
||||
|
||||
factory AngularTransformerGroup(TransformerOptions options) {
|
||||
var phases = [[new DirectiveProcessor(options)], [new DirectiveLinker()]];
|
||||
if (options.modeName == TRANSFORM_MODE) {
|
||||
phases.addAll([
|
||||
[new BindGenerator(options)],
|
||||
[new TemplateComplier(options)],
|
||||
[new ReflectionRemover(options)]
|
||||
]) {
|
||||
formatter.init(new DartFormatter());
|
||||
]);
|
||||
}
|
||||
return new AngularTransformerGroup._(phases);
|
||||
}
|
||||
|
||||
factory AngularTransformerGroup.asPlugin(BarbackSettings settings) {
|
||||
@ -33,5 +40,6 @@ class AngularTransformerGroup extends TransformerGroup {
|
||||
TransformerOptions _parseOptions(BarbackSettings settings) {
|
||||
var config = settings.configuration;
|
||||
return new TransformerOptions(config[ENTRY_POINT_PARAM],
|
||||
reflectionEntryPoint: config[REFLECTION_ENTRY_POINT_PARAM]);
|
||||
reflectionEntryPoint: config[REFLECTION_ENTRY_POINT_PARAM],
|
||||
modeName: settings.mode.name);
|
||||
}
|
||||
|
Reference in New Issue
Block a user