MP Tool
11/8/26About 1 min
A lightweight enhancement framework for mini-programs.
Installation
Every package is published as a single ESM file, so just install it with your package manager:
# Everything (api + enhance + file + net + parser + shared utilities)
npm i @mptool/all
# Skyline rendering engine (base library 3.0+)
npm i @mptool/skyline
# Only the enhancement framework itself
npm i @mptool/enhanceYou can also use pnpm add / yarn add instead of npm i.
miniprogram-api-typings is an optional peer dependency that only provides the global type definitions of the mini-program APIs; install it when you need type hints:
npm i -D miniprogram-api-typingsImporting in WeChat DevTools
- Run one of the install commands above in the project root;
- Open WeChat DevTools and choose "Tools → Build npm";
- Import packages by name in your code:
import { $App, $Config, $Page, request } from "@mptool/all";Each package declares "miniprogram": "dist", so building npm bundles the single-file output into miniprogram_npm.
Choosing a package
| Need | Recommendation |
|---|---|
| Every capability at once | @mptool/all |
| Skyline rendering engine | @mptool/skyline or @mptool/skyline-enhance |
| Only the framework (lifecycles, communication, routing, hot reload) | @mptool/enhance |
A replacement for eval / new Function | @mptool/run |
Mocking wx in tests | @mptool/mock |
| Encoding conversion (GBK / GB18030) | @mptool/encoder |
Features
- Enables communication between any page and component
- Extra lifecycles, allowing pages to call each other for preloading
- Cross references between components and pages
- Hot reload for page logic (used together with
@mptool/runand@mptool/all) - For the Skyline rendering engine, use the slim build:
@mptool/skyline-enhance(see docs)
- Set an expiration time for cached data
- Node.js-style folder creation
- Archive extraction API
- Save online files
- Headers
- URLSearchParams
- Automatic cookie parsing and attachment
- Not included in the
@mptool/all/@mptool/skylinebundles; import it separately
- Not included in the