# Chameleon (CML) — Cross-Platform Development Framework by Didi > A write-once, run-anywhere framework by Didi that compiles a single codebase to Web, WeChat Mini-Program, Alipay Mini-Program, Baidu Smart App, and native platforms. ## Install Save in your project root: # Chameleon (CML) — Cross-Platform Development Framework by Didi ## Quick Use ```bash npm install -g chameleon-tool cml init project my-app cd my-app cml dev ``` ## Introduction Chameleon, abbreviated CML, is a cross-platform development framework created by Didi Chuxing. It enables developers to write application logic once using a unified MVVM syntax and compile it to multiple target platforms including Web, WeChat Mini-Program, Alipay Mini-Program, Baidu Smart App, and native apps via a polymorphic protocol. ## What Chameleon Does - Compiles a single codebase to Web, WeChat, Alipay, Baidu, and QQ mini-programs - Provides a unified component model with platform-specific polymorphic interfaces - Includes a cross-platform API library covering network, storage, navigation, and device features - Supports a polymorphic protocol allowing platform-specific code when needed - Offers a CLI tool for scaffolding, development, and multi-target builds ## Architecture Overview Chameleon uses a compile-time approach: source files written in CML syntax (a superset of Vue-like templates) are parsed and transformed into platform-specific output. The polymorphic protocol lets developers define interface contracts and provide platform-specific implementations, ensuring that unique platform capabilities remain accessible. The runtime layer normalizes lifecycle hooks, event handling, and data binding across targets. The build pipeline uses Webpack internally and outputs platform-native project structures. ## Self-Hosting & Configuration - Install the `chameleon-tool` CLI globally via npm - Initialize a project with `cml init project` and select target platforms - Configure target-specific settings in the project configuration file - Use `cml dev` for live development with hot reload on the selected platform - Build for production with `cml build` which outputs deployable artifacts for each target ## Key Features - True multi-platform compilation from a single codebase to 6+ target runtimes - Polymorphic protocol for clean separation of cross-platform and platform-specific code - Rich built-in component library with consistent behavior across platforms - Comprehensive API library (chameleon-api) for network, storage, location, and animation - Mature CLI toolchain with scaffolding, dev server, and production build support ## Comparison with Similar Tools - **Taro** — compiles React/Vue code to mini-programs and native apps; Chameleon uses its own CML syntax with a stronger emphasis on polymorphic platform abstraction - **uni-app** — Vue-based cross-platform framework with wide platform coverage; Chameleon provides a more explicit polymorphic interface system - **React Native** — targets iOS and Android with native rendering; Chameleon prioritizes web and mini-program targets over native mobile - **Flutter** — uses Dart and its own rendering engine for pixel-perfect cross-platform UI; Chameleon outputs platform-native code for each target ## FAQ **Q: What syntax does Chameleon use for templates?** A: CML uses a Vue-like template syntax with custom directives. Developers familiar with Vue will find the learning curve minimal. **Q: Can I use platform-specific features?** A: Yes. The polymorphic protocol lets you define an interface and provide separate implementations per platform, so you can access native APIs without polluting the shared codebase. **Q: Which mini-program platforms does Chameleon support?** A: WeChat, Alipay, Baidu, QQ, and Toutiao mini-programs are all supported as build targets. **Q: Is Chameleon suitable for new projects in 2025?** A: Chameleon is best suited for teams that need broad mini-program coverage. Evaluate it alongside Taro and uni-app based on your target platform mix and preferred component model. ## Sources - https://github.com/didi/chameleon - https://cml.js.org/ --- Source: https://tokrepo.com/en/workflows/asset-eeedaf3c Author: AI Open Source