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

@ -4,7 +4,7 @@ Bootstrapping
@description @description
{@target ts}`import {bootstrap} from 'angular2/platform/browser';`{@endtarget} {@target ts}`import {bootstrap} from 'angular2/platform/browser';`{@endtarget}
{@target js}Available from the `ng.platform.browser` namespace{@endtarget} {@target js}Available from the `ng.platform.browser` namespace{@endtarget}
{@target dart}`import 'package:angular2/bootstrap.dart';`{@endtarget} {@target dart}`import 'package:angular2/platform/browser.dart';`{@endtarget}
@cheatsheetItem @cheatsheetItem
syntax(ts dart): syntax(ts dart):

View File

@ -1,5 +1,5 @@
import {provide} from 'angular2/core'; import {provide} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {UrlResolver} from 'angular2/compiler'; import {UrlResolver} from 'angular2/compiler';
var MyApp: any; var MyApp: any;

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {NG_VALIDATORS} from 'angular2/common'; import {NG_VALIDATORS} from 'angular2/common';
import {Provider} from 'angular2/core'; import {Provider} from 'angular2/core';

View File

@ -1,5 +1,5 @@
import {Component, provide} from 'angular2/core'; import {Component, provide} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {Observable, Subscriber} from 'rxjs/Rx'; import {Observable, Subscriber} from 'rxjs/Rx';
// #docregion AsyncPipe // #docregion AsyncPipe

View File

@ -1,5 +1,5 @@
import {Component, provide} from 'angular2/core'; import {Component, provide} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
// #docregion DatePipe // #docregion DatePipe
@Component({ @Component({

View File

@ -1,5 +1,5 @@
import {Component, provide} from 'angular2/core'; import {Component, provide} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
// #docregion JsonPipe // #docregion JsonPipe
@Component({ @Component({

View File

@ -1,5 +1,5 @@
import {Component, provide} from 'angular2/core'; import {Component, provide} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
// #docregion LowerUpperPipe // #docregion LowerUpperPipe
@Component({ @Component({

View File

@ -1,5 +1,5 @@
import {Component, provide} from 'angular2/core'; import {Component, provide} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
// #docregion NumberPipe // #docregion NumberPipe
@Component({ @Component({

View File

@ -1,5 +1,5 @@
import {Component, provide} from 'angular2/core'; import {Component, provide} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
// #docregion SlicePipe_string // #docregion SlicePipe_string
@Component({ @Component({

View File

@ -1,6 +1,6 @@
// #docregion enableProdMode // #docregion enableProdMode
import {enableProdMode} from 'angular2/core'; import {enableProdMode} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {MyComponent} from './my_component'; import {MyComponent} from './my_component';
enableProdMode(); enableProdMode();

View File

@ -1,5 +1,5 @@
import {provide, Component} from 'angular2/core'; import {provide, Component} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import { import {
CanActivate, CanActivate,
RouteConfig, RouteConfig,

View File

@ -1,5 +1,5 @@
import {provide, Component} from 'angular2/core'; import {provide, Component} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import { import {
CanDeactivate, CanDeactivate,
RouteConfig, RouteConfig,

View File

@ -1,5 +1,5 @@
import {Component, provide} from 'angular2/core'; import {Component, provide} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import { import {
OnActivate, OnActivate,
ComponentInstruction, ComponentInstruction,

View File

@ -1,5 +1,5 @@
import {Component, Injectable, provide} from 'angular2/core'; import {Component, Injectable, provide} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import { import {
OnDeactivate, OnDeactivate,
ComponentInstruction, ComponentInstruction,

View File

@ -1,5 +1,5 @@
import {Component, provide} from 'angular2/core'; import {Component, provide} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import { import {
CanActivate, CanActivate,
RouteConfig, RouteConfig,

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter'; import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
import {DOM} from 'angular2/src/platform/dom/dom_adapter'; import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {PromiseWrapper} from 'angular2/src/facade/async'; import {PromiseWrapper} from 'angular2/src/facade/async';

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {Component, Directive, DynamicComponentLoader, ElementRef} from 'angular2/core'; import {Component, Directive, DynamicComponentLoader, ElementRef} from 'angular2/core';
import {NgIf, NgFor} from 'angular2/common'; import {NgIf, NgFor} from 'angular2/common';
import {ApplicationRef} from 'angular2/src/core/application_ref'; import {ApplicationRef} from 'angular2/src/core/application_ref';

View File

@ -7,7 +7,7 @@ import {
windowProfile, windowProfile,
windowProfileEnd windowProfileEnd
} from 'angular2/src/testing/benchmark_util'; } from 'angular2/src/testing/benchmark_util';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {Component, Directive, bind, provide} from 'angular2/core'; import {Component, Directive, bind, provide} from 'angular2/core';
import {NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/common'; import {NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/common';
import {ApplicationRef} from 'angular2/src/core/application_ref'; import {ApplicationRef} from 'angular2/src/core/application_ref';

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {App} from './app'; import {App} from './app';

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {NgIf} from 'angular2/common'; import {NgIf} from 'angular2/common';
import { import {
Compiler, Compiler,

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import { import {
Compiler, Compiler,
Component, Component,

View File

@ -1,5 +1,5 @@
import {Component} from 'angular2/core'; import {Component} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
@Component({ @Component({
selector: 'hello-app', selector: 'hello-app',

View File

@ -1,5 +1,5 @@
import {AnimateApp} from './animate-app'; import {AnimateApp} from './animate-app';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
export function main() { export function main() {
bootstrap(AnimateApp); bootstrap(AnimateApp);

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {Component} from 'angular2/core'; import {Component} from 'angular2/core';
import {NgIf} from 'angular2/common'; import {NgIf} from 'angular2/common';
import {TimerWrapper} from 'angular2/src/facade/async'; import {TimerWrapper} from 'angular2/src/facade/async';

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {Component} from 'angular2/core'; import {Component} from 'angular2/core';
@Component({selector: 'gestures-app', templateUrl: 'template.html'}) @Component({selector: 'gestures-app', templateUrl: 'template.html'})

View File

@ -1,5 +1,5 @@
import {Component, provide} from 'angular2/core'; import {Component, provide} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import { import {
RouteConfig, RouteConfig,
Route, Route,

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {Renderer, ElementRef, Component, Directive, Injectable} from 'angular2/core'; import {Renderer, ElementRef, Component, Directive, Injectable} from 'angular2/core';
export function main() { export function main() {

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {HTTP_PROVIDERS} from 'angular2/http'; import {HTTP_PROVIDERS} from 'angular2/http';
import {HttpCmp} from './http_comp'; import {HttpCmp} from './http_comp';

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {JSONP_PROVIDERS} from 'angular2/http'; import {JSONP_PROVIDERS} from 'angular2/http';
import {JsonpCmp} from './jsonp_comp'; import {JsonpCmp} from './jsonp_comp';

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {Component} from 'angular2/core'; import {Component} from 'angular2/core';
import {KeyEventsPlugin} from 'angular2/src/platform/dom/events/key_events'; import {KeyEventsPlugin} from 'angular2/src/platform/dom/events/key_events';

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import { import {
FORM_DIRECTIVES, FORM_DIRECTIVES,
ControlGroup, ControlGroup,

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import { import {
Component, Component,
Directive, Directive,

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {Component, Directive, Host, forwardRef, Provider, Injectable} from 'angular2/core'; import {Component, Directive, Host, forwardRef, Provider, Injectable} from 'angular2/core';
import {NgIf, NgFor, FORM_DIRECTIVES} from 'angular2/common'; import {NgIf, NgFor, FORM_DIRECTIVES} from 'angular2/common';

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {Renderer, ElementRef, Component, Directive, Injectable} from 'angular2/core'; import {Renderer, ElementRef, Component, Directive, Injectable} from 'angular2/core';
import {MyCmp} from './my_cmp/my_cmp'; import {MyCmp} from './my_cmp/my_cmp';

View File

@ -1,6 +1,6 @@
import {InboxApp} from './inbox-app'; import {InboxApp} from './inbox-app';
import {provide} from 'angular2/core'; import {provide} from 'angular2/core';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {ROUTER_PROVIDERS, HashLocationStrategy, LocationStrategy} from 'angular2/router'; import {ROUTER_PROVIDERS, HashLocationStrategy, LocationStrategy} from 'angular2/router';
export function main() { export function main() {

View File

@ -1,5 +1,5 @@
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions'; import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {Component} from 'angular2/core'; import {Component} from 'angular2/core';
@Component({ @Component({

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {Component} from 'angular2/core'; import {Component} from 'angular2/core';
@Component({selector: '[svg-group]', template: `<svg:text x="20" y="20">Hello</svg:text>`}) @Component({selector: '[svg-group]', template: `<svg:text x="20" y="20">Hello</svg:text>`})

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {Component, Directive, Host, forwardRef, Provider} from 'angular2/core'; import {Component, Directive, Host, forwardRef, Provider} from 'angular2/core';
import { import {
ControlGroup, ControlGroup,

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {Component} from 'angular2/core'; import {Component} from 'angular2/core';
import {NgFor} from 'angular2/common'; import {NgFor} from 'angular2/common';
import {Store, Todo, TodoFactory} from './services/TodoStore'; import {Store, Todo, TodoFactory} from './services/TodoStore';

View File

@ -1,4 +1,4 @@
import {bootstrap} from "angular2/bootstrap"; import {bootstrap} from "angular2/platform/browser";
import {ImageDemo} from "./index_common"; import {ImageDemo} from "./index_common";
export function main() { export function main() {

View File

@ -1,4 +1,4 @@
import {bootstrap} from 'angular2/bootstrap'; import {bootstrap} from 'angular2/platform/browser';
import {Component} from 'angular2/core'; import {Component} from 'angular2/core';
import {Zippy} from './zippy'; import {Zippy} from './zippy';

View File

@ -1,6 +1,7 @@
library hello_world.index; library hello_world.index;
import "package:angular2/bootstrap.dart" show AngularEntrypoint, bootstrap; import "package:angular2/platform/browser.dart"
show AngularEntrypoint, bootstrap;
import "package:angular2/angular2.dart" import "package:angular2/angular2.dart"
show Component, Directive, ElementRef, Injectable, Renderer; show Component, Directive, ElementRef, Injectable, Renderer;

View File

@ -3,11 +3,29 @@ library angular2.transform.common.mirror_matcher;
import 'package:analyzer/src/generated/ast.dart'; import 'package:analyzer/src/generated/ast.dart';
import 'package:angular2/src/transform/common/names.dart'; import 'package:angular2/src/transform/common/names.dart';
const BOOTSTRAP_STATIC_URI = 'package:angular2/bootstrap_static.dart'; /// Files from which `bootstrap` is exported.
const BOOTSTRAP_URI = 'package:angular2/bootstrap.dart'; ///
const REFLECTION_CAPABILITIES_URI = /// 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'; '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`. /// Syntactially checks for code related to the use of `dart:mirrors`.
/// ///
/// Checks various [AstNode]s to determine if they are /// Checks various [AstNode]s to determine if they are
@ -20,10 +38,9 @@ class MirrorMatcher {
'${node.constructorName.type.name}' == REFLECTION_CAPABILITIES_NAME; '${node.constructorName.type.name}' == REFLECTION_CAPABILITIES_NAME;
bool hasReflectionCapabilitiesUri(UriBasedDirective node) { bool hasReflectionCapabilitiesUri(UriBasedDirective node) {
return node.uri.stringValue == REFLECTION_CAPABILITIES_URI; return node.uri.stringValue == _REFLECTION_CAPABILITIES_URI;
} }
bool hasBootstrapUri(UriBasedDirective node) { bool hasBootstrapUri(UriBasedDirective node) =>
return node.uri.stringValue == BOOTSTRAP_URI; _BOOTSTRAP_URIS.contains(node.uri.stringValue);
}
} }

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';
import 'bar.dart'; import 'bar.dart';

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';
import 'bar.dart'; import 'bar.dart';

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';
import 'bar.dart'; import 'bar.dart';

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';
import 'bar.dart'; import 'bar.dart';

View File

@ -2,7 +2,7 @@ library web_foo.template.dart;
import 'index.dart'; import 'index.dart';
import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef; import 'package:angular2/src/core/reflection/reflection.dart' as _ngRef;
import 'package:angular2/bootstrap_static.dart' show bootstrapStatic; import 'package:angular2/platform/browser_static.dart' show bootstrapStatic;
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
import 'bar.dart'; import 'bar.dart';
import 'bar.template.dart' as i0; import 'bar.template.dart' as i0;

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart' show bootstrap; import 'package:angular2/platform/browser.dart' show bootstrap;
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';
import 'bar.dart'; import 'bar.dart';

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';
import 'bar.dart'; import 'bar.dart';

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';
import 'bar.dart'; import 'bar.dart';

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';
import 'bar.dart'; import 'bar.dart';

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
abstract class TestBootstrapper { abstract class TestBootstrapper {
@AngularEntrypoint() @AngularEntrypoint()

View File

@ -48,7 +48,8 @@ void allTests() {
'should replace uses of mirrors with the debug implementation & ' 'should replace uses of mirrors with the debug implementation & '
'insert calls to generated code in `MirrorMode.debug`.', () { 'insert calls to generated code in `MirrorMode.debug`.', () {
var output = new Rewriter(code, codegen, entrypointMatcher, var output = new Rewriter(code, codegen, entrypointMatcher,
mirrorMode: MirrorMode.debug).rewrite(parseCompilationUnit(code)); mirrorMode: MirrorMode.debug)
.rewrite(parseCompilationUnit(code));
expect(output).toEqual(debug_mirrors.code); expect(output).toEqual(debug_mirrors.code);
}); });
@ -56,24 +57,38 @@ void allTests() {
'should replace uses of mirrors with the verbose implementation ' 'should replace uses of mirrors with the verbose implementation '
'in `MirrorMode.verbose`.', () { 'in `MirrorMode.verbose`.', () {
var output = new Rewriter(code, codegen, entrypointMatcher, var output = new Rewriter(code, codegen, entrypointMatcher,
mirrorMode: MirrorMode.verbose).rewrite(parseCompilationUnit(code)); mirrorMode: MirrorMode.verbose)
.rewrite(parseCompilationUnit(code));
expect(output).toEqual(verbose_mirrors.code); expect(output).toEqual(verbose_mirrors.code);
}); });
it('should not initialize the reflector when `writeStaticInit` is `false`.', it('should not initialize the reflector when `writeStaticInit` is `false`.',
() { () {
var output = new Rewriter(code, codegen, entrypointMatcher, var output =
writeStaticInit: false).rewrite(parseCompilationUnit(code)); new Rewriter(code, codegen, entrypointMatcher, writeStaticInit: false)
.rewrite(parseCompilationUnit(code));
expect(output).toEqual(log_mirrors.code); expect(output).toEqual(log_mirrors.code);
}); });
describe('`bootstrap` import and call', () { describe('`bootstrap` import and call', () {
// TODO(kegluneq): Remove when we remove angular2/bootstrap.dart
it('deprecated import should be rewritten to `bootstrapStatic`.', () {
final bootstrapCode =
readFile('reflection_remover/deprecated_bootstrap_files/index.dart')
.replaceAll('\r\n', '\n');
var output = new Rewriter(bootstrapCode, codegen, entrypointMatcher,
writeStaticInit: true)
.rewrite(parseCompilationUnit(bootstrapCode));
expect(output).toEqual(bootstrap_expected.code);
});
it('should be rewritten to `bootstrapStatic`.', () { it('should be rewritten to `bootstrapStatic`.', () {
final bootstrapCode = final bootstrapCode =
readFile('reflection_remover/bootstrap_files/index.dart') readFile('reflection_remover/bootstrap_files/index.dart')
.replaceAll('\r\n', '\n'); .replaceAll('\r\n', '\n');
var output = new Rewriter(bootstrapCode, codegen, entrypointMatcher, var output = new Rewriter(bootstrapCode, codegen, entrypointMatcher,
writeStaticInit: true).rewrite(parseCompilationUnit(bootstrapCode)); writeStaticInit: true)
.rewrite(parseCompilationUnit(bootstrapCode));
expect(output).toEqual(bootstrap_expected.code); expect(output).toEqual(bootstrap_expected.code);
}); });
@ -81,7 +96,8 @@ void allTests() {
final bootstrapCode = final bootstrapCode =
readFile('reflection_remover/deferred_bootstrap_files/index.dart'); readFile('reflection_remover/deferred_bootstrap_files/index.dart');
var output = new Rewriter(bootstrapCode, codegen, entrypointMatcher, var output = new Rewriter(bootstrapCode, codegen, entrypointMatcher,
writeStaticInit: true).rewrite(parseCompilationUnit(bootstrapCode)); writeStaticInit: true)
.rewrite(parseCompilationUnit(bootstrapCode));
expect(output).toEqual(deferred_bootstrap_expected.code); expect(output).toEqual(deferred_bootstrap_expected.code);
}); });
@ -89,7 +105,8 @@ void allTests() {
final bootstrapCode = final bootstrapCode =
readFile('reflection_remover/combinator_files/index.dart'); readFile('reflection_remover/combinator_files/index.dart');
var output = new Rewriter(bootstrapCode, codegen, entrypointMatcher, var output = new Rewriter(bootstrapCode, codegen, entrypointMatcher,
writeStaticInit: true).rewrite(parseCompilationUnit(bootstrapCode)); writeStaticInit: true)
.rewrite(parseCompilationUnit(bootstrapCode));
expect(output).toEqual(combinator_expected.code); expect(output).toEqual(combinator_expected.code);
}); });
}); });

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';

View File

@ -11,7 +11,7 @@ library angular2.test.transform.reflection_remover.reflection_remover_files;
var code = """ var code = """
library web_foo; library web_foo;
import 'package:angular2/bootstrap_static.dart';import 'index.template.dart' as ngStaticInit; import 'package:angular2/platform/browser_static.dart';import 'index.template.dart' as ngStaticInit;
void main() async { void main() async {
var appRef = await bootstrapStatic(MyComponent, null, () { ngStaticInit.initReflector(); }); var appRef = await bootstrapStatic(MyComponent, null, () { ngStaticInit.initReflector(); });

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
void main() async { void main() async {
var appRef = await bootstrap(MyComponent); var appRef = await bootstrap(MyComponent);

View File

@ -9,7 +9,7 @@ library angular2.test.transform.reflection_remover.combinator_files;
// those we are removing. // those we are removing.
var code = """ var code = """
import 'package:angular2/bootstrap_static.dart' show bootstrapStatic, initReflector;import 'index.template.dart' as ngStaticInit; import 'package:angular2/platform/browser_static.dart' show bootstrapStatic, initReflector;import 'index.template.dart' as ngStaticInit;
void main() { void main() {
bootstrapStatic(MyComponent, null, () { ngStaticInit.initReflector(); }); bootstrapStatic(MyComponent, null, () { ngStaticInit.initReflector(); });

View File

@ -1,4 +1,4 @@
import 'package:angular2/bootstrap.dart' show bootstrap; import 'package:angular2/platform/browser.dart' show bootstrap;
void main() { void main() {
bootstrap(MyComponent); bootstrap(MyComponent);

View File

@ -11,7 +11,7 @@ library angular2.test.transform.debug_reflection_remover_files;
var code = """ var code = """
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart';import 'index.template.dart' as ngStaticInit; import 'package:angular2/platform/browser.dart';import 'index.template.dart' as ngStaticInit;
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
import 'package:angular2/src/core/reflection/debug_reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/debug_reflection_capabilities.dart';

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';

View File

@ -11,7 +11,7 @@ library angular2.test.transform.reflection_remover.debug_mirrors_files.expected;
var code = """ var code = """
library web_foo; library web_foo;
import 'package:angular2/bootstrap_static.dart';import 'index.template.dart' as ngStaticInit; import 'package:angular2/platform/browser_static.dart';import 'index.template.dart' as ngStaticInit;
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
import 'package:angular2/src/core/reflection/debug_reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/debug_reflection_capabilities.dart';

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';

View File

@ -9,7 +9,7 @@ library angular2.test.transform.reflection_remover.deferred_bootstrap_files;
// those we are removing. // those we are removing.
var code = """ var code = """
import 'package:angular2/bootstrap_static.dart' deferred as ng;import 'index.template.dart' as ngStaticInit; import 'package:angular2/platform/browser_static.dart' deferred as ng;import 'index.template.dart' as ngStaticInit;
void main() { void main() {
ng.loadLibrary().then((_) { ng.loadLibrary().then((_) {

View File

@ -1,4 +1,4 @@
import 'package:angular2/bootstrap.dart' deferred as ng; import 'package:angular2/platform/browser.dart' deferred as ng;
void main() { void main() {
ng.loadLibrary().then((_) { ng.loadLibrary().then((_) {

View File

@ -0,0 +1,7 @@
library web_foo;
import 'package:angular2/platform/browser.dart';
void main() async {
var appRef = await bootstrap(MyComponent);
}

View File

@ -11,7 +11,7 @@ library angular2.test.transform.reflection_remover.function_annotation_files;
const code = """ const code = """
library web_foo; library web_foo;
import 'package:angular2/bootstrap_static.dart';import 'index.template.dart' as ngStaticInit; import 'package:angular2/platform/browser_static.dart';import 'index.template.dart' as ngStaticInit;
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
/*import 'package:angular2/src/core/reflection/reflection_capabilities.dart';*/ /*import 'package:angular2/src/core/reflection/reflection_capabilities.dart';*/

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';

View File

@ -11,7 +11,7 @@ library angular2.test.transform.log_mirrors_files.expected;
var code = """ var code = """
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
/*import 'package:angular2/src/core/reflection/reflection_capabilities.dart';*/ /*import 'package:angular2/src/core/reflection/reflection_capabilities.dart';*/

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';

View File

@ -11,7 +11,7 @@ library angular2.test.transform.reflection_remover.method_annotation_files;
const code = """ const code = """
library web_foo; library web_foo;
import 'package:angular2/bootstrap_static.dart';import 'index.template.dart' as ngStaticInit; import 'package:angular2/platform/browser_static.dart';import 'index.template.dart' as ngStaticInit;
class TestBootstrapper { class TestBootstrapper {
@AngularEntrypoint("Method entrypoint") @AngularEntrypoint("Method entrypoint")

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
class TestBootstrapper { class TestBootstrapper {
@AngularEntrypoint("Method entrypoint") @AngularEntrypoint("Method entrypoint")

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';

View File

@ -11,7 +11,7 @@ library angular2.test.transform.reflection_remover.reflection_remover_files;
var code = """ var code = """
library web_foo; library web_foo;
import 'package:angular2/bootstrap_static.dart';import 'index.template.dart' as ngStaticInit; import 'package:angular2/platform/browser_static.dart';import 'index.template.dart' as ngStaticInit;
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
/*import 'package:angular2/src/core/reflection/reflection_capabilities.dart';*/ /*import 'package:angular2/src/core/reflection/reflection_capabilities.dart';*/

View File

@ -1,6 +1,6 @@
library web_foo; library web_foo;
import 'package:angular2/bootstrap.dart'; import 'package:angular2/platform/browser.dart';
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
import 'package:angular2/src/core/reflection/reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/reflection_capabilities.dart';

View File

@ -11,7 +11,7 @@ library angular2.test.transform.reflection_remover.verbose_files.expected;
var code = """ var code = """
library web_foo; library web_foo;
import 'package:angular2/bootstrap_static.dart';import 'index.template.dart' as ngStaticInit; import 'package:angular2/platform/browser_static.dart';import 'index.template.dart' as ngStaticInit;
import 'package:angular2/src/core/reflection/reflection.dart'; import 'package:angular2/src/core/reflection/reflection.dart';
import 'package:angular2/src/core/reflection/debug_reflection_capabilities.dart'; import 'package:angular2/src/core/reflection/debug_reflection_capabilities.dart';