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:
@ -7,3 +7,4 @@ const REGISTER_TYPE_METHOD_NAME = 'registerType';
|
||||
const REGISTER_GETTERS_METHOD_NAME = 'registerGetters';
|
||||
const REGISTER_SETTERS_METHOD_NAME = 'registerSetters';
|
||||
const REGISTER_METHODS_METHOD_NAME = 'registerMethods';
|
||||
const TRANSFORM_MODE = 'ngstatic';
|
||||
|
@ -13,9 +13,14 @@ class TransformerOptions {
|
||||
/// application's [ReflectionCapabilities] are set.
|
||||
final String reflectionEntryPoint;
|
||||
|
||||
TransformerOptions._internal(this.entryPoint, this.reflectionEntryPoint);
|
||||
/// The `BarbackMode#name` we are running in.
|
||||
final String modeName;
|
||||
|
||||
factory TransformerOptions(String entryPoint, {String reflectionEntryPoint}) {
|
||||
TransformerOptions._internal(
|
||||
this.entryPoint, this.reflectionEntryPoint, this.modeName);
|
||||
|
||||
factory TransformerOptions(String entryPoint,
|
||||
{String reflectionEntryPoint, String modeName: 'release'}) {
|
||||
if (entryPoint == null) {
|
||||
throw new ArgumentError.notNull(ENTRY_POINT_PARAM);
|
||||
} else if (entryPoint.isEmpty) {
|
||||
@ -24,6 +29,7 @@ class TransformerOptions {
|
||||
if (reflectionEntryPoint == null || entryPoint.isEmpty) {
|
||||
reflectionEntryPoint = entryPoint;
|
||||
}
|
||||
return new TransformerOptions._internal(entryPoint, reflectionEntryPoint);
|
||||
return new TransformerOptions._internal(
|
||||
entryPoint, reflectionEntryPoint, modeName);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user