dartdevc: The Dart Dev Compiler

Send feedback

The Dart development compiler (dartdevc, also known as DDC) lets you run and debug your Dart web app in Chrome. As of SDK release 1.24, pub build and pub serve support dartdevc.

Unlike dart2js, dartdevc supports incremental compilation and emits modular JavaScript. When you use pub serve with dartdevc, you can edit your Dart files, refresh in Chrome, and see your edits almost immediately. This speed is possible because pub compiles only updated modules, not all the packages that your app depends on.

The first compilation with dartdevc takes the longest, because the entire app must be compiled. After that, as long as pub serve keeps running, refresh times with dartdevc are much faster than with dart2js.

Preparing your code

To compile with dartdevc, your web app’s code—and all packages it depends on—must be type safe. For practical details on how to make your code type safe, see the list of common errors and warnings. More information is in the sound Dart guide.

For best performance, put implementation files under /lib/src, instead of anywhere else under /lib. Also, avoid imports of package:package_name/src/.... The pub package layout conventions have more information about how to structure your code.

The following repos have good examples of app code that works with dartdevc:

Building with dartdevc

To make pub use dartdevc, do one of the following:

  • Modify your pubspec. A new top-level key named web supports a single key named compiler that maps mode names (such as debug and release) to compilers (dartdevc, dart2js, or none).

    To make pub serve use dartdevc (assuming pub serve runs in its default mode, debug), put the following in your pubspec.yaml file:

        debug: dartdevc
  • Alternately, use the new --web-compiler flag to pub build or pub serve. Specify the dartdevc option:

    pub build --web-compiler=dartdevc

Testing with dartdevc

You can use dartdevc to run your tests in Chrome much more quickly than is possible with dart2js. To run a test in Chrome, use the following commands:

pub serve test --web-compiler=dartdevc
pub run test -p chrome --pub-serve=8080

More information