Skip to content

Commit 3531bb7

Browse files
committed
feat(bootstrap): remove the need for explicit reflection setup in bootstrap code
BREAKING CHANGES: Dart applications and TypeScript applications meant to transpile to Dart must now import `package:angular2/bootstrap.dart` instead of `package:angular2/angular2.dart` in their bootstrap code. `package:angular2/angular2.dart` no longer export the bootstrap function. The transformer rewrites imports of `bootstrap.dart` and calls to `bootstrap` to `bootstrap_static.dart` and `bootstrapStatic` respectively.
1 parent 55e8dca commit 3531bb7

File tree

119 files changed

+896
-827
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+896
-827
lines changed

modules/angular2/angular2.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
library angular2;
2+
3+
/**
4+
* An all-in-one place to import Angular 2 stuff.
5+
*
6+
* This library does not include `bootstrap`. Import `bootstrap.dart` instead.
7+
*/
8+
export 'package:angular2/angular2_exports.dart';

modules/angular2/angular2.ts

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
/**
22
* The `angular2` is the single place to import all of the individual types.
33
*/
4+
export {commonBootstrap as bootstrap} from 'angular2/src/core/application_common';
5+
6+
// TODO(someone familiar with systemjs): the exports below are copied from
7+
// angular2_exports.ts. Re-exporting from angular2_exports.ts causes systemjs
8+
// to resolve imports very very very slowly. See also a similar notice in
9+
// bootstrap.ts
410
export * from 'angular2/annotations';
511
export * from 'angular2/core';
612

@@ -28,34 +34,7 @@ export {
2834

2935
export * from './di';
3036
export * from './forms';
31-
3237
export * from './directives';
33-
34-
export {
35-
AbstractControl,
36-
AbstractControlDirective,
37-
Control,
38-
ControlGroup,
39-
ControlArray,
40-
NgControlName,
41-
NgFormControl,
42-
NgModel,
43-
NgControl,
44-
NgControlGroup,
45-
NgFormModel,
46-
NgForm,
47-
ControlValueAccessor,
48-
DefaultValueAccessor,
49-
CheckboxControlValueAccessor,
50-
SelectControlValueAccessor,
51-
formDirectives,
52-
Validators,
53-
NgValidator,
54-
NgRequiredValidator,
55-
FormBuilder,
56-
formInjectables
57-
} from './forms';
58-
5938
export * from './http';
6039
export {
6140
RenderEventDispatcher,
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
export * from 'angular2/annotations';
2+
export * from 'angular2/core';
3+
4+
export {
5+
DehydratedException,
6+
ExpressionChangedAfterItHasBeenChecked,
7+
ChangeDetectionError,
8+
9+
ON_PUSH,
10+
DEFAULT,
11+
12+
ChangeDetectorRef,
13+
14+
Pipes,
15+
WrappedValue,
16+
Pipe,
17+
PipeFactory,
18+
NullPipe,
19+
NullPipeFactory,
20+
defaultPipes,
21+
BasePipe,
22+
23+
Locals
24+
} from './change_detection';
25+
26+
export * from './di';
27+
export * from './forms';
28+
export * from './directives';
29+
export * from './http';
30+
export {
31+
RenderEventDispatcher,
32+
Renderer,
33+
RenderElementRef,
34+
RenderViewRef,
35+
RenderProtoViewRef,
36+
RenderFragmentRef,
37+
RenderViewWithFragments
38+
} from 'angular2/src/render/api';
39+
export {
40+
DomRenderer,
41+
DOCUMENT_TOKEN,
42+
DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES
43+
} from 'angular2/src/render/dom/dom_renderer';

modules/angular2/bootstrap.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Contains everything you need to bootstrap your application.
3+
*/
4+
export {bootstrap} from 'angular2/src/core/application';
5+
6+
// TODO(someone familiar with systemjs): the exports below are copied from
7+
// angular2_exports.ts. Re-exporting from angular2_exports.ts causes systemjs
8+
// to resolve imports very very very slowly. See also a similar notice in
9+
// angular2.ts
10+
export * from 'angular2/annotations';
11+
export * from 'angular2/core';
12+
13+
export {
14+
DehydratedException,
15+
ExpressionChangedAfterItHasBeenChecked,
16+
ChangeDetectionError,
17+
18+
ON_PUSH,
19+
DEFAULT,
20+
21+
ChangeDetectorRef,
22+
23+
Pipes,
24+
WrappedValue,
25+
Pipe,
26+
PipeFactory,
27+
NullPipe,
28+
NullPipeFactory,
29+
defaultPipes,
30+
BasePipe,
31+
32+
Locals
33+
} from './change_detection';
34+
35+
export * from './di';
36+
export * from './forms';
37+
export * from './directives';
38+
export * from './http';
39+
export {
40+
RenderEventDispatcher,
41+
Renderer,
42+
RenderElementRef,
43+
RenderViewRef,
44+
RenderProtoViewRef,
45+
RenderFragmentRef,
46+
RenderViewWithFragments
47+
} from 'angular2/src/render/api';
48+
export {
49+
DomRenderer,
50+
DOCUMENT_TOKEN,
51+
DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES
52+
} from 'angular2/src/render/dom/dom_renderer';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
library angular2.bootstrap_static;
2+
3+
export 'angular2_exports.dart';
4+
export 'src/core/application_static.dart';

modules/angular2/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* @description
44
* Define angular core API here.
55
*/
6-
export {bootstrap, ApplicationRef} from 'angular2/src/core/application';
76
export {appComponentTypeToken} from 'angular2/src/core/application_tokens';
7+
export {ApplicationRef} from 'angular2/src/core/application_common';
88

99

1010
// Compiler Related Dependencies.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
library angular2.application;
2+
3+
import 'dart:async';
4+
5+
import 'package:angular2/src/reflection/reflection.dart' show reflector;
6+
import 'package:angular2/src/reflection/reflection_capabilities.dart' show ReflectionCapabilities;
7+
import 'application_common.dart';
8+
9+
export 'application_common.dart' show ApplicationRef;
10+
11+
/// Starts an application from a root component. This implementation uses
12+
/// mirrors. Angular 2 transformer automatically replaces this method with a
13+
/// static implementation (see `application_static.dart`) that does not use
14+
/// mirrors and produces a faster and more compact JS code.
15+
///
16+
/// See [commonBootstrap] for detailed documentation.
17+
Future<ApplicationRef> bootstrap(Type appComponentType,
18+
[List componentInjectableBindings, Function errorReporter]) {
19+
reflector.reflectionCapabilities = new ReflectionCapabilities();
20+
return commonBootstrap(appComponentType, componentInjectableBindings, errorReporter);
21+
}

0 commit comments

Comments
 (0)