feat(dart/transform): Use angular2/platform/browser as bootstrap lib

Update the Angular 2 transformer to recognize
`package:angular2/platform/browser.dart` as the library which exports
the `bootstrap` function.

Update playground, examples, benchmarks, & tests to import bootstrap from
platform/browser.

Closes #7647
This commit is contained in:
Tim Blasi
2016-03-17 12:49:46 -07:00
committed by Timothy Blasi
parent c194f6695d
commit b6507e37ef
77 changed files with 130 additions and 88 deletions

View File

@ -3,11 +3,29 @@ library angular2.transform.common.mirror_matcher;
import 'package:analyzer/src/generated/ast.dart';
import 'package:angular2/src/transform/common/names.dart';
const BOOTSTRAP_STATIC_URI = 'package:angular2/bootstrap_static.dart';
const BOOTSTRAP_URI = 'package:angular2/bootstrap.dart';
const REFLECTION_CAPABILITIES_URI =
/// Files from which `bootstrap` is exported.
///
/// These files transitively imports dart:mirrors.
/// They should be replaced with [BOOTSTRAP_STATIC_URI] in production apps.
const _BOOTSTRAP_URIS = const <String>[
'package:angular2/bootstrap.dart',
'package:angular2/platform/browser.dart',
];
/// File from which `ReflectionCapabilities` is exported.
///
/// This file transitively imports dart:mirrors and should be removed from
/// production apps. The Angular2 reflection framework should be initialized
/// with generated code such that no reflection is necessary.
const _REFLECTION_CAPABILITIES_URI =
'package:angular2/src/core/reflection/reflection_capabilities.dart';
/// File from which `bootstrapStatic` is exported.
///
/// This file does not transitively import dart:mirrors.
/// It should be used in place of [_BOOTSTRAP_URIS] in production apps.
const BOOTSTRAP_STATIC_URI = 'package:angular2/platform/browser_static.dart';
/// Syntactially checks for code related to the use of `dart:mirrors`.
///
/// Checks various [AstNode]s to determine if they are
@ -20,10 +38,9 @@ class MirrorMatcher {
'${node.constructorName.type.name}' == REFLECTION_CAPABILITIES_NAME;
bool hasReflectionCapabilitiesUri(UriBasedDirective node) {
return node.uri.stringValue == REFLECTION_CAPABILITIES_URI;
return node.uri.stringValue == _REFLECTION_CAPABILITIES_URI;
}
bool hasBootstrapUri(UriBasedDirective node) {
return node.uri.stringValue == BOOTSTRAP_URI;
}
bool hasBootstrapUri(UriBasedDirective node) =>
_BOOTSTRAP_URIS.contains(node.uri.stringValue);
}