| OLD | NEW |
| 1 # Usage | 1 # Usage |
| 2 | 2 |
| 3 The [Dart Dev Compiler](README.md) (DDC) is an **experimental** | 3 The [Dart Dev Compiler](README.md) (DDC) is an **experimental** development |
| 4 development compiler from Dart to EcmaScript 6. It is | 4 compiler from Dart to EcmaScript 6. It is still incomplete, under heavy |
| 5 still incomplete, under heavy development, and not yet ready for | 5 development, and not yet ready for production use. |
| 6 production use. | |
| 7 | 6 |
| 8 With those caveats, we welcome feedback for those experimenting. | 7 With those caveats, we welcome feedback for those experimenting. |
| 9 | 8 |
| 10 The easiest way to compile and run DDC generated code for now is via NodeJS. Th
e following instructions are in a state of flux - please expect them to change.
If you find issues, please let us know. | 9 The easiest way to compile and run DDC generated code for now is via NodeJS. |
| 10 The following instructions are in a state of flux -- please expect them to |
| 11 change. If you find issues, please let us know. |
| 11 | 12 |
| 12 (1) Clone the [DDC repository](https://github.com/dart-lang/dev_compiler) and se
t the environment variable DDC_PATH to your checkout. | 13 1. Clone the [DDC repository](https://github.com/dart-lang/sdk) and |
| 14 set the environment variable `DDC_PATH` to the `pkg/dev_compiler` |
| 15 subdirectory within wherever you check that out. |
| 13 | 16 |
| 14 (2) Install nodejs v6.0 or later and add it to your path. It can be installed f
rom: | 17 2. Install nodejs v6.0 or later and add it to your path. It can be installed |
| 18 from: |
| 15 | 19 |
| 16 https://nodejs.org/ | 20 https://nodejs.org/ |
| 17 | 21 |
| 18 Note, v6 or later is required for harmony / ES6 support. | 22 Note, v6 or later is required for harmony / ES6 support. |
| 19 | 23 |
| 20 (3) Create a node compatible version of the dart_sdk: | 24 3. Define a node path (you can add other directories if you want to separate |
| 25 things out): |
| 21 | 26 |
| 22 ``` | 27 ```sh |
| 23 dart $DDC_PATH/tool/build_sdk.dart --dart-sdk $DDC_PATH/gen/patched_sdk/ --modul
es node -o dart_sdk.js | 28 export NODE_PATH=$DDC_PATH/lib/js/common:. |
| 24 ``` | 29 ``` |
| 25 | 30 |
| 26 You can ignore any errors or warnings for now. | 31 4. Compile a test file with a `main` entry point: |
| 27 | 32 |
| 28 (4) Define a node path (you can add other directories if you want to separate th
ings out): | 33 ```sh |
| 34 dart $DDC_PATH/bin/dartdevc.dart --modules node -o hello.js hello.dart |
| 35 ``` |
| 29 | 36 |
| 30 ``` | 37 Note, the `hello.js` built here is not fully linked. It loads the SDK via a
`require` call. |
| 31 export NODE_PATH=. | |
| 32 ``` | |
| 33 | 38 |
| 34 (5) Compile a test file with a `main` entry point: | 39 5. Run it via your node built in step 1: |
| 35 | 40 |
| 36 ``` | 41 ```sh |
| 37 dart $DDC_PATH/bin/dartdevc.dart --modules node -o hello.js hello.dart | 42 node -e 'require("hello").hello.main()' |
| 38 ``` | 43 ``` |
| 39 | 44 |
| 40 Note, the `hello.js` built here is not fully linked. It loads the SDK via a `re
quire` call. | 45 6. Compile multiple libraries using summaries. E.g., write a `world.dart` that |
| 46 imports `hello.dart` with it's own `main`. Step 5 above generated a summary |
| 47 (`hello.sum`) for `hello.dart`. Build world: |
| 41 | 48 |
| 42 (6) Run it via your node built in step 1: | 49 ```sh |
| 50 dart $DDC_PATH/bin/dartdevc.dart --modules node -s hello.sum -o world.js wor
ld.dart |
| 51 ``` |
| 43 | 52 |
| 44 ``` | 53 Run world just like hello above: |
| 45 node -e 'require("hello").hello.main()' | |
| 46 ``` | |
| 47 | 54 |
| 48 (7) Compile multiple libraries using summaries. E.g., write a `world.dart` that
imports `hello.dart` with it's own `main`. Step 5 above generated a summary (`
hello.sum`) for `hello.dart`. Build world: | 55 ```sh |
| 56 node -e 'require("world").world.main()' |
| 57 ``` |
| 49 | 58 |
| 50 ``` | 59 7. Node modules do not run directly on the browser or v8. You can use a tool |
| 51 dart $DDC_PATH/bin/dartdevc.dart --modules node -s hello.sum -o world.js world.d
art | 60 like `browserify` to build a linked javascript file that can: |
| 52 ``` | |
| 53 | 61 |
| 54 Run world just like hello above: | 62 Install: |
| 55 | 63 |
| 56 ``` | 64 ```sh |
| 57 node -e 'require("world").world.main()' | 65 sudo npm install -g browserify |
| 58 ``` | 66 ``` |
| 59 | 67 |
| 60 (8) Node modules do not run directly on the browser or v8. You can use a tool l
ike `browserify` to build a linked javascript file that can: | 68 and run, e.g.,: |
| 61 | 69 |
| 62 Install: | 70 ```sh |
| 63 ``` | 71 echo 'require("world").world.main()' | browserify -d - > world.dart.js |
| 64 sudo npm install -g browserify | 72 ``` |
| 65 ``` | |
| 66 | 73 |
| 67 and run, e.g.,: | 74 The produced `world.dart.js` fully links all dependencies (`dart_sdk`, |
| 68 ``` | 75 `hello`, and `world`) and executes `world.main`. It can be loaded via |
| 69 echo 'require("world").world.main()' | browserify -d - > world.dart.js | 76 script tag and run in Chrome (stable or later). |
| 70 ``` | |
| 71 | |
| 72 The produced `world.dart.js` fully links all dependencies (`dart_sdk`, `hello`,
and `world`) and executes `world.main`. It can be loaded via script tag and run
in Chrome (stable or later). | |
| 73 | 77 |
| 74 ## Feedback | 78 ## Feedback |
| 75 | 79 |
| 76 Please file issues in our [GitHub issue tracker](https://github.com/dart-lang/sd
k/issues). | 80 Please file issues in our [GitHub issue |
| 81 tracker](https://github.com/dart-lang/sdk/issues). |
| 77 | 82 |
| 78 You can also view or join our [mailing list](https://groups.google.com/a/dartlan
g.org/forum/#!forum/dev-compiler). | 83 You can also view or join our [mailing |
| 79 | 84 list](https://groups.google.com/a/dartlang.org/forum/#!forum/dev-compiler). |
| 80 | |
| 81 | |
| OLD | NEW |