Chromium Code Reviews| 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/dev_compiler) and |
|
vsm
2017/01/11 00:23:45
This should now point to the sdk:
https://github.
Bob Nystrom
2017/01/11 00:55:16
Done.
| |
| 14 set the environment variable DDC_PATH to your checkout. | |
| 13 | 15 |
| 14 (2) Install nodejs v6.0 or later and add it to your path. It can be installed f rom: | 16 2. Install nodejs v6.0 or later and add it to your path. It can be installed |
| 17 from: | |
| 15 | 18 |
| 16 https://nodejs.org/ | 19 https://nodejs.org/ |
| 17 | 20 |
| 18 Note, v6 or later is required for harmony / ES6 support. | 21 Note, v6 or later is required for harmony / ES6 support. |
| 19 | 22 |
| 20 (3) Create a node compatible version of the dart_sdk: | 23 3. Create a node compatible version of the dart_sdk: |
|
vsm
2017/01/11 00:23:45
I think you can skip step #3 altogether and replac
Bob Nystrom
2017/01/11 00:55:16
Done.
| |
| 21 | 24 |
| 22 ``` | 25 ```sh |
| 23 dart $DDC_PATH/tool/build_sdk.dart --dart-sdk $DDC_PATH/gen/patched_sdk/ --modul es node -o dart_sdk.js | 26 dart $DDC_PATH/tool/build_sdk.dart --dart-sdk $DDC_PATH/gen/patched_sdk/ \ |
| 24 ``` | 27 --dart-sdk-summary=build --modules node -o dart_sdk.js |
| 28 ``` | |
| 25 | 29 |
| 26 You can ignore any errors or warnings for now. | 30 You can ignore any errors or warnings for now. |
| 27 | 31 |
| 28 (4) Define a node path (you can add other directories if you want to separate th ings out): | 32 4. Define a node path (you can add other directories if you want to separate |
| 33 things out): | |
| 29 | 34 |
| 30 ``` | 35 ```sh |
| 31 export NODE_PATH=. | 36 export NODE_PATH=. |
| 32 ``` | 37 ``` |
| 33 | 38 |
| 34 (5) Compile a test file with a `main` entry point: | 39 5. Compile a test file with a `main` entry point: |
| 35 | 40 |
| 36 ``` | 41 ```sh |
| 37 dart $DDC_PATH/bin/dartdevc.dart --modules node -o hello.js hello.dart | 42 dart $DDC_PATH/bin/dartdevc.dart --modules node -o hello.js hello.dart |
| 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 Note, the `hello.js` built here is not fully linked. It loads the SDK via a `require` call. |
| 41 | 46 |
| 42 (6) Run it via your node built in step 1: | 47 6. Run it via your node built in step 1: |
| 43 | 48 |
| 44 ``` | 49 ```sh |
| 45 node -e 'require("hello").hello.main()' | 50 node -e 'require("hello").hello.main()' |
| 46 ``` | 51 ``` |
| 47 | 52 |
| 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: | 53 7. Compile multiple libraries using summaries. E.g., write a `world.dart` that |
| 54 imports `hello.dart` with it's own `main`. Step 5 above generated a summary | |
| 55 (`hello.sum`) for `hello.dart`. Build world: | |
| 49 | 56 |
| 50 ``` | 57 ```sh |
| 51 dart $DDC_PATH/bin/dartdevc.dart --modules node -s hello.sum -o world.js world.d art | 58 dart $DDC_PATH/bin/dartdevc.dart --modules node -s hello.sum -o world.js wor ld.dart |
| 52 ``` | 59 ``` |
| 53 | 60 |
| 54 Run world just like hello above: | 61 Run world just like hello above: |
| 55 | 62 |
| 56 ``` | 63 ```sh |
| 57 node -e 'require("world").world.main()' | 64 node -e 'require("world").world.main()' |
| 58 ``` | 65 ``` |
| 59 | 66 |
| 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: | 67 8. Node modules do not run directly on the browser or v8. You can use a tool |
| 68 like `browserify` to build a linked javascript file that can: | |
| 61 | 69 |
| 62 Install: | 70 Install: |
| 63 ``` | |
| 64 sudo npm install -g browserify | |
| 65 ``` | |
| 66 | 71 |
| 67 and run, e.g.,: | 72 ```sh |
| 68 ``` | 73 sudo npm install -g browserify |
| 69 echo 'require("world").world.main()' | browserify -d - > world.dart.js | 74 ``` |
| 70 ``` | |
| 71 | 75 |
| 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). | 76 and run, e.g.,: |
| 77 | |
| 78 ```sh | |
| 79 echo 'require("world").world.main()' | browserify -d - > world.dart.js | |
| 80 ``` | |
| 81 | |
| 82 The produced `world.dart.js` fully links all dependencies (`dart_sdk`, | |
| 83 `hello`, and `world`) and executes `world.main`. It can be loaded via | |
| 84 script tag and run in Chrome (stable or later). | |
| 73 | 85 |
| 74 ## Feedback | 86 ## Feedback |
|
vsm
2017/01/11 00:23:45
Now that we're built as part of the SDK, someone w
Bob Nystrom
2017/01/11 00:55:16
...yes, but I wasn't planning to rewrite this whol
| |
| 75 | 87 |
| 76 Please file issues in our [GitHub issue tracker](https://github.com/dart-lang/sd k/issues). | 88 Please file issues in our [GitHub issue |
| 89 tracker](https://github.com/dart-lang/sdk/issues). | |
| 77 | 90 |
| 78 You can also view or join our [mailing list](https://groups.google.com/a/dartlan g.org/forum/#!forum/dev-compiler). | 91 You can also view or join our [mailing |
| 79 | 92 list](https://groups.google.com/a/dartlang.org/forum/#!forum/dev-compiler). |
| 80 | |
| 81 | |
| OLD | NEW |