Overview
@morjs/plugin-composer implements the compose command. It orchestrates the download, build, and assembly of multiple mini-program modules (sub-apps, sub-packages, and plugins) into one host application directory.
| Property | Value |
|---|---|
| Package | @morjs/plugin-composer |
| Version | 1.0.72 |
| Command | mor compose |
Installation
Usage
MorComposerPlugin
The default export. Implements the Takin Plugin interface.
- The
composeCLI command. - A
--composeflag to the existingcompilecommand (viaAddComposeToCompilerPlugin). --with-modules/--without-modules,--from-state/--to-state, and--concurrencyoptions to both commands.- Automatic loading of module
scriptsanddistpaths from each module’spackage.json. - Automatic copying of host project config files to the compose output directory.
What composition does
Composition merges multiple independently-developed mini-program modules into a single host application. Each module can be sourced from:- A local directory (
mode: 'local') - A Git repository (
git: { url, branch }) - An npm package (
npm: { name, version }) - A tarball URL (
tar: { url }) - A pre-built
distdirectory
CLI options
| Option | Description |
|---|---|
-t, --target <target> | Compile target platform (e.g. wechat, alipay) |
-o, --output-path <dir> | Output directory |
--compile-type <compileType> | Compile form: miniprogram, subpackage, or plugin |
--with-modules <modules> | Comma-separated list of modules to include |
--without-modules <modules> | Comma-separated list of modules to exclude |
--from-state <state> | Start composing from this ComposeModuleState |
--to-state <state> | Stop composing at this ComposeModuleState |
--concurrency <n> | Max number of modules to process in parallel |
ComposerUserConfig
The user-facing configuration type for the compose command.
DSL source type of the host project.
Target platform for the compose output.
Directory where the composed application is written.
Whether the host is a
miniprogram, subpackage, or plugin.Array of module definitions to integrate. Each entry describes a module’s source (git, npm, tar, dist, or local), build scripts, and placement in the output app.
When
true, all modules are combined into a single output directory rather than each occupying a sub-package.Exported utilities
generateComposeModuleHash
Generates a deterministic MD5 hash from a module’s source configuration. Used to detect whether a module needs to be re-downloaded.
The module configuration object. Only the
git, npm, tar, dist, and mode fields contribute to the hash.Module name used in debug log output.
32-character lowercase hexadecimal MD5 hash.