Skip to main content

Overview

@morjs/cli is the entry-point package for the MorJS toolchain. It bundles all first-party plugins and exposes them through two executable commands.
PropertyValue
Package@morjs/cli
Version1.0.113
LicenseMIT
Node>= 12.13.0

Installation

npm install --save-dev @morjs/cli
# or
npm install -g @morjs/cli

Binary commands

BinaryResolves to
mor./bin/cli.js
morjs./bin/cli.js
Both binaries are identical; morjs is provided as an alias for environments where mor may conflict with another tool.

Usage

# compile a mini-program
mor compile --target wechat

# compose (integrate) multiple mini-program modules
mor compose

# generate a new project from a template
mor generate

# run the development server
mor compile --target wechat --watch

Bundled dependencies

@morjs/cli ships with the following first-party packages as direct dependencies. You do not need to install them separately.

@morjs/plugin-compiler

1.0.113 — Webpack-based multi-target mini-program compiler.

@morjs/plugin-composer

1.0.72 — Multi-module mini-program composition engine.

@morjs/plugin-analyzer

1.0.71 — Bundle size analysis.

@morjs/plugin-generator

1.0.71 — Project and file scaffolding.

@morjs/plugin-mocker

1.0.71 — API mocking for development.

@morjs/utils

1.0.71 — Shared utilities used across all MorJS packages.
Third-party runtime dependencies included in the CLI bundle:
  • v8-compile-cache ^2.3.0 — Speeds up Node.js startup by caching compiled V8 bytecode.
  • youch ^3.2.2 — Pretty-prints Node.js error stacks.
  • youch-terminal ^2.1.5 — Terminal rendering for youch output.

Programmatic usage

Behind every mor command is a Takin instance. You can replicate CLI behaviour programmatically:
import takin from '@morjs/takin'
import MorCompilerPlugin from '@morjs/plugin-compiler'
import MorComposerPlugin from '@morjs/plugin-composer'

const cli = takin('mor')

cli.use([
  new MorCompilerPlugin(),
  new MorComposerPlugin()
])

await cli.run(
  { name: 'compile', options: { target: 'wechat' } },
  [{ sourceType: 'alipay', target: 'wechat' }]
)

Build docs developers (and LLMs) love