|
38 | 38 | specify the angular2 and browser packages as dependencies,
|
39 | 39 | as well as the angular2 transformer.
|
40 | 40 | Angular 2 is changing rapidly, so provide an exact version:
|
41 |
| - <b>2.0.0-alpha.29</b>. |
| 41 | + <b>2.0.0-alpha.33</b>. |
42 | 42 |
|
43 | 43 | code-example(language="yaml" format="linenums").
|
44 | 44 | name: hello_world
|
45 | 45 | version: 0.0.1
|
46 | 46 | dependencies:
|
47 |
| - angular2: 2.0.0-alpha.29 |
| 47 | + angular2: 2.0.0-alpha.33 |
48 | 48 | browser: ^0.10.0
|
49 | 49 | transformers:
|
50 | 50 | - angular2:
|
|
73 | 73 | > <span class="blk">vim web/main.dart</span> # Use your favorite editor!
|
74 | 74 |
|
75 | 75 | p.
|
76 |
| - Edit <code>web/main.dart</code> to import the angular2 library |
77 |
| - and two reflection libraries: |
| 76 | + Edit <code>web/main.dart</code> to import the Angular bootstrap library: |
78 | 77 |
|
79 | 78 | code-example(language="dart" format="linenums").
|
80 |
| - import 'package:angular2/angular2.dart'; |
81 |
| - import 'package:angular2/src/reflection/reflection.dart' show reflector; |
82 |
| - import 'package:angular2/src/reflection/reflection_capabilities.dart' |
83 |
| - show ReflectionCapabilities; |
| 79 | + import 'package:angular2/bootstrap.dart'; |
84 | 80 | //- STEP 3 - Define a component ##########################
|
85 | 81 | .l-main-section
|
86 | 82 |
|
| 83 | + .l-sub-section |
| 84 | + h3 Top-level Angular 2 libraries |
| 85 | + |
| 86 | + p. |
| 87 | + The main Dart file for any Angular 2 app must import |
| 88 | + <code>'package:angular2/bootstrap.dart'</code>. |
| 89 | + If you put part of your app into one or more additional libraries, |
| 90 | + those additional libraries must import <code>angular2.dart</code> |
| 91 | + instead of <code>bootstrap.dart</code>, |
| 92 | + |
| 93 | + p. |
| 94 | + The <code>bootstrap.dart</code> and <code>angular2.dart</code> files |
| 95 | + provide the same API, |
| 96 | + except that <code>bootstrap.dart</code> also provides a |
| 97 | + <code>bootstrap()</code> function, which you'll see a little later. |
| 98 | + For <a href="#performance">performance reasons</a>, |
| 99 | + use <code>angular2.dart</code> whenever possible. |
| 100 | + |
87 | 101 | h2#section-angular-create-account 3. Define a component
|
88 | 102 |
|
89 | 103 | p.
|
|
163 | 177 |
|
164 | 178 | code-example(language="dart" format="linenums:16").
|
165 | 179 | main() {
|
166 |
| - reflector.reflectionCapabilities = new ReflectionCapabilities(); |
167 | 180 | bootstrap(AppComponent);
|
168 | 181 | }
|
169 | 182 |
|
|
173 | 186 | The argument to <code>bootstrap()</code> is the name of the component class
|
174 | 187 | you defined above.
|
175 | 188 |
|
176 |
| - p. |
177 |
| - Setting the value of <code>reflector.reflectionCapabilities</code> |
178 |
| - lets your app use the Dart VM's reflection (dart:mirrors) |
179 |
| - when running in Dartium. |
180 |
| - Reflection is fast in native Dart, |
181 |
| - so using it makes sense during development. |
182 |
| - Later, when you build a JavaScript version of your app, |
183 |
| - the Angular transformer will |
184 |
| - convert the reflection-using code to static code, |
185 |
| - so your generated JavaScript can be smaller and faster. |
186 |
| - |
187 | 189 |
|
188 | 190 | //- STEP 5 - Declare the HTML ##########################
|
189 | 191 | .l-main-section
|
|
245 | 247 |
|
246 | 248 | code-example(language="basic").
|
247 | 249 | > <span class="blk">pub build</span>
|
248 |
| - Loading source assets... |
249 |
| - Loading angular2 transformers... |
250 |
| - INFO: Formatter is being overwritten. |
251 |
| - Building hello_world... (4.2s) |
| 250 | + Loading source assets... |
| 251 | + ... |
| 252 | + Building hello_world... (5.7s) |
252 | 253 | [Info from Dart2JS]:
|
253 | 254 | Compiling hello_world|web/main.dart...
|
254 | 255 | [Info from Dart2JS]:
|
255 |
| - Took 0:00:16.908569 to compile hello_world|web/main.dart. |
256 |
| - Built 75 files to "build". |
257 |
| - //- REGENERATE THIS OUTPUT - or delete it? - when updating from 2.0.0-alpha.29 |
| 256 | + Took 0:00:19.177402 to compile hello_world|web/main.dart. |
| 257 | + Built 303 files to "build". |
| 258 | + //- REGENERATE THIS OUTPUT - or delete it? - when updating from 2.0.0-alpha.33 |
258 | 259 |
|
259 | 260 | p.
|
260 | 261 | The generated JavaScript appears, along with supporting files,
|
|
273 | 274 | name: hello_world
|
274 | 275 | version: 0.0.1
|
275 | 276 | dependencies:
|
276 |
| - angular2: 2.0.0-alpha.29 |
| 277 | + angular2: 2.0.0-alpha.33 |
277 | 278 | browser: ^0.10.0
|
278 | 279 | <span class="pnk">transformers:
|
279 | 280 | - angular2:
|
|
286 | 287 | <a href="https://github.com/angular/angular/wiki/Angular-2-Dart-Transformer">Angular
|
287 | 288 | transformer wiki page</a>.
|
288 | 289 |
|
| 290 | + |
| 291 | + #performance.l-sub-section |
| 292 | + h3 Performance, the transformer, and Angular 2 libraries |
| 293 | + |
| 294 | + p. |
| 295 | + When you import <code>bootstrap.dart</code>, |
| 296 | + you also get <code>dart:mirrors</code>, |
| 297 | + a reflection library that |
| 298 | + causes performance problems when compiled to JavaScript. |
| 299 | + Don't worry, |
| 300 | + the Angular transformer converts your entry points |
| 301 | + so that they don't use mirrors. |
| 302 | + The transformer doesn't convert other libraries in your app, |
| 303 | + so be sure to |
| 304 | + import <code>angular2.dart</code> instead of <code>bootstrap.dart</code> |
| 305 | + in any libraries you create that use Angular 2 |
| 306 | + but don't call <code>bootstrap()</code>. |
| 307 | + |
| 308 | + |
289 | 309 | //- WHAT'S NEXT... ##########################
|
290 | 310 | .l-main-section
|
291 | 311 | h2#section-transpile Great job! Next step...
|
|
0 commit comments