@easy-editor/easypack 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.
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright © 2024-PRESENT JinSo <https://github.com/JinSooo>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,230 @@
1
+ # @easy-editor/easypack
2
+
3
+ EasyEditor 生态统一构建工具,用于 Materials 和 Setters 的打包构建。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ pnpm add -D @easy-editor/easypack
9
+ ```
10
+
11
+ ## 快速开始
12
+
13
+ ### 1. 初始化配置
14
+
15
+ ```bash
16
+ easypack init
17
+ ```
18
+
19
+ 选择预设类型:
20
+ - `material` - 物料组件
21
+ - `setter` - 设置器
22
+ - `library` - 通用库
23
+
24
+ ### 2. 构建
25
+
26
+ ```bash
27
+ easypack build
28
+ ```
29
+
30
+ ### 3. 开发服务器
31
+
32
+ ```bash
33
+ easypack dev
34
+ ```
35
+
36
+ ## 配置文件
37
+
38
+ 创建 `easypack.config.ts`:
39
+
40
+ ```typescript
41
+ export default {
42
+ preset: 'material',
43
+ globalName: 'EasyEditorMaterialsText',
44
+ dev: {
45
+ port: 5001,
46
+ },
47
+ }
48
+ ```
49
+
50
+ ## 预设
51
+
52
+ ### material
53
+
54
+ 适用于 EasyMaterials 物料组件。
55
+
56
+ **默认配置:**
57
+ - 入口:`src/index.tsx`, `src/meta.ts`, `src/component.tsx`
58
+ - 输出:`index.min.js`, `meta.min.js`, `component.min.js`
59
+ - CSS:注入到 JS 中
60
+ - JSX:automatic
61
+
62
+ ### setter
63
+
64
+ 适用于 EasySetters 设置器包。
65
+
66
+ **默认配置:**
67
+ - 入口:`src/index.ts`
68
+ - 输出:`index.min.js`
69
+ - CSS:提取为 `index.css`
70
+ - JSX:classic
71
+ - 外部依赖:包含 `@easy-editor/core`
72
+
73
+ ### library
74
+
75
+ 适用于通用 React 库。
76
+
77
+ **默认配置:**
78
+ - 入口:`src/index.ts`
79
+ - 输出:`index.min.js`
80
+ - CSS:注入到 JS 中
81
+ - JSX:automatic
82
+
83
+ ## 配置选项
84
+
85
+ ```typescript
86
+ interface EasypackConfig {
87
+ // 预设类型
88
+ preset: 'material' | 'setter' | 'library'
89
+
90
+ // UMD 全局变量名
91
+ globalName?: string
92
+
93
+ // 入口文件
94
+ entry?: {
95
+ main?: string // 主入口
96
+ meta?: string // 元数据入口 (material)
97
+ component?: string // 组件入口 (material)
98
+ }
99
+
100
+ // 输出配置
101
+ output?: {
102
+ dir?: string // 输出目录,默认 'dist'
103
+ esm?: boolean // ESM 格式
104
+ cjs?: boolean // CJS 格式
105
+ umd?: boolean // UMD 格式,默认 true
106
+ minify?: boolean // 压缩,默认 true
107
+ sourcemap?: boolean // Sourcemap
108
+ types?: boolean // TypeScript 声明
109
+ }
110
+
111
+ // 外部依赖
112
+ external?: {
113
+ externals?: string[] // 外部依赖列表
114
+ globals?: Record<string, string> // UMD 全局变量映射
115
+ }
116
+
117
+ // CSS 配置
118
+ css?: {
119
+ scopedName?: string // CSS Modules 类名格式
120
+ mode?: 'inject' | 'extract' // 注入或提取
121
+ extractFilename?: string // 提取文件名
122
+ }
123
+
124
+ // JSX 运行时
125
+ jsxRuntime?: 'automatic' | 'classic'
126
+
127
+ // 路径别名
128
+ alias?: Record<string, string>
129
+
130
+ // 开发服务器
131
+ dev?: {
132
+ port?: number
133
+ materialApi?: boolean
134
+ }
135
+ }
136
+ ```
137
+
138
+ ## 输出格式
139
+
140
+ | 配置 | 输出文件 |
141
+ |------|---------|
142
+ | `umd: true, minify: true` | `index.min.js` |
143
+ | `umd: true, minify: false` | `index.js` |
144
+ | `esm: true, minify: true` | `index.min.esm.js` |
145
+ | `esm: true, minify: false` | `index.esm.js` |
146
+ | `cjs: true, minify: true` | `index.min.cjs` |
147
+ | `cjs: true, minify: false` | `index.cjs` |
148
+
149
+ ## 示例
150
+
151
+ ### 物料组件
152
+
153
+ ```typescript
154
+ // easypack.config.ts
155
+ export default {
156
+ preset: 'material',
157
+ dev: {
158
+ port: 5003,
159
+ },
160
+ }
161
+ ```
162
+
163
+ ### 设置器
164
+
165
+ ```typescript
166
+ // easypack.config.ts
167
+ export default {
168
+ preset: 'setter',
169
+ globalName: 'EasyEditorSetters',
170
+ }
171
+ ```
172
+
173
+ ### 多格式输出
174
+
175
+ ```typescript
176
+ // easypack.config.ts
177
+ export default {
178
+ preset: 'library',
179
+ globalName: 'MyLibrary',
180
+ output: {
181
+ esm: true,
182
+ cjs: true,
183
+ umd: true,
184
+ minify: true,
185
+ sourcemap: true,
186
+ types: true,
187
+ },
188
+ }
189
+ ```
190
+
191
+ ### 自定义外部依赖
192
+
193
+ ```typescript
194
+ // easypack.config.ts
195
+ export default {
196
+ preset: 'library',
197
+ external: {
198
+ externals: ['react', 'react-dom', 'lodash'],
199
+ globals: {
200
+ lodash: '_',
201
+ },
202
+ },
203
+ }
204
+ ```
205
+
206
+ ## CLI 命令
207
+
208
+ ```bash
209
+ # 构建
210
+ easypack build
211
+
212
+ # 开发服务器
213
+ easypack dev
214
+
215
+ # 初始化配置
216
+ easypack init
217
+
218
+ # 指定配置文件
219
+ easypack build -c custom.config.ts
220
+
221
+ # 查看帮助
222
+ easypack --help
223
+
224
+ # 查看版本
225
+ easypack --version
226
+ ```
227
+
228
+ ## License
229
+
230
+ MIT
package/dist/bin.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * CLI Entry Point
3
+ * CLI 可执行入口
4
+ */
5
+ export {};