The Dart Dev Compiler (DDC) is a fast, modular compiler that generates modern JavaScript (ES6) for development. It’s optimized for quick incremental compilation and debugging, making it ideal for iterative web development.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dart-lang/sdk/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Dartdevc prioritizes developer experience over production optimization:- Fast incremental compilation - Rebuild only changed modules
- Readable output - ES6 JavaScript that resembles the original Dart
- Source maps - Precise mapping for debugging
- Modular architecture - Compile libraries independently
webdev serve or build_web_compilers instead of invoking dartdevc manually.
How It Works
Modular Compilation
Unlike dart2js which requires the entire application, DDC operates modularly:- Takes a set of Dart source files
- Receives summaries of dependencies
- Performs modular type checking
- Generates a single JavaScript module
Representation
DDC maps Dart concepts to ES6 naturally:- Classes
- Generics
- Libraries
- Private Members
Dart classes map to ES6 classes:
Using DDC
With webdev (Recommended)
The standard way to use DDC:With build_web_compilers
For custom build configurations:Direct Invocation (Advanced)
Not recommended for application development:Development Workflow
Fast Incremental Builds
DDC shines during development with minimal rebuild times:- Initial build - Compile all modules (~seconds)
- Change a file - Recompile only affected modules (~milliseconds)
- Hot reload - Browser updates without full page refresh
Debugging
DDC generates high-quality source maps:- Open DevTools (F12)
- Navigate to Sources tab
- Browse to
lib/to see Dart sources - Set breakpoints and inspect variables
Type Checking
DDC performs strict type checking during compilation:Performance Characteristics
Compilation Speed
- Initial Build
- Incremental Build
First compilation of entire app:
- Small app (< 1000 LOC): 1-3 seconds
- Medium app (< 10k LOC): 5-15 seconds
- Large app (> 10k LOC): 15-60 seconds
Runtime Performance
- Startup: Slower than dart2js (no tree-shaking)
- Execution: Comparable to hand-written JavaScript
- Bundle size: Larger than dart2js (includes unused code)
Module Systems
DDC supports multiple JavaScript module formats:AMD (Default)
ES6
CommonJS
Browser Support
DDC generates ES6, requiring modern browsers:- Chrome: Latest stable (recommended)
- Firefox: Latest stable
- Safari: Latest stable
- Edge: Chromium-based versions
Comparison with dart2js
| Feature | dartdevc | dart2js |
|---|---|---|
| Purpose | Development | Production |
| Compilation speed | Very fast | Slow |
| Incremental builds | Yes | No |
| Output size | Large | Small |
| Tree-shaking | No | Yes |
| Minification | No | Yes |
| Source maps | Excellent | Good |
| Readability | High | Low (minified) |
| Runtime performance | Good | Excellent |
| Browser support | Modern only | All browsers |
Limitations
Stability Warning
The DDC output format is not stable. Do not rely on:- Generated JavaScript structure
- Naming conventions
- Module boundaries
- Internal APIs
Not for Production
DDC is not recommended for production deployment:- No tree-shaking (includes all code)
- No minification (larger downloads)
- No advanced optimizations
- Modern browser requirement
Not for JavaScript Export
Do not use DDC to create JavaScript libraries:- Use
dart compile jswith explicit JS interop - Define stable APIs using
dart:js_interop
Configuration
Build Configuration
Analysis Options
Troubleshooting
Slow Incremental Builds
If rebuilds are slow:- Check for circular dependencies
- Split large libraries into smaller modules
- Use
--verboseto identify bottlenecks
Module Loading Errors
If modules fail to load:- Clear build cache:
webdev clean - Rebuild:
webdev build --no-release - Check browser console for errors