@makoojs/cli 0.1.0
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.
- package/LICENSE +21 -0
- package/README.CN.md +373 -0
- package/README.md +373 -0
- package/dist/bin.js +1506 -0
- package/dist/command/_util.d.ts +16 -0
- package/dist/command/add.d.ts +1 -0
- package/dist/command/bin.d.ts +2 -0
- package/dist/command/build.d.ts +1 -0
- package/dist/command/dev.d.ts +1 -0
- package/dist/command/inspect.d.ts +1 -0
- package/dist/config/config.d.ts +3 -0
- package/dist/config/defaults.d.ts +26 -0
- package/dist/config/resolve.d.ts +17 -0
- package/dist/config/types.d.ts +140 -0
- package/dist/config/validation.d.ts +15 -0
- package/dist/error/error.d.ts +46 -0
- package/dist/generator/generator.d.ts +3 -0
- package/dist/generator/render/import/importAdapter.d.ts +3 -0
- package/dist/generator/render/import/importComp.d.ts +3 -0
- package/dist/generator/render/import/importInjector.d.ts +1 -0
- package/dist/generator/render/import/importRuntimeSetup.d.ts +1 -0
- package/dist/generator/render/init/initInjector.d.ts +3 -0
- package/dist/generator/render/init/registerComp.d.ts +2 -0
- package/dist/generator/render/run/renderInjectorRun.d.ts +1 -0
- package/dist/generator/render/util/value.d.ts +1 -0
- package/dist/generator/types.d.ts +21 -0
- package/dist/index.cjs +86 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5090 -0
- package/dist/monkey/clipboard.d.ts +3 -0
- package/dist/monkey/download.d.ts +3 -0
- package/dist/monkey/index.cjs +1 -0
- package/dist/monkey/index.d.ts +60 -0
- package/dist/monkey/index.js +60 -0
- package/dist/monkey/info.d.ts +5 -0
- package/dist/monkey/menu.d.ts +4 -0
- package/dist/monkey/notification.d.ts +3 -0
- package/dist/monkey/request.d.ts +7 -0
- package/dist/monkey/resource.d.ts +4 -0
- package/dist/monkey/storage.d.ts +11 -0
- package/dist/monkey/style.d.ts +4 -0
- package/dist/monkey/tab.d.ts +6 -0
- package/dist/scanner/collectDependenics.d.ts +2 -0
- package/dist/scanner/load/loadManifes.d.ts +3 -0
- package/dist/scanner/load/loadMeta.d.ts +2 -0
- package/dist/scanner/scanner.d.ts +3 -0
- package/dist/scanner/types.d.ts +23 -0
- package/dist/scanner/util.d.ts +2 -0
- package/dist/scanner/validation.d.ts +121 -0
- package/dist/vitePlugin/hmrController.d.ts +4 -0
- package/dist/vitePlugin/makoo.d.ts +3 -0
- package/dist/vitePlugin/makooMonkey.d.ts +3 -0
- package/dist/vitePlugin/types.d.ts +12 -0
- package/dist/vitePlugin/virtualModule.d.ts +2 -0
- package/dist/vitePlugin/watchList.d.ts +4 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FlowingInk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.CN.md
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
# @makoojs/cli
|
|
2
|
+
|
|
3
|
+
`@makoojs/cli` 是 Makoo 项目的主要入口。它提供 Vite 插件、CLI 命令、manifest 类型辅助、injection 扫描、虚拟入口生成,并把 userscript 的开发、构建和安装流程接到 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey)。
|
|
4
|
+
|
|
5
|
+
如果你在开发普通 Makoo userscript 项目,通常应该从这个包开始。`@makoojs/core` 负责底层注入运行时,`@makoojs/vue` 和 `@makoojs/react` 负责组件挂载适配器,而 `@makoojs/cli` 负责把它们组织进 Vite 和 userscript 构建流程。
|
|
6
|
+
|
|
7
|
+
## 适用场景
|
|
8
|
+
|
|
9
|
+
- 使用 Vite 开发 Makoo userscript 项目。
|
|
10
|
+
- 从 `injections` 目录扫描注入模块并生成运行时代码。
|
|
11
|
+
- 编写 `injections/manifest.ts` 和模块级 `manifest.ts`。
|
|
12
|
+
- 通过 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 生成 userscript 元信息、开发入口和构建产物。
|
|
13
|
+
- 使用 `makoo dev`、`makoo build`、`makoo add`、`makoo inspect` 等命令。
|
|
14
|
+
- 通过 `@makoojs/cli/monkey` 使用 GM API 的 Makoo 稳定入口。
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
// npm install @makoojs/cli
|
|
20
|
+
// yarn add @makoojs/cli
|
|
21
|
+
pnpm add @makoojs/cli
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
如果你使用 `@makoojs/create-makoo` 创建项目,通常会自动配置好 `@makoojs/cli`。
|
|
25
|
+
|
|
26
|
+
## 最小 Vite 配置
|
|
27
|
+
|
|
28
|
+
`makoo()` 返回一个 Vite plugin 数组,因此在 `plugins` 中通常使用 `...makoo(...)`。
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { defineConfig } from 'vite';
|
|
32
|
+
import { makoo } from '@makoojs/cli';
|
|
33
|
+
import vue from '@vitejs/plugin-vue';
|
|
34
|
+
|
|
35
|
+
export default defineConfig({
|
|
36
|
+
plugins: [
|
|
37
|
+
vue(),
|
|
38
|
+
...makoo({
|
|
39
|
+
app: {
|
|
40
|
+
name: 'my-userscript',
|
|
41
|
+
version: '0.0.1',
|
|
42
|
+
description: 'My first Makoo script'
|
|
43
|
+
},
|
|
44
|
+
monkey: {
|
|
45
|
+
userscript: {
|
|
46
|
+
namespace: 'https://example.com',
|
|
47
|
+
match: ['https://example.com/*']
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`makoo()` 会先注入 Makoo 自己的扫描和虚拟入口插件,再接入 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 负责 userscript 开发与构建。
|
|
56
|
+
|
|
57
|
+
## 推荐项目结构
|
|
58
|
+
|
|
59
|
+
Makoo 默认扫描项目根目录下的 `injections` 目录。
|
|
60
|
+
|
|
61
|
+
```txt
|
|
62
|
+
.
|
|
63
|
+
├─ vite.config.ts
|
|
64
|
+
└─ injections
|
|
65
|
+
├─ manifest.ts
|
|
66
|
+
├─ profile-card
|
|
67
|
+
│ ├─ app.vue
|
|
68
|
+
│ └─ manifest.ts
|
|
69
|
+
└─ react-badge
|
|
70
|
+
├─ app.tsx
|
|
71
|
+
└─ manifest.ts
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
顶层 `injections/manifest.ts` 用来声明全局注入配置和模块列表。模块级 `injections/<module>/manifest.ts` 可以覆盖或补充单个模块的配置,适合让模块自己维护 `injectAt`、`component`、`framework`、`match` 或生命周期 hooks。
|
|
75
|
+
|
|
76
|
+
## Manifest 基础
|
|
77
|
+
|
|
78
|
+
`@makoojs/cli` 导出 `defineInjections()` 和 `defineInjection()`,用于给 manifest 提供类型约束。
|
|
79
|
+
|
|
80
|
+
对象形式适合多数项目:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { defineInjections } from '@makoojs/cli';
|
|
84
|
+
|
|
85
|
+
export default defineInjections({
|
|
86
|
+
globalInjector: {
|
|
87
|
+
alive: false,
|
|
88
|
+
scope: 'local',
|
|
89
|
+
timeout: 5000
|
|
90
|
+
},
|
|
91
|
+
injections: {
|
|
92
|
+
profile: {
|
|
93
|
+
injectAt: '#app',
|
|
94
|
+
component: './profile-card/app.vue',
|
|
95
|
+
framework: 'Vue',
|
|
96
|
+
match: {
|
|
97
|
+
include: ['https://example.com/users/*'],
|
|
98
|
+
exclude: ['https://example.com/users/settings']
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
badge: {
|
|
102
|
+
injectAt: 'body',
|
|
103
|
+
component: './react-badge/app.tsx',
|
|
104
|
+
framework: 'React'
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
数组形式适合动态生成,或需要显式声明 `name` 的场景:
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
import { defineInjections } from '@makoojs/cli';
|
|
114
|
+
|
|
115
|
+
export default defineInjections({
|
|
116
|
+
injections: [
|
|
117
|
+
{
|
|
118
|
+
name: 'profile',
|
|
119
|
+
injectAt: '#app',
|
|
120
|
+
component: './profile-card/app.vue',
|
|
121
|
+
framework: 'Vue'
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
模块级 manifest 可以使用 `defineInjection()`:
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
import { defineInjection } from '@makoojs/cli';
|
|
131
|
+
|
|
132
|
+
export default defineInjection({
|
|
133
|
+
injectAt: '#app',
|
|
134
|
+
component: './app.vue',
|
|
135
|
+
framework: 'Vue',
|
|
136
|
+
alive: true
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
常用字段:
|
|
141
|
+
|
|
142
|
+
| 字段 | 说明 |
|
|
143
|
+
| --- | --- |
|
|
144
|
+
| `injectAt` | 目标 DOM 选择器 |
|
|
145
|
+
| `component` | 组件路径,相对于顶层 manifest 或模块目录 |
|
|
146
|
+
| `framework` | `Vue`、`React` 或 `auto`;省略时根据文件扩展名推断 |
|
|
147
|
+
| `enabled` | 是否启用该模块,默认 `true` |
|
|
148
|
+
| `match` | 模块级 URL 匹配规则 |
|
|
149
|
+
| `alive` | 目标 DOM 被移除后是否尝试重注入 |
|
|
150
|
+
| `scope` | alive 观察范围,支持 `local` 和 `global` |
|
|
151
|
+
| `timeout` | 等待目标 DOM 的超时时间 |
|
|
152
|
+
| `hooks` | 传给 `@makoojs/core` 的生命周期观察 hooks |
|
|
153
|
+
|
|
154
|
+
`match` 支持数组简写:
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
match: ['https://example.com/*']
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
也支持 include/exclude 对象:
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
match: {
|
|
164
|
+
include: ['https://example.com/*'],
|
|
165
|
+
exclude: ['https://example.com/admin/*']
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
`match` 是模块级过滤。userscript 本身在哪些页面运行,仍由 `monkey.userscript.match` 等 userscript 元信息决定。
|
|
170
|
+
|
|
171
|
+
## 配置概览
|
|
172
|
+
|
|
173
|
+
`makoo()` 的主要配置分为四块:
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
makoo({
|
|
177
|
+
app: {
|
|
178
|
+
name: 'my-script',
|
|
179
|
+
version: '0.0.1',
|
|
180
|
+
description: 'demo script'
|
|
181
|
+
},
|
|
182
|
+
source: {
|
|
183
|
+
include: ['*'],
|
|
184
|
+
exclude: []
|
|
185
|
+
},
|
|
186
|
+
injector: {
|
|
187
|
+
alive: false,
|
|
188
|
+
scope: 'local',
|
|
189
|
+
timeout: 5000
|
|
190
|
+
},
|
|
191
|
+
runtime: {
|
|
192
|
+
setup: ['./injections/vue-setup.ts']
|
|
193
|
+
},
|
|
194
|
+
monkey: {
|
|
195
|
+
userscript: {
|
|
196
|
+
match: ['https://example.com/*']
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
| 配置 | 说明 |
|
|
203
|
+
| --- | --- |
|
|
204
|
+
| `app` | 用于生成 userscript 的 `name`、`version`、`description` |
|
|
205
|
+
| `source` | 控制扫描哪些 injection 模块目录 |
|
|
206
|
+
| `injector` | 传给 `@makoojs/core` 的全局注入默认值 |
|
|
207
|
+
| `runtime` | 控制 Makoo 生成入口里的运行时前置 setup import |
|
|
208
|
+
| `monkey` | 大多数配置会透传给 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) |
|
|
209
|
+
|
|
210
|
+
`source.include` 和 `source.exclude` 过滤的是 `injections` 下的模块目录名,不是页面 URL。默认 include 是 `['*']`,exclude 是 `[]`。
|
|
211
|
+
|
|
212
|
+
大多数 `monkey` 配置会透传给 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey),用于 userscript 元信息、开发服务和构建行为。但 Makoo 会内部管理以下字段:
|
|
213
|
+
|
|
214
|
+
- `entry`:固定为 Makoo 生成的虚拟入口。
|
|
215
|
+
- `clientAlias`:固定为 Makoo 内部使用的 GM API alias。
|
|
216
|
+
- `server.mountGmApi`:固定由 Makoo 管理,不支持用户配置。
|
|
217
|
+
|
|
218
|
+
默认情况下,`monkey.build.autoGrant` 为 `true`,[lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 会根据最终代码生成 `@grant`。
|
|
219
|
+
|
|
220
|
+
## CLI 命令
|
|
221
|
+
|
|
222
|
+
安装后可以使用 `makoo` 命令:
|
|
223
|
+
|
|
224
|
+
| 命令 | 说明 |
|
|
225
|
+
| --- | --- |
|
|
226
|
+
| `makoo dev` | 启动 Vite dev server,并打印本地访问地址 |
|
|
227
|
+
| `makoo build` | 执行 Vite build,生成 userscript 构建产物 |
|
|
228
|
+
| `makoo add <name>` | 创建新的 injection 模块并更新 manifest |
|
|
229
|
+
| `makoo add <name> --framework Vue` | 创建 Vue injection 模块 |
|
|
230
|
+
| `makoo add <name> --framework React` | 创建 React injection 模块 |
|
|
231
|
+
| `makoo inspect` | 打印解析后的 Makoo 配置和扫描结果 |
|
|
232
|
+
|
|
233
|
+
`makoo add` 默认使用 React。它会在 `injections/<name>` 下创建组件文件,并把模块记录写入 `injections/manifest.ts`。
|
|
234
|
+
|
|
235
|
+
## 扫描与生成流程
|
|
236
|
+
|
|
237
|
+
Makoo 的 Vite 插件会在启动和构建时执行以下流程:
|
|
238
|
+
|
|
239
|
+
1. 加载 `injections/manifest.ts`。
|
|
240
|
+
2. 扫描 `injections` 下符合 `source.include` / `source.exclude` 的模块目录。
|
|
241
|
+
3. 读取模块级 `manifest.ts`,并与顶层 manifest 合并。
|
|
242
|
+
4. 解析组件路径、模块 ID、framework、match、alive、scope、timeout 等配置。
|
|
243
|
+
5. 根据实际使用到的 framework 生成 adapter import。
|
|
244
|
+
6. 生成虚拟入口,创建 `Injector`,注册组件并执行 `run()`。
|
|
245
|
+
7. 把虚拟入口交给 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 打包成 userscript。
|
|
246
|
+
|
|
247
|
+
如果没有找到顶层 manifest、没有可用注入模块,或无法推断 framework,CLI 会抛出 Makoo 自己的错误类型,方便定位问题。
|
|
248
|
+
|
|
249
|
+
## HMR 行为
|
|
250
|
+
|
|
251
|
+
开发模式下,Makoo 会区分结构变化和普通组件更新。
|
|
252
|
+
|
|
253
|
+
| 变化 | 行为 |
|
|
254
|
+
| --- | --- |
|
|
255
|
+
| 顶层 `injections/manifest.ts` 修改 | 重新扫描并更新虚拟入口 |
|
|
256
|
+
| 模块级 `injections/<module>/manifest.ts` 修改 | 重新扫描并更新虚拟入口 |
|
|
257
|
+
| manifest 静态导入的本地 helper 修改 | 追踪依赖并重新扫描更新虚拟入口 |
|
|
258
|
+
| 模块目录新增或删除 | 重新扫描并更新虚拟入口 |
|
|
259
|
+
| 普通组件文件修改 | 交给 Vite 原生 HMR 处理 |
|
|
260
|
+
| 第三方依赖变化 | 不作为 Makoo 结构扫描依赖 |
|
|
261
|
+
|
|
262
|
+
结构变化会触发虚拟入口更新。普通组件内部变化则保持 Vite 自己的热更新体验。
|
|
263
|
+
|
|
264
|
+
## Runtime Setup
|
|
265
|
+
|
|
266
|
+
`runtime.setup` 用来导入一批只负责副作用初始化的运行时文件。它们会在 Makoo 初始化 adapter、注册 injection、执行 `injector.run()` 前进入最终 userscript bundle。
|
|
267
|
+
|
|
268
|
+
这个能力适合注册 Vue 插件、初始化 GM helper、导入全局样式或执行埋点初始化。
|
|
269
|
+
|
|
270
|
+
```ts
|
|
271
|
+
// vite.config.ts
|
|
272
|
+
import { defineConfig } from 'vite';
|
|
273
|
+
import { makoo } from '@makoojs/cli';
|
|
274
|
+
|
|
275
|
+
export default defineConfig({
|
|
276
|
+
plugins: [
|
|
277
|
+
...makoo({
|
|
278
|
+
app: {
|
|
279
|
+
name: 'my-script',
|
|
280
|
+
version: '0.0.1'
|
|
281
|
+
},
|
|
282
|
+
runtime: {
|
|
283
|
+
setup: ['./injections/vue-setup.ts']
|
|
284
|
+
},
|
|
285
|
+
monkey: {
|
|
286
|
+
userscript: {
|
|
287
|
+
match: ['https://example.com/*']
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
})
|
|
291
|
+
]
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
```ts
|
|
296
|
+
// injections/vue-setup.ts
|
|
297
|
+
import { VuePlugin } from '@makoojs/vue';
|
|
298
|
+
import router from './router';
|
|
299
|
+
import i18n from './i18n';
|
|
300
|
+
|
|
301
|
+
VuePlugin.usePlugins(router, i18n);
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
`runtime.setup` 支持字符串和字符串数组。相对路径会基于项目根目录解析:
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
runtime: {
|
|
308
|
+
setup: [
|
|
309
|
+
'./injections/vue-setup.ts',
|
|
310
|
+
'./injections/gm-setup.ts'
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
开发模式下,setup 文件和它静态导入的本地依赖会参与结构更新。修改这些文件时,Makoo 会重新扫描并更新虚拟入口。
|
|
316
|
+
|
|
317
|
+
## 使用 GM API
|
|
318
|
+
|
|
319
|
+
`@makoojs/cli` 提供 `@makoojs/cli/monkey` 子入口,作为 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) GM API 的 Makoo 稳定封装。
|
|
320
|
+
|
|
321
|
+
```ts
|
|
322
|
+
import { gmStorage, gmStyle } from '@makoojs/cli/monkey';
|
|
323
|
+
|
|
324
|
+
gmStyle.add('.makoo-panel { z-index: 999999; }');
|
|
325
|
+
gmStorage.set('enabled', true);
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
也可以使用聚合入口:
|
|
329
|
+
|
|
330
|
+
```ts
|
|
331
|
+
import { GMapi } from '@makoojs/cli/monkey';
|
|
332
|
+
|
|
333
|
+
GMapi.storage.set('enabled', true);
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
如果希望生成的 `@grant` 范围尽量小,优先使用按能力导入;`GMapi` 更适合作为共享代码或探索阶段的便利入口。完整 GM API 参考后续会放到独立文档站中。
|
|
337
|
+
|
|
338
|
+
## 减小构建体积
|
|
339
|
+
|
|
340
|
+
`@makoojs/cli` 重新导出了 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 的 `cdn` 辅助方法。你可以配合 `monkey.build.externalGlobals` 使用 CDN 外部依赖,减小 userscript 构建体积。
|
|
341
|
+
|
|
342
|
+
```ts
|
|
343
|
+
import { defineConfig } from 'vite';
|
|
344
|
+
import { cdn, makoo } from '@makoojs/cli';
|
|
345
|
+
|
|
346
|
+
export default defineConfig({
|
|
347
|
+
plugins: makoo({
|
|
348
|
+
app: {
|
|
349
|
+
name: 'my-script',
|
|
350
|
+
version: '0.0.1'
|
|
351
|
+
},
|
|
352
|
+
monkey: {
|
|
353
|
+
build: {
|
|
354
|
+
externalGlobals: {
|
|
355
|
+
vue: cdn.jsdelivr('Vue', 'dist/vue.global.prod.js')
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
})
|
|
360
|
+
});
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
## 与其他包的关系
|
|
364
|
+
|
|
365
|
+
| 包 | 职责 |
|
|
366
|
+
| --- | --- |
|
|
367
|
+
| `@makoojs/cli` | Vite 插件、CLI 命令、扫描、代码生成和 userscript 构建接入 |
|
|
368
|
+
| `@makoojs/core` | 框架无关的注入运行时内核 |
|
|
369
|
+
| `@makoojs/vue` | Vue adapter 与 Vue 插件注册辅助 |
|
|
370
|
+
| `@makoojs/react` | React adapter |
|
|
371
|
+
| `@makoojs/create-makoo` | 项目脚手架 |
|
|
372
|
+
|
|
373
|
+
`@makoojs/cli` 本身并不是完整的运行时实现,很多功能无法单独存在,需要依赖 `@makoojs/core` 提供的注入调度能力才能真正工作。
|