Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 22fcdb3

Browse files
committed
make the transformer more prominent
1 parent 3bd646b commit 22fcdb3

File tree

1 file changed

+59
-44
lines changed

1 file changed

+59
-44
lines changed

public/docs/dart/latest/quickstart.jade

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ p.
1313
<a href="https://www.dartlang.org/downloads/">download Dart</a>.
1414
Then return here.
1515

16-
// STEP 1 - Create a project ##########################
16+
//- STEP 1 - Create a project ##########################
1717
.l-main-section
1818
h2#section-install-angular 1. Create a project
1919

@@ -27,16 +27,21 @@ p.
2727
&gt; <span class="blk">vim pubspec.yaml</span> # Use your favorite editor!
2828

2929
p.
30-
In <code>pubspec.yaml</code>, add the angular2 and browser packages as dependencies.
31-
Angular 2 is changing rapidly, so specify an exact version:
30+
In <code>pubspec.yaml</code>,
31+
specify the angular2 and browser packages as dependencies,
32+
as well as the angular2 transformer.
33+
Angular 2 is changing rapidly, so provide an exact version:
3234
<b>2.0.0-alpha.25</b>.
3335

34-
code-example(language="yaml").
36+
code-example(language="yaml" format="linenums").
3537
name: hello_world
3638
version: 0.0.1
3739
dependencies:
3840
angular2: 2.0.0-alpha.25
3941
browser: any
42+
transformers:
43+
- angular2:
44+
entry_points: web/main.dart
4045
p.
4146
In the same directory, run <code>pub get</code>
4247
to install the angular2 and browser packages
@@ -45,11 +50,11 @@ p.
4550
code-example(language="sh").
4651
&gt; <span class="blk">pub get</span>
4752

48-
// PENDING: Create template? Link to pub/pubspec docs?
49-
// Is browser really needed?
53+
//- PENDING: browser: any -> ???
54+
//- PENDING: Create template? Link to pub/pubspec docs?
5055
5156
52-
// STEP 2 - Import Angular ##########################
57+
//- STEP 2 - Import Angular ##########################
5358
.l-main-section
5459
h2#section-transpile 2. Import Angular
5560

@@ -70,7 +75,7 @@ p.
7075
import 'package:angular2/src/reflection/reflection.dart' show reflector;
7176
import 'package:angular2/src/reflection/reflection_capabilities.dart' show ReflectionCapabilities;
7277

73-
// STEP 3 - Define a component ##########################
78+
//- STEP 3 - Define a component ##########################
7479
.l-main-section
7580

7681
h2#section-angular-create-account 3. Define a component
@@ -143,7 +148,7 @@ p.
143148
String name = 'Alice';
144149
}
145150

146-
// STEP 4 - Bootstrap ##########################
151+
//- STEP 4 - Bootstrap ##########################
147152
.l-main-section
148153
h2#section-transpile 4. Bootstrap
149154

@@ -162,10 +167,19 @@ p.
162167
The argument to <code>bootstrap()</code> is the name of the component class
163168
you defined above.
164169

165-
//- Explain why setting reflector.reflectionCapabilities is necessary.
166-
167-
168-
// STEP 5 - Declare the HTML ##########################
170+
p.
171+
Setting the value of <code>reflector.reflectionCapabilities</code>
172+
lets your app use the Dart VM's reflection (dart:mirrors)
173+
when running in Dartium.
174+
Reflection is fast in native Dart,
175+
so using it makes sense during development.
176+
Later, when you build a JavaScript version of your app,
177+
the Angular transformer will
178+
convert the reflection-using code to static code,
179+
so your generated JavaScript can be smaller and faster.
180+
181+
182+
//- STEP 5 - Declare the HTML ##########################
169183
.l-main-section
170184

171185
h2#section-angular-create-account 5. Declare the HTML
@@ -175,7 +189,7 @@ p.
175189
the following code,
176190
which loads <code>main.dart</code> and instantiates the my-app component:
177191

178-
code-example(language="html").
192+
code-example(language="html" format="linenums").
179193
&lt;!doctype html>
180194
&lt;html>
181195
&lt;head&gt;
@@ -189,10 +203,10 @@ p.
189203
&lt;/body>
190204
&lt;/html>
191205

192-
// STEP 6 - Build and run ##########################
206+
//- STEP 6 - Run ##########################
193207
.l-main-section
194208

195-
h2#section-angular-run-app 6. Build and run your app
209+
h2#section-angular-run-app 6. Run your app
196210

197211
p.
198212
You have a few options for running your app.
@@ -212,36 +226,15 @@ p.
212226
you should see <b>Hello Alice</b> in your browser window.
213227

214228

215-
// STEP 7 - Use the Angular transformer ##########################
229+
//- STEP 7 - Generate JavaScript ##########################
216230
.l-main-section
217231

218-
h2#section-angular-run-app 7. Use the Angular transformer
219-
220-
p.
221-
To enable quick turnaround while you're developing an Angular app,
222-
the framework uses reflection via dart:mirrors.
223-
Unfortunately, mirror-using Dart code compiles to
224-
JavaScript code that's large and slow.
225-
To create more deployable JavaScript, use the Angular transformer.
226-
The transformer analyzes your code,
227-
converting reflection to static code
228-
that Dart's build tools can compile to faster, smaller JavaScript.
229-
230-
p.
231-
To use the Angular transformer,
232-
first add the highlighted lines to your <code>pubspec.yaml</code>:
232+
h2#section-angular-run-app 7. Generate JavaScript
233233

234-
code-example(language="yaml").
235-
name: hello_world
236-
version: 0.0.1
237-
dependencies:
238-
angular2: 2.0.0-alpha.25
239-
browser: any
240-
<span class="pnk">transformers:
241-
- angular2:
242-
entry_points: web/main.dart</span>
243234
p.
244-
Then build the JavaScript version using <code>pub build</code>:
235+
Before you can deploy your app, you need to generate JavaScript files.
236+
Compiling your Dart code to JavaScript is easy:
237+
just run <code>pub build</code>.
245238

246239
code-example(language="basic").
247240
&gt; <span class="blk">pub build</span>
@@ -254,17 +247,39 @@ p.
254247
[Info from Dart2JS]:
255248
Took 0:00:16.123086 to compile hello_world|web/main.dart.
256249
Built 41 files to "build".
250+
//- REGENERATE THIS OUTPUT - or delete it? - when updating from 2.0.0-alpha.25
257251
258252
p.
259-
The compiled JavaScript appears, along with supporting files,
253+
The generated JavaScript appears, along with supporting files,
260254
under the <code>build</code> directory.
261255

262256
p.
257+
When you generate JavaScript for an Angular app,
258+
be sure you use the Angular transformer.
259+
It analyzes your code,
260+
converting reflection-using code to static code
261+
that Dart's build tools can compile to faster, smaller JavaScript.
262+
The highlighted lines in <code>pubspec.yaml</code>
263+
configure the Angular transformer:
264+
265+
code-example(language="yaml" format="linenums").
266+
name: hello_world
267+
version: 0.0.1
268+
dependencies:
269+
angular2: 2.0.0-alpha.25
270+
browser: any
271+
<span class="pnk">transformers:
272+
- angular2:
273+
entry_points: web/main.dart</span>
274+
p.
275+
The <code>entry_points</code> entry
276+
identifies the Dart file in your app
277+
that has a <code>main()</code> function.
263278
For more information, see the
264279
<a href="https://github.com/angular/angular/wiki/Angular-2-Dart-Transformer">Angular
265280
transformer wiki page</a>.
266281

267-
// WHAT'S NEXT... ##########################
282+
//- WHAT'S NEXT... ##########################
268283
.l-main-section
269284
h2#section-transpile Great job! Next step...
270285

0 commit comments

Comments
 (0)