Skip to main content
MorJS does not define its own template language. You write mini-programs using the native DSL of either WeChat or Alipay, and MorJS converts that DSL to the syntax required by the output target.

Source types

The sourceType configuration field tells MorJS which DSL your source files use:
ValueDSLTemplate extensionGlobal object
wechatWeChat mini-program DSL.wxmlwx
alipayAlipay mini-program DSL.axmlmy
These are the only two valid values for sourceType. All other targets are compilation outputs, not source types.

Automatic detection

By default you do not need to set sourceType. MorJS inspects the file extensions in your source directory:
  • If it finds .wxml files, it treats the source as WeChat DSL (wechat).
  • If it finds .axml files, it treats the source as Alipay DSL (alipay).
The default value in the schema is wechat:
// From packages/plugin-compiler/src/constants.ts
sourceType: z.nativeEnum(SourceTypes).default(SourceTypes.wechat)

When to set sourceType explicitly

Set sourceType manually when:
  • Both .wxml and .axml files exist in the same directory (MorJS cannot infer unambiguously).
  • You want to make the source type explicit in CI or configuration-as-code.
export default defineConfig([
  {
    target: 'alipay',
    sourceType: 'wechat',  // WeChat source compiled to Alipay
  }
])
You can also pass it on the command line:
mor compile --target alipay --source-type wechat

DSL differences

WeChat-flavored mini-program source uses wx-prefixed attributes and the wx global object:
<!-- pages/index/index.wxml -->
<view wx:if="{{show}}">
  <text>Hello World</text>
</view>
<block wx:for="{{list}}" wx:key="id">
  <view>{{item.name}}</view>
</block>
// pages/index/index.js
Page({
  data: { show: true, list: [] },
  onLoad() {
    wx.showToast({ title: 'Loaded' })
  }
})
MorJS rewrites template directives at compile time. When compiling WeChat source to Alipay, 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:
FeatureWeChatAlipay
Tag name<wxs><import-sjs>
Source attributesrcfrom
Module attributemodulename
Inline contentSupportedNot supported
File extension.wxs.sjs

Supported file types

Beyond the native mini-program file types, MorJS adds support for the following extensions:
ExtensionDescription
.jsStandard JavaScript (all targets)
.tsTypeScript
.mjsES module JavaScript
.mtsES module TypeScript
ExtensionDescription
.wxssWeChat stylesheet
.acssAlipay stylesheet
.cssStandard CSS (Baidu and others)
.lessLess preprocessor
.scss / .sassSass preprocessor
ExtensionDescription
.jsonStandard JSON
.jsoncJSON with comments
.json5JSON5 (relaxed JSON syntax)
ExtensionDescription
.wxmlWeChat template
.axmlAlipay template
.swanBaidu template
.ttmlByteDance template
.qmlQQ template
Using TypeScript (.ts) is recommended. MorJS has first-class TypeScript support with configurable compilerOptions.module and compilerOptions.target per platform.

Build docs developers (and LLMs) love