cmpt-huitu-cli 1.0.8 → 1.0.10
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/CHANGELOG.md +18 -3
- package/package.json +1 -1
- package/src/versions.js +2 -2
- package/templates/default/.npmrc +1 -0
- package/templates/default/node_modules/.viteCache/deps/_metadata.json +8 -0
- package/templates/default/node_modules/.viteCache/deps/package.json +3 -0
- package/templates/default/package.json +0 -1
- package/templates/default/src/components.d.ts +0 -2
- package/templates/default/src/views/home.vue +2 -10
- package/templates/default/vite.config.js +3 -20
- package/templates/default/.template-verification.md +0 -217
- package/templates/default//344/277/256/345/244/215vxe-table/344/276/235/350/265/226/351/227/256/351/242/230.md +0 -106
- package/templates/default//344/277/256/345/244/215xe-utils/351/224/231/350/257/257.md +0 -158
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
7
7
|
|
|
8
8
|
## [1.0.8] - 2026-01-09
|
|
9
9
|
|
|
10
|
+
### Breaking Changes
|
|
11
|
+
|
|
12
|
+
- **cmpt-huitu-utils 升级到 2.0.0**:移除了 parseTime 及所有时间处理功能
|
|
13
|
+
- 删除了 `parseTime.js` 文件及其所有导出函数
|
|
14
|
+
- 移除了 dayjs 依赖
|
|
15
|
+
- 如需时间处理功能,请在项目中直接安装并使用 dayjs
|
|
16
|
+
|
|
10
17
|
### Fixed
|
|
11
18
|
|
|
12
19
|
- 修复依赖转换逻辑:正确将 `workspace:*` 协议替换为 npm 版本号
|
|
@@ -23,16 +30,24 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
23
30
|
### Changed
|
|
24
31
|
|
|
25
32
|
- 优化成功提示信息:显示配置的依赖版本和后续操作步骤
|
|
26
|
-
-
|
|
33
|
+
- 更新模板文件:简化 home.vue,移除 parseTime 示例
|
|
27
34
|
- 改进文档:更新完整发布和使用指南,添加故障排查章节
|
|
35
|
+
- 更新依赖版本:cmpt-huitu-utils 升级到 ^2.0.0
|
|
36
|
+
- 简化模板依赖:移除 dayjs,减少项目体积
|
|
37
|
+
|
|
38
|
+
### Removed
|
|
39
|
+
|
|
40
|
+
- 模板中移除 dayjs 依赖(不再需要)
|
|
41
|
+
- 模板中移除 parseTime 使用示例
|
|
28
42
|
|
|
29
43
|
### Verified
|
|
30
44
|
|
|
31
45
|
- 端到端测试:验证项目创建、依赖安装、开发服务器启动、组件渲染、构建流程
|
|
32
|
-
- UI 组件集成:验证 VexTable、HTable
|
|
46
|
+
- UI 组件集成:验证 VexTable、HTable 组件正常工作
|
|
33
47
|
- 模板完整性:确认所有配置文件和示例代码完整
|
|
48
|
+
- 生产构建:验证 pnpm run build 成功执行
|
|
34
49
|
|
|
35
|
-
## [1.0.
|
|
50
|
+
## [1.0.7] - 2024-XX-XX
|
|
36
51
|
|
|
37
52
|
### Initial Release
|
|
38
53
|
|
package/package.json
CHANGED
package/src/versions.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@huitu-dev:registry=http://120.46.221.186:8081
|
|
@@ -12,7 +12,5 @@ declare module 'vue' {
|
|
|
12
12
|
Error: typeof import('./components/error/error.vue')['default']
|
|
13
13
|
Home: typeof import('./views/home.vue')['default']
|
|
14
14
|
Login: typeof import('./views/login/index.vue')['default']
|
|
15
|
-
RouterLink: typeof import('vue-router')['RouterLink']
|
|
16
|
-
RouterView: typeof import('vue-router')['RouterView']
|
|
17
15
|
}
|
|
18
16
|
}
|
|
@@ -22,18 +22,14 @@
|
|
|
22
22
|
</ul>
|
|
23
23
|
|
|
24
24
|
<div class="demo-section">
|
|
25
|
-
<h3
|
|
26
|
-
<p
|
|
25
|
+
<h3>组件演示</h3>
|
|
26
|
+
<p>VexTable 和 HTable 组件已成功集成</p>
|
|
27
27
|
</div>
|
|
28
28
|
</div>
|
|
29
29
|
</div>
|
|
30
30
|
</template>
|
|
31
31
|
|
|
32
32
|
<script setup>
|
|
33
|
-
import { ref, onMounted } from 'vue'
|
|
34
|
-
import { parseTime } from 'cmpt-huitu-utils'
|
|
35
|
-
|
|
36
|
-
const currentTime = ref('')
|
|
37
33
|
const columns = [
|
|
38
34
|
{ type: 'seq', title: '序号', width: 80 },
|
|
39
35
|
{ field: 'name', title: '姓名', width: 120 },
|
|
@@ -66,10 +62,6 @@
|
|
|
66
62
|
fixed: 'left',
|
|
67
63
|
},
|
|
68
64
|
]
|
|
69
|
-
|
|
70
|
-
onMounted(() => {
|
|
71
|
-
currentTime.value = parseTime(new Date(), 'YYYY-MM-DD HH:mm:ss')
|
|
72
|
-
})
|
|
73
65
|
</script>
|
|
74
66
|
|
|
75
67
|
<style scoped>
|
|
@@ -127,7 +127,7 @@ export default defineConfig(({ mode, command }) => {
|
|
|
127
127
|
// 将 CommonJS 模块转换为 ES 模块
|
|
128
128
|
transformMixedEsModules: true,
|
|
129
129
|
// 包含的 CommonJS 模块
|
|
130
|
-
include: [/xe-utils/, /vxe-table/],
|
|
130
|
+
include: [/xe-utils/, /vxe-table/, /node_modules/],
|
|
131
131
|
},
|
|
132
132
|
// 下面要配合 minify: 'terser',才能生效
|
|
133
133
|
// terserOptions: isProduction
|
|
@@ -153,7 +153,7 @@ export default defineConfig(({ mode, command }) => {
|
|
|
153
153
|
chunkFileNames: 'assets/js/[name]-[hash].js',
|
|
154
154
|
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
|
|
155
155
|
manualChunks: {
|
|
156
|
-
'x-vuelib': ['vue', 'vue-router', 'pinia', 'axios', '
|
|
156
|
+
'x-vuelib': ['vue', 'vue-router', 'pinia', 'axios', 'lodash-es'],
|
|
157
157
|
'x-eleuilib': ['element-plus'],
|
|
158
158
|
'x-vxetable': ['vxe-table', 'xe-utils'],
|
|
159
159
|
},
|
|
@@ -175,24 +175,7 @@ export default defineConfig(({ mode, command }) => {
|
|
|
175
175
|
|
|
176
176
|
// 优化依赖预构建(当你首次启动 vite 时,Vite 在本地加载你的站点之前预构建了项目依赖。)
|
|
177
177
|
optimizeDeps: {
|
|
178
|
-
include: [
|
|
179
|
-
'vue',
|
|
180
|
-
'vue-router',
|
|
181
|
-
'pinia',
|
|
182
|
-
'axios',
|
|
183
|
-
'element-plus',
|
|
184
|
-
'dayjs',
|
|
185
|
-
'dayjs/plugin/duration',
|
|
186
|
-
'dayjs/plugin/relativeTime',
|
|
187
|
-
'dayjs/plugin/isBetween',
|
|
188
|
-
'dayjs/plugin/weekday',
|
|
189
|
-
'dayjs/plugin/weekOfYear',
|
|
190
|
-
'dayjs/plugin/isSameOrBefore',
|
|
191
|
-
'dayjs/plugin/isSameOrAfter',
|
|
192
|
-
'dayjs/locale/zh-cn',
|
|
193
|
-
'vxe-table',
|
|
194
|
-
'xe-utils',
|
|
195
|
-
], // 默认情况下,不在 node_modules 中的,链接的包不会被预构建
|
|
178
|
+
include: ['vue', 'vue-router', 'pinia', 'axios', 'element-plus', 'vxe-table', 'xe-utils'], // 默认情况下,不在 node_modules 中的,链接的包不会被预构建
|
|
196
179
|
exclude: ['cmpt-huitu-ui', 'cmpt-huitu-utils'], // 在预构建中强制排除的依赖项
|
|
197
180
|
force: false, // 强制进行依赖预构建
|
|
198
181
|
esbuildOptions: {
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
# Template Configuration Verification Report
|
|
2
|
-
|
|
3
|
-
## ✅ Verification Status: PASSED
|
|
4
|
-
|
|
5
|
-
This document verifies that the template configuration meets all requirements for task 4.
|
|
6
|
-
|
|
7
|
-
## 1. UI Component Registration (main.js)
|
|
8
|
-
|
|
9
|
-
**File:** `src/main.js`
|
|
10
|
-
|
|
11
|
-
**Status:** ✅ VERIFIED
|
|
12
|
-
|
|
13
|
-
**Findings:**
|
|
14
|
-
|
|
15
|
-
- ✅ HuituUI is correctly imported from 'cmpt-huitu-ui'
|
|
16
|
-
- ✅ HuituUI is registered using `app.use(HuituUI)`
|
|
17
|
-
- ✅ HuituUtils is imported from 'cmpt-huitu-utils'
|
|
18
|
-
- ✅ Utils are mounted to global properties as `$utils`
|
|
19
|
-
- ✅ Element Plus is properly imported and registered
|
|
20
|
-
- ✅ Pinia and Vue Router are configured
|
|
21
|
-
|
|
22
|
-
**Code Verification:**
|
|
23
|
-
|
|
24
|
-
```javascript
|
|
25
|
-
import HuituUI from 'cmpt-huitu-ui'
|
|
26
|
-
import * as HuituUtils from 'cmpt-huitu-utils'
|
|
27
|
-
|
|
28
|
-
// Registration
|
|
29
|
-
app.use(HuituUI)
|
|
30
|
-
app.config.globalProperties.$utils = HuituUtils
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Requirements Met:** 2.5, 3.1
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## 2. Component Examples (home.vue)
|
|
38
|
-
|
|
39
|
-
**File:** `src/views/home.vue`
|
|
40
|
-
|
|
41
|
-
**Status:** ✅ VERIFIED
|
|
42
|
-
|
|
43
|
-
**Findings:**
|
|
44
|
-
|
|
45
|
-
- ✅ VexTable component is used with proper props (columns, data)
|
|
46
|
-
- ✅ HTable component is used with proper props (data, columns)
|
|
47
|
-
- ✅ parseTime utility function is imported and used
|
|
48
|
-
- ✅ Element Plus components (el-tag) are demonstrated
|
|
49
|
-
- ✅ Component demonstrates reactive data binding
|
|
50
|
-
- ✅ Proper lifecycle hooks (onMounted) are used
|
|
51
|
-
|
|
52
|
-
**Component Usage:**
|
|
53
|
-
|
|
54
|
-
```vue
|
|
55
|
-
<VexTable :columns="columns" :data="data" />
|
|
56
|
-
<HTable :data="data" :columns="hTableColumns" />
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
**Utils Usage:**
|
|
60
|
-
|
|
61
|
-
```javascript
|
|
62
|
-
import { parseTime } from 'cmpt-huitu-utils'
|
|
63
|
-
currentTime.value = parseTime(new Date(), 'YYYY-MM-DD HH:mm:ss')
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
**Requirements Met:** 2.3, 3.1, 3.2, 3.3, 3.4
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## 3. Path Alias Configuration (vite.config.js)
|
|
71
|
-
|
|
72
|
-
**File:** `vite.config.js`
|
|
73
|
-
|
|
74
|
-
**Status:** ✅ VERIFIED
|
|
75
|
-
|
|
76
|
-
**Findings:**
|
|
77
|
-
|
|
78
|
-
- ✅ '@' alias points to './src' directory
|
|
79
|
-
- ✅ All standard aliases are configured (@components, @views, @utils, etc.)
|
|
80
|
-
- ✅ Aliases match jsconfig.json configuration
|
|
81
|
-
- ✅ Extensions array includes .vue, .js, .jsx, .tsx, .json, .css, .scss
|
|
82
|
-
- ✅ CSS preprocessor configured for SCSS with UI package variables
|
|
83
|
-
- ✅ optimizeDeps excludes workspace packages correctly
|
|
84
|
-
|
|
85
|
-
**Alias Configuration:**
|
|
86
|
-
|
|
87
|
-
```javascript
|
|
88
|
-
resolve: {
|
|
89
|
-
alias: {
|
|
90
|
-
'@': resolve(__dirname, './src'),
|
|
91
|
-
'@components': resolve(__dirname, './src/components'),
|
|
92
|
-
'@views': resolve(__dirname, './src/views'),
|
|
93
|
-
'@utils': resolve(__dirname, './src/utils'),
|
|
94
|
-
// ... and more
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
**CSS Configuration:**
|
|
100
|
-
|
|
101
|
-
```javascript
|
|
102
|
-
css: {
|
|
103
|
-
preprocessorOptions: {
|
|
104
|
-
scss: {
|
|
105
|
-
additionalData: `
|
|
106
|
-
@use "cmpt-huitu-ui/src/styles/variables.scss" as *;
|
|
107
|
-
@use "cmpt-huitu-ui/src/styles/mixin.scss" as *;
|
|
108
|
-
`,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**Requirements Met:** 2.4
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
## 4. Required Configuration Files
|
|
119
|
-
|
|
120
|
-
**Status:** ✅ ALL PRESENT
|
|
121
|
-
|
|
122
|
-
### Core Configuration Files:
|
|
123
|
-
|
|
124
|
-
- ✅ `package.json` - Dependencies and scripts configured
|
|
125
|
-
- ✅ `vite.config.js` - Build and dev server configuration
|
|
126
|
-
- ✅ `jsconfig.json` - IDE path alias hints
|
|
127
|
-
- ✅ `eslint.config.js` - Code quality rules
|
|
128
|
-
- ✅ `index.html` - Entry HTML file
|
|
129
|
-
|
|
130
|
-
### Project Structure:
|
|
131
|
-
|
|
132
|
-
- ✅ `src/main.js` - Application entry point
|
|
133
|
-
- ✅ `src/app.vue` - Root component
|
|
134
|
-
- ✅ `src/views/home.vue` - Example page with components
|
|
135
|
-
- ✅ `src/routers/` - Router configuration
|
|
136
|
-
- ✅ `src/stores/` - Pinia store setup
|
|
137
|
-
- ✅ `src/utils/` - Utility functions
|
|
138
|
-
- ✅ `src/components/` - Reusable components
|
|
139
|
-
- ✅ `public/` - Static assets
|
|
140
|
-
|
|
141
|
-
### Additional Files:
|
|
142
|
-
|
|
143
|
-
- ✅ `README.md` - Project documentation
|
|
144
|
-
- ✅ `.prettierrc` - Code formatting rules
|
|
145
|
-
- ✅ `public/config/envCfg.js` - Environment configuration
|
|
146
|
-
|
|
147
|
-
**Requirements Met:** 2.2
|
|
148
|
-
|
|
149
|
-
---
|
|
150
|
-
|
|
151
|
-
## 5. Package Dependencies Verification
|
|
152
|
-
|
|
153
|
-
**File:** `package.json`
|
|
154
|
-
|
|
155
|
-
**Status:** ✅ VERIFIED
|
|
156
|
-
|
|
157
|
-
**Workspace Dependencies:**
|
|
158
|
-
|
|
159
|
-
```json
|
|
160
|
-
{
|
|
161
|
-
"cmpt-huitu-ui": "workspace:*",
|
|
162
|
-
"cmpt-huitu-utils": "workspace:*"
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
**Note:** These will be replaced with npm versions by the CLI create script.
|
|
167
|
-
|
|
168
|
-
**Peer Dependencies Present:**
|
|
169
|
-
|
|
170
|
-
- ✅ vue: ^3.5.18
|
|
171
|
-
- ✅ element-plus: ^2.11.1
|
|
172
|
-
- ✅ vxe-table: ^4.16.20
|
|
173
|
-
- ✅ xe-utils: ^3.5.0
|
|
174
|
-
- ✅ vue-router: ^4.5.1
|
|
175
|
-
- ✅ pinia: ^3.0.3
|
|
176
|
-
|
|
177
|
-
**Requirements Met:** 1.3, 1.4
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
## 6. UI Components Available
|
|
182
|
-
|
|
183
|
-
**From cmpt-huitu-ui package:**
|
|
184
|
-
|
|
185
|
-
- ✅ VexTable - Advanced data table component
|
|
186
|
-
- ✅ HTable - Standard table component
|
|
187
|
-
- ✅ HtDialog - Dialog component
|
|
188
|
-
|
|
189
|
-
**All components are:**
|
|
190
|
-
|
|
191
|
-
- ✅ Exported from the UI package
|
|
192
|
-
- ✅ Registered globally via app.use(HuituUI)
|
|
193
|
-
- ✅ Demonstrated in home.vue
|
|
194
|
-
|
|
195
|
-
---
|
|
196
|
-
|
|
197
|
-
## Summary
|
|
198
|
-
|
|
199
|
-
All template files are properly configured and meet the requirements:
|
|
200
|
-
|
|
201
|
-
1. ✅ UI components are correctly registered in main.js
|
|
202
|
-
2. ✅ Component examples are present in home.vue
|
|
203
|
-
3. ✅ Path aliases are properly configured in vite.config.js
|
|
204
|
-
4. ✅ All required configuration files exist
|
|
205
|
-
5. ✅ Dependencies are correctly specified
|
|
206
|
-
6. ✅ The template is ready for CLI distribution
|
|
207
|
-
|
|
208
|
-
**Next Steps:**
|
|
209
|
-
|
|
210
|
-
- The CLI create script will replace workspace:\* with actual npm versions
|
|
211
|
-
- Users can run `pnpm install` to install dependencies
|
|
212
|
-
- Users can run `pnpm dev` to start the development server
|
|
213
|
-
- All UI components will be immediately available for use
|
|
214
|
-
|
|
215
|
-
---
|
|
216
|
-
|
|
217
|
-
**Verification Date:** 2026-01-09 **Verified By:** Kiro CLI Optimization Task 4
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
# 修复 vxe-table 依赖问题
|
|
2
|
-
|
|
3
|
-
## 问题描述
|
|
4
|
-
|
|
5
|
-
执行 `pnpm dev` 后,终端报错:
|
|
6
|
-
```
|
|
7
|
-
[vite] Internal server error: Failed to resolve import "vxe-table" from "node_modules/.pnpm/cmpt-huitu-ui@1.0.1/node_modules/cmpt-huitu-ui/index.js?v=8ce970af". Does the file exist?
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
控制台报错:
|
|
11
|
-
```
|
|
12
|
-
GET http://localhost:3002/node_modules/.pnpm/cmpt-huitu-ui@1.0.1/node_modules/cmpt-huitu-ui/index.js?v=8ce970af net::ERR_ABORTED 500 (Internal Server Error)
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## 问题原因
|
|
16
|
-
|
|
17
|
-
`cmpt-huitu-ui` 包依赖 `vxe-table`,但项目的 `package.json` 中没有直接声明 `vxe-table` 依赖。在使用 pnpm 时,依赖提升机制可能没有正确提升 `vxe-table` 到项目的 `node_modules` 中,导致 Vite 无法解析该模块。
|
|
18
|
-
|
|
19
|
-
## 解决方案
|
|
20
|
-
|
|
21
|
-
### 方案 1:手动添加依赖(推荐)
|
|
22
|
-
|
|
23
|
-
在项目根目录执行:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
pnpm add vxe-table@^4.16.20
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
或者使用 npm:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npm install vxe-table@^4.16.20
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### 方案 2:修改 package.json
|
|
36
|
-
|
|
37
|
-
在项目的 `package.json` 的 `dependencies` 中添加:
|
|
38
|
-
|
|
39
|
-
```json
|
|
40
|
-
{
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"vxe-table": "^4.16.20",
|
|
43
|
-
// ... 其他依赖
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
然后执行:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
pnpm install
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### 方案 3:配置 pnpm 依赖提升(可选)
|
|
55
|
-
|
|
56
|
-
如果希望 pnpm 自动提升 `vxe-table`,可以在项目根目录创建 `.npmrc` 文件:
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
shamefully-hoist=true
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
然后重新安装依赖:
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
rm -rf node_modules pnpm-lock.yaml
|
|
66
|
-
pnpm install
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
**注意**:`shamefully-hoist=true` 会让 pnpm 的行为更像 npm,可能会增加 `node_modules` 的大小。
|
|
70
|
-
|
|
71
|
-
## 验证
|
|
72
|
-
|
|
73
|
-
修复后,检查以下内容:
|
|
74
|
-
|
|
75
|
-
1. ✅ `package.json` 中包含 `vxe-table` 依赖
|
|
76
|
-
2. ✅ `node_modules` 中存在 `vxe-table` 目录
|
|
77
|
-
3. ✅ 终端没有 `vxe-table` 相关错误
|
|
78
|
-
4. ✅ 页面正常加载
|
|
79
|
-
5. ✅ `VexTable` 组件可以正常使用
|
|
80
|
-
|
|
81
|
-
## 预防措施
|
|
82
|
-
|
|
83
|
-
**对于新创建的项目**:
|
|
84
|
-
|
|
85
|
-
模板已经更新,新创建的项目会自动包含 `vxe-table` 依赖,不会再出现此问题。
|
|
86
|
-
|
|
87
|
-
**对于已创建的项目**:
|
|
88
|
-
|
|
89
|
-
请按照上述方案手动添加 `vxe-table` 依赖。
|
|
90
|
-
|
|
91
|
-
## 相关依赖
|
|
92
|
-
|
|
93
|
-
`vxe-table` 的依赖关系:
|
|
94
|
-
- `vxe-table` 依赖 `xe-utils`
|
|
95
|
-
- `cmpt-huitu-ui` 依赖 `vxe-table`
|
|
96
|
-
|
|
97
|
-
因此,项目中需要同时安装:
|
|
98
|
-
- `vxe-table`(已通过模板添加)
|
|
99
|
-
- `xe-utils`(会自动作为 `vxe-table` 的依赖安装)
|
|
100
|
-
|
|
101
|
-
## 注意事项
|
|
102
|
-
|
|
103
|
-
- 确保 `vxe-table` 版本与 `cmpt-huitu-ui` 包中声明的版本兼容(当前为 `^4.16.20`)
|
|
104
|
-
- 如果使用 Monorepo,确保依赖正确安装
|
|
105
|
-
- 清理缓存后重新启动开发服务器
|
|
106
|
-
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
# 修复 xe-utils 导入错误
|
|
2
|
-
|
|
3
|
-
## 问题描述
|
|
4
|
-
|
|
5
|
-
执行 `pnpm dev` 后,控制台报错:
|
|
6
|
-
```
|
|
7
|
-
Uncaught SyntaxError: The requested module '/node_modules/.pnpm/xe-utils@3.8.3/node_modules/xe-utils/index.js?v=e03718de' does not provide an export named 'default' (at config.js?v=e03718de:1:8)
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
## 问题原因
|
|
11
|
-
|
|
12
|
-
`xe-utils` 是 `vxe-table` 的依赖,是一个 CommonJS 模块。在 Vite 的 ESM 环境下,需要正确预构建和转换。
|
|
13
|
-
|
|
14
|
-
## 解决方案
|
|
15
|
-
|
|
16
|
-
### 方案 1:清理缓存并重启(推荐先尝试)
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
# 1. 停止开发服务器(Ctrl+C)
|
|
20
|
-
|
|
21
|
-
# 2. 删除 Vite 缓存
|
|
22
|
-
rm -rf node_modules/.vite
|
|
23
|
-
|
|
24
|
-
# 3. 如果使用 pnpm,清理 pnpm 缓存
|
|
25
|
-
rm -rf node_modules/.pnpm
|
|
26
|
-
|
|
27
|
-
# 4. 重新安装依赖(可选,如果上述步骤无效)
|
|
28
|
-
pnpm install
|
|
29
|
-
|
|
30
|
-
# 5. 重新启动开发服务器
|
|
31
|
-
pnpm dev
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### 方案 2:检查 vite.config.js 配置
|
|
35
|
-
|
|
36
|
-
确保 `vite.config.js` 中包含以下配置:
|
|
37
|
-
|
|
38
|
-
```javascript
|
|
39
|
-
export default defineConfig({
|
|
40
|
-
// ... 其他配置
|
|
41
|
-
|
|
42
|
-
// 优化依赖预构建
|
|
43
|
-
optimizeDeps: {
|
|
44
|
-
include: [
|
|
45
|
-
// ... 其他依赖
|
|
46
|
-
'vxe-table',
|
|
47
|
-
'xe-utils',
|
|
48
|
-
],
|
|
49
|
-
exclude: ['cmpt-huitu-ui', 'cmpt-huitu-utils'],
|
|
50
|
-
esbuildOptions: {
|
|
51
|
-
format: 'esm',
|
|
52
|
-
supported: {
|
|
53
|
-
'dynamic-import': true,
|
|
54
|
-
'import-meta': true,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
// 路径解析配置
|
|
60
|
-
resolve: {
|
|
61
|
-
// ... 其他配置
|
|
62
|
-
dedupe: ['vxe-table', 'xe-utils'],
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
// 构建配置
|
|
66
|
-
build: {
|
|
67
|
-
// ... 其他配置
|
|
68
|
-
commonjsOptions: {
|
|
69
|
-
transformMixedEsModules: true,
|
|
70
|
-
include: [/xe-utils/, /vxe-table/],
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
})
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### 方案 3:如果上述方案无效,尝试强制重新构建
|
|
77
|
-
|
|
78
|
-
在 `vite.config.js` 中临时设置:
|
|
79
|
-
|
|
80
|
-
```javascript
|
|
81
|
-
optimizeDeps: {
|
|
82
|
-
// ... 其他配置
|
|
83
|
-
force: true, // 强制重新构建依赖
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
然后重启开发服务器。构建完成后,可以改回 `force: false`。
|
|
88
|
-
|
|
89
|
-
### 方案 4:检查 vxe-table 版本
|
|
90
|
-
|
|
91
|
-
如果问题仍然存在,可能是 `vxe-table` 版本与 `xe-utils` 版本不兼容。
|
|
92
|
-
|
|
93
|
-
检查 `cmpt-huitu-ui` 包中的 `vxe-table` 版本:
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
cd node_modules/cmpt-huitu-ui
|
|
97
|
-
cat package.json | grep vxe-table
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
如果版本过旧,可能需要更新 `cmpt-huitu-ui` 包。
|
|
101
|
-
|
|
102
|
-
### 方案 5:使用 Vite 插件(最后手段)
|
|
103
|
-
|
|
104
|
-
如果以上方案都无效,可以创建一个 Vite 插件来处理:
|
|
105
|
-
|
|
106
|
-
```javascript
|
|
107
|
-
// vite/plugins/fixXeUtils.js
|
|
108
|
-
export default function fixXeUtils() {
|
|
109
|
-
return {
|
|
110
|
-
name: 'fix-xe-utils',
|
|
111
|
-
enforce: 'pre',
|
|
112
|
-
resolveId(id) {
|
|
113
|
-
if (id === 'xe-utils') {
|
|
114
|
-
return id
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
load(id) {
|
|
118
|
-
if (id === 'xe-utils') {
|
|
119
|
-
// 返回一个包装的 ESM 模块
|
|
120
|
-
return `
|
|
121
|
-
import * as xeUtils from 'xe-utils'
|
|
122
|
-
export default xeUtils
|
|
123
|
-
export * from 'xe-utils'
|
|
124
|
-
`
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
然后在 `vite.config.js` 中使用:
|
|
132
|
-
|
|
133
|
-
```javascript
|
|
134
|
-
import fixXeUtils from './vite/plugins/fixXeUtils'
|
|
135
|
-
|
|
136
|
-
export default defineConfig({
|
|
137
|
-
plugins: [
|
|
138
|
-
// ... 其他插件
|
|
139
|
-
fixXeUtils(),
|
|
140
|
-
],
|
|
141
|
-
// ... 其他配置
|
|
142
|
-
})
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
## 验证
|
|
146
|
-
|
|
147
|
-
修复后,检查以下内容:
|
|
148
|
-
|
|
149
|
-
1. ✅ 控制台没有 `xe-utils` 相关错误
|
|
150
|
-
2. ✅ 页面正常加载
|
|
151
|
-
3. ✅ `VexTable` 组件可以正常使用
|
|
152
|
-
|
|
153
|
-
## 注意事项
|
|
154
|
-
|
|
155
|
-
- 如果使用 Monorepo,确保 `cmpt-huitu-ui` 包已正确发布并安装
|
|
156
|
-
- 清理缓存后,首次启动可能会较慢(需要重新预构建依赖)
|
|
157
|
-
- 如果问题持续存在,可能需要检查 `vxe-table` 和 `xe-utils` 的版本兼容性
|
|
158
|
-
|