@nasti-toolchain/nasti 1.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.md +169 -0
- package/bin/nasti.js +2 -0
- package/client/hmr.ts +19 -0
- package/dist/cli.cjs +1369 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1346 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/hmr.cjs +19 -0
- package/dist/client/hmr.cjs.map +1 -0
- package/dist/client/hmr.d.cts +15 -0
- package/dist/client/hmr.d.ts +15 -0
- package/dist/client/hmr.js +1 -0
- package/dist/client/hmr.js.map +1 -0
- package/dist/index.cjs +1233 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +216 -0
- package/dist/index.d.ts +216 -0
- package/dist/index.js +1204 -0
- package/dist/index.js.map +1 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zixiao Laboratory
|
|
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.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Nasti
|
|
4
|
+
|
|
5
|
+
**基于 [Rolldown](https://rolldown.rs) + [OXC](https://oxc.rs) 的高性能 Web 打包器**
|
|
6
|
+
|
|
7
|
+
*兼容 Vite 插件生态,内置 React & Vue 支持*
|
|
8
|
+
|
|
9
|
+
[](https://github.com/zixiao-labs/Nasti/actions/workflows/ci.yml)
|
|
10
|
+
[](https://www.npmjs.com/package/nasti-build)
|
|
11
|
+
[](./LICENSE)
|
|
12
|
+
|
|
13
|
+
[English](#features) | [文档](https://nasti.zixiaolabs.com) | [快速开始](#quick-start)
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- **Rolldown 驱动** - Rust 编写的打包内核,生产构建速度比 Rollup 快 10-30x
|
|
22
|
+
- **OXC 转译** - Rust 编写的 TS/JSX/TSX 转译器,比 Babel 快 20-50x
|
|
23
|
+
- **Vite 插件兼容** - 直接使用现有 Vite/Rollup 插件(resolveId / load / transform)
|
|
24
|
+
- **内置 React 支持** - JSX 自动转换 + React Fast Refresh HMR
|
|
25
|
+
- **内置 Vue 支持** - SFC 编译 + Vue HMR(可选依赖 `@vue/compiler-sfc`)
|
|
26
|
+
- **Dev Server + HMR** - 开发服务器 + WebSocket 热模块替换
|
|
27
|
+
- **TypeScript 优先** - 原生 TS 支持,零配置
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# 安装
|
|
33
|
+
npm install -D nasti-build
|
|
34
|
+
|
|
35
|
+
# 启动开发服务器
|
|
36
|
+
npx nasti dev
|
|
37
|
+
|
|
38
|
+
# 生产构建
|
|
39
|
+
npx nasti build
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 项目结构
|
|
43
|
+
|
|
44
|
+
Nasti 期望的项目结构与 Vite 一致:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
my-project/
|
|
48
|
+
├── index.html # 入口 HTML
|
|
49
|
+
├── src/
|
|
50
|
+
│ ├── main.tsx # JS 入口(在 index.html 中引用)
|
|
51
|
+
│ └── App.tsx
|
|
52
|
+
├── public/ # 静态资源(原样复制)
|
|
53
|
+
└── nasti.config.ts # 配置文件(可选)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Configuration
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
// nasti.config.ts
|
|
60
|
+
import { defineConfig } from 'nasti-build'
|
|
61
|
+
|
|
62
|
+
export default defineConfig({
|
|
63
|
+
// 框架: 'react' | 'vue' | 'auto'(自动检测)
|
|
64
|
+
framework: 'react',
|
|
65
|
+
|
|
66
|
+
server: {
|
|
67
|
+
port: 3000,
|
|
68
|
+
host: true, // 监听所有地址
|
|
69
|
+
open: true, // 自动打开浏览器
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
build: {
|
|
73
|
+
outDir: 'dist',
|
|
74
|
+
sourcemap: true,
|
|
75
|
+
minify: true,
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
resolve: {
|
|
79
|
+
alias: {
|
|
80
|
+
'@': '/src',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
// 直接使用 Vite 插件
|
|
85
|
+
plugins: [],
|
|
86
|
+
})
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## CLI
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# 开发服务器
|
|
93
|
+
nasti dev [root] [--port 3000] [--host] [--open]
|
|
94
|
+
|
|
95
|
+
# 生产构建
|
|
96
|
+
nasti build [root] [--outDir dist] [--sourcemap] [--minify]
|
|
97
|
+
|
|
98
|
+
# 预览构建产物
|
|
99
|
+
nasti preview [root] [--port 4173]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Programmatic API
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import { build, createServer, defineConfig } from 'nasti-build'
|
|
106
|
+
|
|
107
|
+
// 开发服务器
|
|
108
|
+
const server = await createServer({
|
|
109
|
+
root: '.',
|
|
110
|
+
server: { port: 3000 },
|
|
111
|
+
})
|
|
112
|
+
await server.listen()
|
|
113
|
+
|
|
114
|
+
// 生产构建
|
|
115
|
+
await build({
|
|
116
|
+
root: '.',
|
|
117
|
+
build: { outDir: 'dist' },
|
|
118
|
+
})
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Plugin API
|
|
122
|
+
|
|
123
|
+
Nasti 的插件接口与 Vite 完全兼容:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
import type { NastiPlugin } from 'nasti-build'
|
|
127
|
+
|
|
128
|
+
function myPlugin(): NastiPlugin {
|
|
129
|
+
return {
|
|
130
|
+
name: 'my-plugin',
|
|
131
|
+
enforce: 'pre', // 'pre' | 'post'(可选)
|
|
132
|
+
apply: 'build', // 'build' | 'serve'(可选)
|
|
133
|
+
|
|
134
|
+
resolveId(source, importer) {
|
|
135
|
+
// 解析模块 ID
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
load(id) {
|
|
139
|
+
// 加载模块内容
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
transform(code, id) {
|
|
143
|
+
// 转换模块代码
|
|
144
|
+
return { code: transformedCode }
|
|
145
|
+
},
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Vue 支持
|
|
151
|
+
|
|
152
|
+
Vue 支持需要安装可选依赖:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
npm install -D @vue/compiler-sfc
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
// nasti.config.ts
|
|
160
|
+
export default defineConfig({
|
|
161
|
+
framework: 'vue',
|
|
162
|
+
})
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
[MIT](./LICENSE) - Made by [zixiao-labs](https://github.com/zixiao-labs)
|
|
168
|
+
|
|
169
|
+
> Nasti - 明日方舟干员命名 :
|
package/bin/nasti.js
ADDED
package/client/hmr.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Nasti HMR 浏览器客户端
|
|
2
|
+
// 此文件会被内联到 Dev Server 中间件返回给浏览器
|
|
3
|
+
|
|
4
|
+
export interface HotModule {
|
|
5
|
+
accept(cb?: (mod: any) => void): void
|
|
6
|
+
accept(deps: string[], cb: (mods: any[]) => void): void
|
|
7
|
+
dispose(cb: (data: any) => void): void
|
|
8
|
+
prune(cb: () => void): void
|
|
9
|
+
invalidate(): void
|
|
10
|
+
data: Record<string, any>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare global {
|
|
14
|
+
interface ImportMeta {
|
|
15
|
+
hot?: HotModule
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {}
|