How Chameleon Enables One‑Code Multi‑Platform Development for H5, Mini‑Programs, and More

Chameleon is Didi's cross‑platform framework that lets developers write a single codebase in CML, CMSS, and JavaScript to run on H5, various mini‑programs, and native‑like environments, dramatically reducing duplication, maintenance effort, and improving consistency across platforms.

Didi Tech
Didi Tech
Didi Tech
How Chameleon Enables One‑Code Multi‑Platform Development for H5, Mini‑Programs, and More

Overview

Chameleon is Didi's cross‑platform solution that allows a single codebase to run on H5, native‑like performance, and multiple mini‑program ecosystems (WeChat, Alipay, Baidu, Android quick apps). It addresses the explosion of entry points that otherwise require duplicated implementations, cutting development and maintenance costs.

Design Philosophy

The framework follows the classic “split and merge” principle: decompose complex problems into isolated services and then merge common requirements into a unified front‑end middle‑platform. Chameleon provides a unified language framework and a polymorphic protocol to extract a consistent front‑end middle‑service across platforms.

Target Architecture

Based on the MVVM pattern, Chameleon aims for a unified MVVM experience across all target environments.

Development Language

Similar to web development, Chameleon uses CML (Chameleon Markup Language) for structure, CMSS (Chameleon Style Sheets) for styling, and JavaScript for logic. CML defines components with a Vue‑like syntax, supports template features such as conditional rendering, list rendering, and data binding. CMSS inherits most CSS capabilities and can preprocess with Less or Stylus.

Rich Components and APIs

Built‑in components include button, switch, radio, and checkbox; extended components such as c-picker, c-dialog, and c-loading are also provided. The npm package chameleon-api offers network requests, data storage, geolocation, system information, animation, and other utilities.

Customizable API and Component Extension

Thanks to the polymorphic protocol, developers can freely add new APIs or components without depending on framework updates, and existing native components can be imported directly into cross‑platform projects.

Smart Lint and Progressive Cross‑Platform Adoption

The IDE provides intelligent linting that highlights non‑compliant code and shows error locations in the command line. Projects can adopt Chameleon incrementally, reusing existing components without massive refactoring.

Maintainability and Consistency

The protocol isolates platform differences, ensuring a single codebase remains maintainable. Consistency spans framework lifecycle, built‑in components, event communication, routing, layout, component scope, and communication.

Tooling and Build

Chameleon leverages Webpack for bundling and supplies a CLI scaffolding tool that streamlines development, debugging, testing, and deployment across the full workflow.

Event Context

Chameleon was presented at the OSCAR Open‑Source Pioneer Day on April 11, 2019, where its architecture, features, and use cases were demonstrated.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

frontendcross-platformWeb DevelopmentMVVMChameleonCML
Didi Tech
Written by

Didi Tech

Official Didi technology account

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.