![Kevin Moore](/assets/img/avatar_default.png)
dartlang.org -> dart.dev Remove references to dev-compiler group that has been deleted Change-Id: I8d994b5f2dba19aab3c3b0fc16c5c340fbce80fd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167442 Auto-Submit: Kevin Moore <kevmoo@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com>
2.4 KiB
Usage
The Dart Dev Compiler (DDC) is an experimental development compiler from Dart to EcmaScript 6. It is still incomplete, under heavy development, and not yet ready for production use.
With those caveats, we welcome feedback for those experimenting.
The easiest way to compile and run DDC generated code for now is via NodeJS. The following instructions are in a state of flux -- please expect them to change. If you find issues, please let us know.
-
Follow the Getting the Source steps, and set the environment variable
DDC_PATH
to thepkg/dev_compiler
subdirectory within wherever you check that out. -
Install nodejs v6.0 or later and add it to your path. It can be installed from:
Note, v6 or later is required for harmony / ES6 support.
-
Define a node path (you can add other directories if you want to separate things out):
export NODE_PATH=$DDC_PATH/lib/js/common:.
-
Compile a test file with a
main
entry point:dart $DDC_PATH/bin/dartdevc.dart --modules node -o hello.js hello.dart
Note, the
hello.js
built here is not fully linked. It loads the SDK via arequire
call. -
Run it via your node built in step 1:
node -e 'require("hello").hello.main()'
-
Compile multiple libraries using summaries. E.g., write a
world.dart
that importshello.dart
with it's ownmain
. Step 5 above generated a summary (hello.sum
) forhello.dart
. Build world:dart $DDC_PATH/bin/dartdevc.dart --modules node -s hello.sum -o world.js world.dart
Run world just like hello above:
node -e 'require("world").world.main()'
-
Node modules do not run directly on the browser or v8. You can use a tool like
browserify
to build a linked javascript file that can:Install:
sudo npm install -g browserify
and run, e.g.,:
echo 'require("world").world.main()' | browserify -d - > world.dart.js
The produced
world.dart.js
fully links all dependencies (dart_sdk
,hello
, andworld
) and executesworld.main
. It can be loaded via script tag and run in Chrome (stable or later).
Feedback
Please file issues in our GitHub issue tracker.