@@ -13,30 +13,31 @@ block setup-tooling
1313 :marked
1414 Install the **[Dart SDK](https://www.dartlang.org/downloads/)**,
1515 if not already on your machine, and any tools you like to use with Dart.
16- The Dart SDK includes **[pub][pub]**, the Dart package manager, that we
17- will be using shortly.
16+ The Dart SDK includes tools such as **[pub][pub]**, the Dart package manager.
1817 If you don't have a favorite Dart editor already, try
1918 [WebStorm][WS], which comes with a Dart plugin.
2019 You can also download [Dart plugins for other IDEs and editors][DT].
2120
2221 [WS]: https://confluence.jetbrains.com/display/WI/Getting+started+with+Dart
2322 [DT]: https://www.dartlang.org/tools
2423 [pub]: https://www.dartlang.org/tools/pub
25-
24+
2625block download-source
2726 // exclude this section from Dart
2827
2928block package-and-config-files
3029 :marked
31- In the project folder just created, put a file named
32- **[pubspec.yaml][pubspec]** in it.
33- As shown below, in `pubspec.yaml`, specify the angular2 and browser
34- packages as dependencies, as well as the angular2 transformer.
30+ In the project folder just created, create a file named
31+ **[pubspec.yaml][pubspec]** with the code below.
32+ This pubspec must specify the **angular2** and **browser**
33+ packages as dependencies, as well as the `angular2` transformer.
34+ It can also specify other packages and transformers for the app to use,
35+ such as [dart_to_js_script_rewriter](https://pub.dartlang.org/packages/dart_to_js_script_rewriter).
3536 Angular 2 is still changing, so provide an exact version: **2.0.0-beta.17**.
3637
3738 [pubspec]: https://www.dartlang.org/tools/pub/pubspec.html
3839
39- + makeExample('quickstart/dart/pubspec.yaml' , 'no-rewriter' , 'pubspec.yaml' )
40+ + makeExample('quickstart/dart/pubspec.yaml' , null , 'pubspec.yaml' )
4041
4142block install-packages
4243 :marked
@@ -57,69 +58,58 @@ block create-main
5758 Now we need something to tell Angular to load the root component.
5859 Create:
5960 ul
60- li a #[ b folder named #[ code web] ] , and inside it
61- li the file #[ code #[ + adjExPath('app/main.ts' )] ] with the following content:
61+ li a #[ b folder named #[ code web] ]
62+ li a < b > file named #[code #[+adjExPath('app/main.ts')]]</ b > with the following content:
6263
6364block index-html-commentary-for-ts
6465 //- N/A
6566
6667block run-app
6768 p.
68- You have a few options for running your app.
69+ We have a few options for running our app.
6970 One is to launch a local HTTP server
7071 and then view the app in
7172 <a href =" https://www.dartlang.org/tools/dartium/" >Dartium</a >.
72- You can use whatever server you like , such as WebStorm's server
73+ We can use any web server , such as WebStorm's server
7374 or Python's SimpleHTTPServer.
7475 p.
7576 Another option is to build and serve the app using <code >pub serve</code >,
7677 and then run it by visiting <b ><code >http://localhost:8080</code ></b > in any modern browser.
7778 Pub serve generates JavaScript on the fly,
78- which can take a while when you first visit the page.
79- Pub serve also runs in <b ><i >watch mode</i ></b >, and will re-compile and subsequently serve
80- and changed assets.
79+ which can take a while when first visiting the page.
80+ Pub serve also runs in <b ><i >watch mode</i ></b >, and will recompile and subsequently serve
81+ any changed assets.
8182 p.
82- Once the app is running, you should see the following in your browser
83- window:
83+ Once the app is running, the browser window should show the following:
8484
8585block build-app
8686 .alert.is-important
8787 :marked
88- If you don't see that , make sure you've entered all the code correctly,
88+ If you don't see **My First Angular 2 App** , make sure you've entered all the code correctly,
8989 in the [proper folders](#wrap-up),
9090 and run `pub get`.
9191
9292 .l-verbose-section
9393 h3#section-angular-run-app Building the app (generating JavaScript)
9494
9595 :marked
96- Before you can deploy your app, you need to generate JavaScript files.
96+ Before deploying the app, we need to generate JavaScript files.
9797 The `pub build` command makes that easy.
98- To improve your app's performance, convert the
99- HTML file to directly include the generated JavaScript;
100- one way to do that is with `dart_to_js_script_rewriter`.
101-
102- Add the `dart_to_js_script_rewriter` package to your pubspec,
103- in both the `dependencies` and `transformers` sections.
104-
105- - var stylePattern = { pnk: / (dart_to_js_script_rewriter. * $ )| (- dart_to_js_script_rewriter. * $ )/ gm , otl: / (dependencies:)| (transformers:)/ g };
106- + makeExample('quickstart/dart/pubspec.yaml' , null , 'pubspec.yaml' , stylePattern)
107-
108- p.
109- Then compile your Dart code to JavaScript,
110- using <code >pub build</code >.
11198
11299 code-example( language ="sh" ) .
113100 > <span class =" blk" >pub build</span >
114101 Loading source assets...
115102
116103 p.
117104 The generated JavaScript appears, along with supporting files,
118- under the <code >build</code > directory.
105+ under a directory named <code >build</code >.
106+
107+ h4#angular_transformer Using the Angular transformer
108+
119109 p.
120- When you generate JavaScript for an Angular app,
110+ When generating JavaScript for an Angular app,
121111 be sure to use the Angular transformer.
122- It analyzes your code,
112+ It analyzes the Dart code,
123113 converting reflection-using code to static code
124114 that Dart's build tools can compile to faster, smaller JavaScript.
125115 The highlighted lines in <code >pubspec.yaml</code >
@@ -130,7 +120,7 @@ block build-app
130120
131121 p.
132122 The <code >entry_points</code > item
133- identifies the Dart file in your app
123+ identifies the Dart file in our app
134124 that has a <code >main()</code > function.
135125 For more information, see the
136126 <a href =" https://github.com/angular/angular/wiki/Angular-2-Dart-Transformer" >Angular
@@ -139,39 +129,69 @@ block build-app
139129 #performance .l-sub-section
140130 h3 Performance, the transformer, and Angular 2 libraries
141131 p.
142- When you import <code >bootstrap.dart</code >,
143- you also get <code >dart:mirrors</code >,
132+ When an app imports <code >bootstrap.dart</code >,
133+ it also gets <code >dart:mirrors</code >,
144134 a reflection library that
145135 causes performance problems when compiled to JavaScript.
146136 Don't worry,
147- the Angular transformer converts your entry points
137+ the Angular transformer converts the app's entry points
148138 (<code >entry_points</code > in <code >pubspec.yaml</code >)
149139 so that they don't use mirrors.
150140
151- block server-watching
141+ h4#dart_to_js_script_rewriter Using dart_to_js_script_rewriter
142+
143+ :marked
144+ To improve the app's performance, convert the
145+ HTML file to directly include the generated JavaScript;
146+ one way to do that is with `dart_to_js_script_rewriter`.
147+ To use the rewriter, specify `dart_to_js_script_rewriter` in both
148+ the `dependencies` and `transformers` sections of the pubspec.
149+
150+ - var stylePattern = { otl: / (dart_to_js_script_rewriter. * $ )| (- dart_to_js_script_rewriter. * $ )| (dependencies:)| (transformers:)/ gm };
151+ + makeExample('quickstart/dart/pubspec.yaml' , null , 'pubspec.yaml' , stylePattern)
152+
153+ .alert.is-important
154+ :marked
155+ The `dart_to_js_script_rewriter` transformer must be
156+ **after** the `angular2` transformer in `pubspec.yaml`.
157+
158+ :marked
159+ For more information, see the docs for
160+ [dart_to_js_script_rewriter](https://pub.dartlang.org/packages/dart_to_js_script_rewriter).
161+
162+ block server-watching
152163 :marked
153- Pub serve is watching and
154- should detect the change, recompile the Dart into JavaScript,
155- refresh the browser, and display the revised message.
156- It's a nifty way to develop an application!
164+ To see the new version, just reload the page.
157165
158- Ensure that you terminate the `pub serve` process once you are done.
166+ .alert.is-important
167+ :marked
168+ Be sure to terminate the `pub serve` process once you stop working on this app.
159169
160170block project-file-structure
161171 .filetree
162172 .file angular2-quickstart
163173 .children
164- .file build ...
165174 .file lib
166175 .children
167176 .file app_component.dart
168177 .file pubspec.yaml
169178 .file web
170179 .children
171180 .file index.html
172- .file main.ts
181+ .file main.dart
173182 .file styles.css
174183
184+ .l-verbose-section
185+ :marked
186+ This figure doesn't show generated files and directories.
187+ For example, a `pubspec.lock` file
188+ specifies versions and other identifying information for
189+ the packages that our app depends on.
190+ The `pub build` command creates a `build` directory
191+ containing the JavaScript version of our app.
192+ Pub, IDEs, and other tools often create
193+ other directories and dotfiles.
194+
175195block project-files
176196 + makeTabs(`
177197 quickstart/ts/app/app.component.ts,
@@ -180,10 +200,10 @@ block project-files
180200 quickstart/dart/pubspec.yaml,
181201 quickstart/ts/styles.1.css`
182202 ,null ,
183- ` app/app.component.ts,
184- app/main.ts,
203+ ` app/app.component.ts,
204+ app/main.ts,
185205 index.html,
186- pubspec.yaml,
206+ pubspec.yaml,
187207 styles.css` )
188208
189209block what-next-ts-overhead
0 commit comments