Hasty Briefsbeta

Bilingual

Dart added support for cross-compilation

a year ago
  • #Dart
  • #JavaScript
  • #Compilation
  • The `dart compile` command compiles Dart programs to various target platforms.
  • Subcommands include `exe`, `aot-snapshot`, `jit-snapshot`, `kernel`, `js`, and `wasm`.
  • The `exe` subcommand produces standalone executables for Windows, macOS, or Linux.
  • Cross-compilation is supported for Linux x64 and ARM64 on macOS, Windows, and Linux hosts.
  • AOT modules (`aot-snapshot`) reduce disk space and are architecture-specific.
  • JIT modules (`jit-snapshot`) include optimized code from training runs for faster performance.
  • Kernel modules (`kernel`) are portable across all OS and CPU architectures.
  • The `js` subcommand compiles Dart to JavaScript with optimization levels (`-O0` to `-O4`).
  • Options for `js` include output file specification, source maps, and environment variables.
  • Best practices for web compilation include avoiding `Function.apply()` and `noSuchMethod()`.