@nasti-toolchain/nasti 2.2.0 → 2.3.1
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/README.md +37 -1
- package/dist/cli.cjs +552 -123
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +552 -123
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +554 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +109 -11
- package/dist/index.d.ts +109 -11
- package/dist/index.js +551 -121
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
- **Vite 插件兼容** - 直接使用现有 Vite/Rollup 插件(resolveId / load / transform)
|
|
24
24
|
- **内置 React 支持** - JSX 自动转换 + React Fast Refresh HMR
|
|
25
25
|
- **内置 Vue 支持** - SFC 编译 + Vue HMR(可选依赖 `@vue/compiler-sfc`)
|
|
26
|
-
- **Electron 41+ 支持** -
|
|
26
|
+
- **Electron 41+ 支持** - React/Vue renderer + 主进程 / Preload,支持 ESM 主进程
|
|
27
|
+
- **Environment Driver** - 可桥接 Rspeedy 等非 Rolldown 工具链,含 build/dev/watch 生命周期
|
|
27
28
|
- **Monaco Editor 集成** - 内置 `monacoEditorPlugin`,预打包 Web Worker,修复 HMR 期间的 EMFILE
|
|
28
29
|
- **Dev Server + HMR** - 开发服务器 + WebSocket 热模块替换
|
|
29
30
|
- **TypeScript 优先** - 原生 TS 支持,零配置
|
|
@@ -210,9 +211,11 @@ import { defineConfig } from '@nasti-toolchain/nasti'
|
|
|
210
211
|
|
|
211
212
|
export default defineConfig({
|
|
212
213
|
target: 'electron',
|
|
214
|
+
framework: 'auto', // 自动识别 React / Vue
|
|
213
215
|
electron: {
|
|
214
216
|
main: 'src/electron/main.ts', // 主进程入口
|
|
215
217
|
preload: 'src/electron/preload.ts', // Preload 脚本(可传数组)
|
|
218
|
+
renderer: 'src/renderer/index.html', // React / Vue renderer HTML
|
|
216
219
|
mainFormat: 'cjs', // 主进程输出格式:'cjs' | 'esm'
|
|
217
220
|
preloadFormat: 'cjs', // Preload 输出格式
|
|
218
221
|
nodeTarget: 'node22', // Electron 41 捆绑 Node 22
|
|
@@ -222,6 +225,19 @@ export default defineConfig({
|
|
|
222
225
|
})
|
|
223
226
|
```
|
|
224
227
|
|
|
228
|
+
Vue renderer 直接使用标准 SFC:
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
// src/renderer/main.ts
|
|
232
|
+
import { createApp } from 'vue'
|
|
233
|
+
import App from './App.vue'
|
|
234
|
+
|
|
235
|
+
createApp(App).mount('#app')
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
生产 renderer 默认使用 `base: './'`,因此 `BrowserWindow.loadFile()` 可以正确加载
|
|
239
|
+
hashed JS/CSS;显式配置其他 `base` 时保留用户值。
|
|
240
|
+
|
|
225
241
|
开发:
|
|
226
242
|
|
|
227
243
|
```bash
|
|
@@ -269,6 +285,26 @@ app.whenReady().then(createWindow)
|
|
|
269
285
|
|
|
270
286
|
> 详细说明见 [Electron 指南](https://nasti.zixiaolabs.com/pages/electron.html)。
|
|
271
287
|
|
|
288
|
+
## External Environment Driver
|
|
289
|
+
|
|
290
|
+
Rspeedy 等外部工具链可以接管单个环境,同时保留 Nasti 的 CLI、日志与多环境编排:
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
export default defineConfig({
|
|
294
|
+
environments: {
|
|
295
|
+
lynx: {
|
|
296
|
+
consumer: 'client',
|
|
297
|
+
driver: 'rspeedy',
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
plugins: [pluginRspeedyBridge()],
|
|
301
|
+
})
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
bridge 插件通过 `createEnvironmentDriver()` 提供 `build`、`serve`、`watchChange`
|
|
305
|
+
和 `close`,并可使用 `setup(api)`、`api.expose/useExposed` 与
|
|
306
|
+
`afterBuildApp()` 协调多个插件或环境。
|
|
307
|
+
|
|
272
308
|
## Monaco Editor 支持
|
|
273
309
|
|
|
274
310
|
内置 `monacoEditorPlugin`(对标 `vite-plugin-monaco-editor`),解决两个老大难问题:
|