@liujitcn/kratos-admin-core 0.0.41 → 0.0.43

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.
@@ -1,11 +1,13 @@
1
1
  import type { HotPayload, Plugin, WebSocketClient } from "vite";
2
2
 
3
3
  /** 暂缓生成期间的开发热更新,释放后统一刷新以加载完整产物。 */
4
- export function codegenHmrPlugin(): Plugin {
4
+ export function codegenHmrPlugin(sourceRoots: string[] = []): Plugin {
5
5
  return {
6
6
  name: "admin-codegen-hmr",
7
7
  apply: "serve",
8
8
  configureServer(server) {
9
+ // 模块源码位于宿主 root 外,监听目录才能发现新生成的页面。
10
+ server.watcher.add(sourceRoots);
9
11
  const clients = new Set<WebSocketClient>();
10
12
  const send = server.ws.send.bind(server.ws);
11
13
  let pending = false;
package/build/plugins.ts CHANGED
@@ -20,6 +20,8 @@ import autoImports from "./auto-imports.json";
20
20
  * Vite 插件扩展配置。
21
21
  */
22
22
  interface VitePluginOptions {
23
+ /** 需要监听新增文件的宿主与业务模块源码目录。 */
24
+ sourceRoots?: string[];
23
25
  /** 组合构建时需要处理的源码路径。 */
24
26
  sourcePatterns?: RegExp[];
25
27
  /** 自动导入声明文件输出位置,false 表示不生成。 */
@@ -38,13 +40,13 @@ export const createVitePlugins = (viteEnv: ViteEnv, options: VitePluginOptions =
38
40
  const { VITE_GLOB_APP_TITLE, VITE_REPORT, VITE_DEVTOOLS, VITE_PWA, VITE_CODEINSPECTOR } = viteEnv;
39
41
  const sourcePatterns = options.sourcePatterns;
40
42
  return [
41
- codegenHmrPlugin(),
43
+ codegenHmrPlugin(options.sourceRoots),
42
44
  vue(),
43
45
  // vue 可以使用 jsx/tsx 语法
44
46
  vueJsx(),
45
47
  // 自动导入 Vue、Element Plus API 与图标,减少页面重复 import
46
48
  AutoImport({
47
- dts: options.autoImportDts ?? "types/generated/auto-imports.d.ts",
49
+ dts: options.autoImportDts ?? false,
48
50
  include: sourcePatterns,
49
51
  exclude: sourcePatterns ? [/[/\\]\.git[/\\]/] : undefined,
50
52
  resolvers: [ElementPlusResolver()],
@@ -52,7 +54,7 @@ export const createVitePlugins = (viteEnv: ViteEnv, options: VitePluginOptions =
52
54
  }),
53
55
  // 按需解析 Element Plus 组件,避免主入口全量安装 ElementPlus。
54
56
  Components({
55
- dts: options.componentDts ?? "types/generated/components.d.ts",
57
+ dts: options.componentDts ?? false,
56
58
  dirs: [],
57
59
  include: sourcePatterns,
58
60
  exclude: sourcePatterns ? [/[/\\]\.git[/\\]/] : undefined,
@@ -1,3 +1,3 @@
1
1
  import type { Plugin } from "vite";
2
2
  /** 暂缓生成期间的开发热更新,释放后统一刷新以加载完整产物。 */
3
- export declare function codegenHmrPlugin(): Plugin;
3
+ export declare function codegenHmrPlugin(sourceRoots?: string[]): Plugin;
@@ -3,6 +3,8 @@ import { PluginOption } from "vite";
3
3
  * Vite 插件扩展配置。
4
4
  */
5
5
  interface VitePluginOptions {
6
+ /** 需要监听新增文件的宿主与业务模块源码目录。 */
7
+ sourceRoots?: string[];
6
8
  /** 组合构建时需要处理的源码路径。 */
7
9
  sourcePatterns?: RegExp[];
8
10
  /** 自动导入声明文件输出位置,false 表示不生成。 */
@@ -25,6 +25,7 @@ declare module 'vue' {
25
25
  ElCollapse: typeof import('element-plus/es')['ElCollapse']
26
26
  ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
27
27
  ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
28
+ ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
28
29
  ElContainer: typeof import('element-plus/es')['ElContainer']
29
30
  ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
30
31
  ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@liujitcn/kratos-admin-core",
3
3
  "private": false,
4
- "version": "0.0.41",
4
+ "version": "0.0.43",
5
5
  "type": "module",
6
6
  "description": "kratos-admin frontend runtime and base modules",
7
7
  "author": {
@@ -224,7 +224,7 @@
224
224
  "scripts": {
225
225
  "build": "pnpm build:package",
226
226
  "build:package": "node ../../scripts/build-package.mjs .",
227
- "test": "tsc -p tsconfig.test.json && node --test dist/test/tests/modules.test.js dist/test/tests/dict.test.js dist/test/tests/menu.test.js dist/test/tests/source-patterns.test.js",
227
+ "test": "tsc -p tsconfig.test.json && node --test dist/test/tests/modules.test.js dist/test/tests/dict.test.js dist/test/tests/menu.test.js dist/test/tests/source-patterns.test.js dist/test/tests/codegen-hmr.test.js",
228
228
  "type:check": "vue-tsc --noEmit --skipLibCheck"
229
229
  }
230
230
  }
@@ -25,6 +25,7 @@ declare module 'vue' {
25
25
  ElCollapse: typeof import('element-plus/es')['ElCollapse']
26
26
  ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
27
27
  ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
28
+ ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
28
29
  ElContainer: typeof import('element-plus/es')['ElContainer']
29
30
  ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
30
31
  ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
package/vite.config.ts CHANGED
@@ -113,6 +113,7 @@ export function defineAdminViteConfig(options: AdminViteConfigOptions = {}) {
113
113
  proxy: createProxy(viteEnv.VITE_PROXY)
114
114
  },
115
115
  plugins: createVitePlugins(viteEnv, {
116
+ sourceRoots,
116
117
  sourcePatterns,
117
118
  autoImportDts: false,
118
119
  componentDts: options.componentDts ?? false,