feat(dart/transform): Remove unnecessary .ng_deps.dart files

Removes `.ng_deps.dart` files which

1. Do not register any `@Injectable` classes
2. Do not call `initReflector` on any other `.ng_deps.dart` files.

Closes #1929
This commit is contained in:
Tim Blasi
2015-05-22 14:15:18 -07:00
parent cda35101df
commit c065fb1422
15 changed files with 166 additions and 65 deletions

View File

@ -3,9 +3,13 @@ library angular2.transform.common.options;
import 'annotation_matcher.dart';
import 'mirror_mode.dart';
const ENTRY_POINT_PARAM = 'entry_points';
const REFLECTION_ENTRY_POINT_PARAM = 'reflection_entry_points';
/// See `optimizationPhases` below for an explanation.
const DEFAULT_OPTIMIZATION_PHASES = 5;
const CUSTOM_ANNOTATIONS_PARAM = 'custom_annotations';
const ENTRY_POINT_PARAM = 'entry_points';
const OPTIMIZATION_PHASES_PARAM = 'optimization_phases';
const REFLECTION_ENTRY_POINT_PARAM = 'reflection_entry_points';
/// Provides information necessary to transform an Angular2 app.
class TransformerOptions {
@ -28,20 +32,32 @@ class TransformerOptions {
/// The [AnnotationMatcher] which is used to identify angular annotations.
final AnnotationMatcher annotationMatcher;
/// The number of phases to spend optimizing output size.
/// Each additional phase adds time to the transformation but may decrease
/// final output size. There is a limit beyond which this will no longer
/// decrease size, that is, setting this to 20 may not decrease size any
/// more than setting it to 10, but you will still pay an additional
/// penalty in transformation time.
/// The "correct" number of phases varies with the structure of the app.
final int optimizationPhases;
TransformerOptions._internal(this.entryPoints, this.reflectionEntryPoints,
this.modeName, this.mirrorMode, this.initReflector,
this.annotationMatcher);
this.annotationMatcher, this.optimizationPhases);
factory TransformerOptions(List<String> entryPoints,
{List<String> reflectionEntryPoints, String modeName: 'release',
MirrorMode mirrorMode: MirrorMode.none, bool initReflector: true,
List<AnnotationDescriptor> customAnnotationDescriptors: const []}) {
List<AnnotationDescriptor> customAnnotationDescriptors: const [],
int optimizationPhases: DEFAULT_OPTIMIZATION_PHASES}) {
if (reflectionEntryPoints == null || reflectionEntryPoints.isEmpty) {
reflectionEntryPoints = entryPoints;
}
var annotationMatcher = new AnnotationMatcher()
..addAll(customAnnotationDescriptors);
optimizationPhases = optimizationPhases.isNegative ? 0 : optimizationPhases;
return new TransformerOptions._internal(entryPoints, reflectionEntryPoints,
modeName, mirrorMode, initReflector, annotationMatcher);
modeName, mirrorMode, initReflector, annotationMatcher,
optimizationPhases);
}
}

View File

@ -26,12 +26,15 @@ TransformerOptions parseBarbackSettings(BarbackSettings settings) {
mirrorMode = MirrorMode.none;
break;
}
var optimizationPhases = _readInt(config, OPTIMIZATION_PHASES_PARAM,
defaultValue: DEFAULT_OPTIMIZATION_PHASES);
return new TransformerOptions(entryPoints,
reflectionEntryPoints: reflectionEntryPoints,
modeName: settings.mode.name,
mirrorMode: mirrorMode,
initReflector: initReflector,
customAnnotationDescriptors: _readCustomAnnotations(config));
customAnnotationDescriptors: _readCustomAnnotations(config),
optimizationPhases: optimizationPhases);
}
/// Cribbed from the polymer project.
@ -56,6 +59,18 @@ List<String> _readFileList(Map config, String paramName) {
return files;
}
int _readInt(Map config, String paramName, {int defaultValue: null}) {
if (!config.containsKey(paramName)) return defaultValue;
var value = config[paramName];
if (value is String) {
value = int.parse(value);
}
if (value is! int) {
throw new ArgumentError.value(value, paramName, 'Expected an integer');
}
return value;
}
/// Parse the [CUSTOM_ANNOTATIONS_PARAM] options out of the transformer into
/// [AnnotationDescriptor]s.
List<AnnotationDescriptor> _readCustomAnnotations(Map config) {