compose command assembles a mini-program from multiple independently developed modules — a host app, main packages, subpackages, and plugins — into a single output directory.
How compose works
Compose runs through up to eight sequential stages for each module:- Initial — Load module metadata and compare hashes.
- Download — Fetch the module from git, npm, tar, file, or symlink.
- Before scripts — Run pre-processing shell commands.
- Config loaded — Read
subpackage.json,plugin.json, orapp.json. - Copied or compiled — Copy the module output into the host directory.
- After scripts — Run post-processing shell commands.
- Composed — Merge module routing into the host
app.json. - Retry — Automatically retry stages 2–6 on failure.
git, npm, tar, dist, or mode settings change.
Flags
The platform target (for example,
wechat, alipay). Used when modules need to be compiled before integration.The directory where the composed output is written. Defaults to the target’s default output path.
The compile type of the host. Accepted values:
miniprogram, plugin, subpackage, component.Include only matching modules in the integration. Accepts glob patterns. Pass the flag multiple times to include several patterns.
Exclude matching modules from the integration. Accepts glob patterns.
Force modules that have passed this state to restart from it. Useful for recovering from a partial integration.State values:
0 initial, 1 downloaded, 2 before-scripts executed, 3 config loaded, 4 copied/compiled, 5 after-scripts executed, 6 composed.Stop integration at this state. Useful for running only the download phase or only the copy phase.
Maximum number of modules to download and process in parallel. Defaults to the system queue concurrency.
Flatten all subpackage pages into the host
app.json pages array instead of keeping them in subPackages. Useful for platforms that do not support subpackages.Configuration in mor.config.ts
Compose is configured under the samemor.config.ts config object as the compiler. Set compose: true to enable it.
mor.config.ts
Module downloader options
Each module entry must include exactly one downloader configuration:git — Clone from a git repository
git — Clone from a git repository
npm — Download from an npm registry
npm — Download from an npm registry
file — Use a local path
file — Use a local path
link — Create a symlink to a local path
link — Create a symlink to a local path
tar — Download from a tarball URL
tar — Download from a tarball URL
Module type
Determines how the module’s pages are merged into the host
app.json.subpackage— Pages are added tosubPackages.main— Pages are added directly to the top-levelpagesarray.plugin— Plugin configuration is pulled and routing support is added.
Module integration mode
compose— The module’s compiled output is copied directly into the host output directory.compile— The module is compiled by MorJS as part of the current build, then composed.
Module scripts
Shell commands to run at different stages of the integration lifecycle.The following environment variables are injected automatically into each script:
| Variable | Description |
|---|---|
MOR_COMPOSER_MODULE_CWD | Absolute path of the project working directory |
MOR_COMPOSER_MODULE_TYPE | Module type (host, main, subpackage, plugin) |
MOR_COMPOSER_MODULE_HASH | Module hash |
MOR_COMPOSER_MODULE_ROOT | Module root directory (relative to cwd) |
MOR_COMPOSER_MODULE_SOURCE | Module source directory (relative to cwd) |
MOR_COMPOSER_MODULE_OUTPUT_FROM | Compiled output source path |
MOR_COMPOSER_MODULE_OUTPUT_TO | Composed output destination path |
Combine modules
When
true, all subpackage pages are merged into the host’s top-level pages array, removing the subPackages section from app.json. Use this for platforms that do not support the subpackage model.Usage examples
Configuration reference →
Full mor.config.ts documentation including all compose configuration fields.