@wevu/compiler 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +68 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # @wevu/compiler
2
+
3
+ ## 简介
4
+
5
+ `@wevu/compiler` 提供 Wevu 的编译能力,面向小程序模板与 Vue SFC 的解析、转换与输出。它从 weapp-vite 中抽离出纯编译管线,供 `wevu/compiler` 与 weapp-vite 等上层工具复用。
6
+
7
+ ## 特性
8
+
9
+ - Vue SFC 编译(script/template/style/config)
10
+ - WXML/WXSS 编译与多平台模板适配
11
+ - JSON 配置解析与合并策略
12
+ - Wevu 页面特性分析与注入
13
+ - 可作为独立编译器在非 Vite 场景使用
14
+
15
+ ## 安装
16
+
17
+ ```bash
18
+ pnpm add @wevu/compiler
19
+ ```
20
+
21
+ ## 使用
22
+
23
+ 编译单个 Vue SFC:
24
+
25
+ ```ts
26
+ import { compileSfc } from '@wevu/compiler'
27
+
28
+ const result = await compileSfc(
29
+ sourceCode,
30
+ filename,
31
+ {
32
+ isPage: true,
33
+ template: { /* 模板编译参数 */ },
34
+ json: { kind: 'page' },
35
+ },
36
+ )
37
+
38
+ console.log(result.script)
39
+ console.log(result.template)
40
+ ```
41
+
42
+ 使用页面特性工具:
43
+
44
+ ```ts
45
+ import {
46
+ collectWevuPageFeatureFlags,
47
+ injectWevuPageFeaturesInJs,
48
+ } from '@wevu/compiler'
49
+
50
+ const flags = collectWevuPageFeatureFlags(sourceCode)
51
+ const nextCode = injectWevuPageFeaturesInJs(sourceCode, flags)
52
+ ```
53
+
54
+ ## 配置
55
+
56
+ `compileSfc`(`compileVueFile`)常用选项:
57
+
58
+ - `isPage` / `isApp`
59
+ - `warn`:自定义警告输出
60
+ - `template`:模板编译参数
61
+ - `json`:配置合并策略
62
+ - `autoUsingComponents` / `autoImportTags`
63
+ - `wevuDefaults`:Wevu 默认配置
64
+
65
+ ## 相关链接
66
+
67
+ - weapp-vite 文档:https://vite.icebreaker.top/
68
+ - 仓库:https://github.com/weapp-vite/weapp-vite
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wevu/compiler",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "description": "wevu 编译器基础包,面向小程序模板的编译与转换",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -54,7 +54,7 @@
54
54
  "pathe": "^2.0.3",
55
55
  "vue": "^3.5.27",
56
56
  "@weapp-core/shared": "3.0.0",
57
- "rolldown-require": "2.0.1"
57
+ "rolldown-require": "2.0.2"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public",