Prerequisites
Before installing MorJS, ensure your environment meets these requirements:| Requirement | Version |
|---|---|
| Node.js | >= 12.13.0 |
| npm / pnpm / yarn | any recent version |
Step 1: Install the CLI
Install@morjs/cli globally so the mor command is available everywhere:
- npm
- pnpm
- yarn
Step 2: Create a new project
Use themor create command to scaffold a new project:
- Project name
- Source DSL (
wechatoralipay) - Target platforms
- Whether to include TypeScript
You can also integrate MorJS into an existing mini-program by installing
@morjs/cli and @morjs/core as dependencies and adding a mor.config.ts.Step 3: Explore the project structure
A scaffolded MorJS project looks like this:Template files use
.xml by default for DSL-agnostic source. MorJS maps .xml to the correct extension (.wxml, .axml, .ttml, etc.) for each target platform.Step 4: Configure mor.config.ts
Openmor.config.ts in your project root. A minimal configuration looks like this:
mor.config.ts
mor.config.ts
Step 5: Compile your project
Run a one-time compile for a specific target:--target to use the target(s) defined in mor.config.ts:
Watch mode
Pass--watch to recompile whenever source files change:
Compile a specific named config
When your config exports an array, use--name to select one entry:
Available compile targets
Step 6: Open in the platform DevTools
After compiling, open the output directory in the corresponding platform’s developer tool:| Target | DevTool |
|---|---|
wechat | WeChat DevTools — open dist/wechat |
alipay | Alipay Mini Program Studio — open dist/alipay |
web | A local web server — dist/web contains standard HTML/JS/CSS |
Verbose logging
For debugging, pass--verbose to print internal framework logs:
Quick links
Configuration reference
Full reference for all
mor.config.ts options.Compile options
All flags and options for
mor compile.Architecture
Understand Takin, Runner, and the plugin lifecycle.
Plugin development
Extend MorJS with your own plugin.