Chameleon – Didi’s Open‑Source Cross‑Platform MVVM Framework
Chameleon is Didi's open-source cross‑platform MVVM framework that lets developers write a single CML codebase and compile it to WeChat mini‑programs, Alipay, Android quick‑apps, Web, Weex and other MVVM‑based targets, improving maintainability, code reuse and performance while isolating platform‑specific differences at build time.
Background
China’s mobile ecosystem is dominated by mini‑programs: WeChat (1 billion MAU), Alipay (400 million), Baidu (330 million) and Android devices account for over 80% of the market. Developing separate code bases for each platform leads to massive duplication of effort.
Didi’s engineers, who maintain entrances on WeChat, Alipay and Android quick‑apps, experienced this pain firsthand.
Solution
Chameleon is an open‑source framework (https://github.com/didi/chameleon) that unifies development across all these targets using a single MVVM‑based code base. It abstracts the common MVVM pattern shared by Weex, React‑Native, Web, Flutter, etc., allowing the same business logic and UI description to run on multiple ends.
It provides a unified SDK (ChameleonSDK) that currently supports WeChat mini‑programs, Web and Weex, with more MVVM‑compliant platforms planned.
Principle
The core language is CML (Chameleon Markup Language), a Vue‑like DSL that combines components, data binding, and event handling. CML files are compiled into the appropriate native or web code for each target.
Experience and Lessons Learned
In 2017 Didi launched a small MPV project to prove the concept, achieving over 90% code reuse across projects. The pilot revealed issues such as maintainability, mixed platform‑specific code, inconsistent UI, high debugging cost, and lack of ecosystem component support.
Polymorphic Protocol
Inspired by Apache Thrift, Chameleon defines standard interfaces for each platform. Implementations are compiled and checked at build‑time, isolating shared code from platform‑specific differences and ensuring consistency.
Key goals:
Maintainability across multiple ends.
Compile‑time separation of platform code.
Usability
Chameleon emphasizes:
Consistency – identical UI across platforms.
Simplicity – clear separation of shared and platform‑specific code.
Performance – no increase in bundle size.
Speed – efficient development workflow.
Progressive Adoption
Teams can adopt Chameleon either for an entire project or incrementally for shared components. The framework supports both approaches with clear guidelines.
Industry Comparison
Unlike other frameworks that focus on a single mini‑program syntax or promote a specific ecosystem, Chameleon aims for true “write once, run everywhere” across any MVVM‑based target.
Future Plans
Continued expansion to more platforms, richer component libraries, and deeper integration with existing ecosystems.
Quick start documentation: https://cmljs.org/doc/quick/start.html
FAQ: https://cmljs.org/doc/framework/faq.html
Didi Tech
Official Didi technology account
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.