# miniprogram-compiler

> compiler

Latest version **0.2.3** (published 2024-03-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install miniprogram-compiler
pnpm add miniprogram-compiler
yarn add miniprogram-compiler
bun add miniprogram-compiler
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.3 |
| Published | 2024-03-08 |
| First published | 2019-02-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | wechat-miniprogram |
| Maintainers | juneandgreen, wechat-miniprogram |

## Links

- npm: https://www.npmjs.com/package/miniprogram-compiler
- npm.io page: https://npm.io/package/miniprogram-compiler

## Dependencies (2)

- [glob](https://npm.io/package/glob.md) ^7.1.3
- [unescape-js](https://npm.io/package/unescape-js.md) ^1.1.1

## Recent versions

- 0.2.3 (latest) — 2024-03-08
- 0.2.2 — 2023-01-10
- 0.2.1 — 2022-03-29
- 0.2.0 — 2022-02-17
- 0.1.3 — 2021-04-25
- 0.1.2 — 2019-11-20
- 0.1.1 — 2019-07-14
- 0.1.0 — 2019-03-20
- 0.0.7 — 2019-02-24
- 0.0.6 — 2019-02-23
- 0.0.5 — 2019-02-14
- 0.0.4 — 2019-02-14
- 0.0.3 — 2019-02-14
- 0.0.2 — 2019-02-13
- 0.0.1 — 2019-02-13

## README

# miniprogram-compiler

## 介绍

这是 wcc、wcsc 官方编译器的 node 封装版，用于编译 wxml、wxss 文件。

## 快速上手

### 安装

```
npm install miniprogram-compiler
```

### 使用

编译 wxml：

```js
const {wxmlToJs} = require('miniprogram-compiler')

const compilerString = wxmlToJs(miniprogramProjectRoot)
const compiler = new Function('global', compilerString)
const $gwx = compiler({})

// 假设项目里有 wxml/index.wxml 文件
const generateFunc = $gwx('wxml/index.wxml')
const compilerRes = generateFunc({
    // 数据
})

console.log(compilerRes)
```

编译 wxss：

```js
const {wxssToJs} = require('miniprogram-compiler')

const compilerString = wxssToJs(miniprogramProjectRoot)
const compiler = new Function('global', compilerString)
const $gwx = compiler({})

// 假设项目里有 wxss/index.wxss 文件
const generateFunc = $gwx('wxss/index.wxss')
generateFunc('前缀') // 会插入到 style 中
```

---
_Source: https://npm.io/package/miniprogram-compiler · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
