Source types
ThesourceType configuration field tells MorJS which DSL your source files use:
| Value | DSL | Template extension | Global object |
|---|---|---|---|
wechat | WeChat mini-program DSL | .wxml | wx |
alipay | Alipay mini-program DSL | .axml | my |
sourceType. All other targets are compilation outputs, not source types.
Automatic detection
By default you do not need to setsourceType. MorJS inspects the file extensions in your source directory:
- If it finds
.wxmlfiles, it treats the source as WeChat DSL (wechat). - If it finds
.axmlfiles, it treats the source as Alipay DSL (alipay).
wechat:
When to set sourceType explicitly
SetsourceType manually when:
- Both
.wxmland.axmlfiles exist in the same directory (MorJS cannot infer unambiguously). - You want to make the source type explicit in CI or configuration-as-code.
DSL differences
- WeChat DSL
- Alipay DSL
WeChat-flavored mini-program source uses
wx-prefixed attributes and the wx global object:wx:if becomes a:if, wx:for becomes a:for, and so on.
Inline script: wxs and sjs
Both DSLs support small inline or imported script modules:| Feature | Alipay | |
|---|---|---|
| Tag name | <wxs> | <import-sjs> |
| Source attribute | src | from |
| Module attribute | module | name |
| Inline content | Supported | Not supported |
| File extension | .wxs | .sjs |
Supported file types
Beyond the native mini-program file types, MorJS adds support for the following extensions:Scripts
Scripts
| Extension | Description |
|---|---|
.js | Standard JavaScript (all targets) |
.ts | TypeScript |
.mjs | ES module JavaScript |
.mts | ES module TypeScript |
Styles
Styles
| Extension | Description |
|---|---|
.wxss | WeChat stylesheet |
.acss | Alipay stylesheet |
.css | Standard CSS (Baidu and others) |
.less | Less preprocessor |
.scss / .sass | Sass preprocessor |
Config files
Config files
| Extension | Description |
|---|---|
.json | Standard JSON |
.jsonc | JSON with comments |
.json5 | JSON5 (relaxed JSON syntax) |
Templates
Templates
| Extension | Description |
|---|---|
.wxml | WeChat template |
.axml | Alipay template |
.swan | Baidu template |
.ttml | ByteDance template |
.qml | QQ template |