Supported targets
Thetarget field in your MorJS configuration selects the output platform. The following targets ship with MorJS out of the box:
| Target | Platform | Global object | Default output dir |
|---|---|---|---|
alipay | Alipay mini-program (支付宝小程序) | my | dist/alipay |
wechat | WeChat mini-program (微信小程序) | wx | dist/wechat |
baidu | Baidu smart mini-program (百度小程序) | swan | dist/baidu |
bytedance | ByteDance mini-program — Douyin (字节小程序) | tt | dist/bytedance |
qq | QQ mini-program (QQ 小程序) | qq | dist/qq |
taobao | Taobao mini-program (淘宝小程序) | — | dist/taobao |
dingding | DingTalk mini-program (钉钉小程序) | — | dist/dingding |
kuaishou | Kuaishou mini-program (快手小程序) | — | dist/kuaishou |
web | Web application (H5) | my | dist/web |
web-pro and weex-pro are available as extended targets for advanced use cases.
One source, many outputs
A typical MorJS workflow compiles the same source directory to multiple targets by running the compiler once per target:src/ (or the configured srcPath) and writes to the target’s default output directory.
To set the target in configuration instead of on the command line, use mor.config.ts:
Compile-time vs runtime platform handling
MorJS handles platform differences in two complementary layers:Compile-time
The compiler rewrites template directives, file extensions, and global object references during the build. For example,
wx:if becomes a:if when targeting Alipay. No runtime cost.Runtime
The runtime layer normalizes API behavior and component lifecycle differences at run time. This covers cases that cannot be handled statically, such as API response shape differences.
autoInjectRuntime configuration controls which runtime adapters are injected at compile time. See Runtime for details.
Conditional compilation by target
You can write target-specific code inline using conditional compile context variables, or use file-extension-based conditional compilation. Each target defines adefaultConditionalFileExt:
| Target | File extension suffix |
|---|---|
alipay | .my |
wechat | .wx |
baidu | .bd |
web | .web |
button.my.ts is only included in Alipay builds; button.wx.ts is only included in WeChat builds. A plain button.ts is the fallback used for all other targets.
Setting
outputPath explicitly in your config overrides the default output directory for that target configuration entry.