npm.io
2.1.3 • Published 2 years agoCLI

mistc

Licence
ISC
Version
2.1.3
Deps
21
Size
1.4 MB
Vulns
1
Weekly
0

mistc

Mist 组件编译工具

Install

npm install -g mistc

CLI Usage

mistc [options] file
mistc --help  

Mist 模板编译工具

Usage:
  mistc [options] file

Options:
  -o,--output <file>    输出到指定文件
  -m,--minify           是否进行最小化
  -b,--binary           是否编译为二进制产物
  -u,--check-update     检查更新,输出 JSON 字符串,属性有 hasUpdate, currentVersion, newVersion
  -p,--platform         编译平台
  -d,--debug            是否调试
  -v,--version          输出版本号
  -h,--help             显示帮助

API Usage

import { compile } from 'mistc'

async function test() {
  const templatePath = '/path/to/the/template/file.mist'
  const compiledTemplate = await compile(templatePath, { minify: true, tsxOptions: {
    removeConsoleLog: false,
    symbolNameOptimization: true,
    shortStyleKeyOptimization: false
  }});
  console.log(compiledTemplate)
}

开发指南

.
├── FEATURE.md
├── README.md
├── bin
│   └── mistc
├── dev            // 测试
│   └── test.js
├── package-lock.json
├── package.json
├── src            // 代码
│   ├── binary
│   ├── cli.ts
│   ├── constantFolding.ts
│   ├── convertExpressions.ts
│   ├── exp
│   ├── index.ts
│   ├── inlineComponents.ts
│   └── tsx
├── test            // 单元测试
│   ├── index.js
│   ├── mist
│   └── tsx

1 安装依赖

npm i

2 编写代码

执行测试代码

ts-node ./dev/test.js    

断点调试 打开test.js文件,按F5启动调试

3 跑单元测试

npm run test

4 发布beta版 修改版本号

npm publish --tag=beta

5 发布正式版 修改版本号

npm publish

性能优化

node性能分析

node --prof ./dev/prof.js
node --prof-process isolate-0x7f949e700000-43913-v8.log > processed.txt