@sdata/web-vue-auto-import-resolver 1.0.0 → 1.15.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/CHANGELOG.md +6 -0
- package/README.md +5 -9
- package/index.d.ts +5 -7
- package/index.js +4 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [1.14.1](https://github.com/liunnn1994/sd-design/compare/v1.14.0...v1.14.1) (2026-05-20)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- 🐛 typecheck 缺图标问题 ([150436f](https://github.com/liunnn1994/sd-design/commit/150436f936f66ac889d5cd8f14ae0ab188e196f2))
|
|
6
|
+
|
|
1
7
|
# Changelog
|
|
2
8
|
|
|
3
9
|
All notable changes to this package will be documented in this file.
|
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
解析器会在运行时读取已安装的 `@sdata/web-vue` 发布产物来识别组件导出和样式入口,因此新增组件后不需要再维护额外的组件映射文件。
|
|
6
6
|
|
|
7
|
+
当前解析器仅面向模板自动导入场景,不支持 SSR。
|
|
8
|
+
|
|
7
9
|
## 安装
|
|
8
10
|
|
|
9
11
|
```bash
|
|
@@ -17,14 +19,14 @@ pnpm add -D @sdata/web-vue-auto-import-resolver unplugin-vue-components
|
|
|
17
19
|
import { defineConfig } from 'vite';
|
|
18
20
|
import vue from '@vitejs/plugin-vue';
|
|
19
21
|
import Components from 'unplugin-vue-components/vite';
|
|
20
|
-
import {
|
|
22
|
+
import { SdDesignResolver } from '@sdata/web-vue-auto-import-resolver';
|
|
21
23
|
|
|
22
24
|
export default defineConfig({
|
|
23
25
|
plugins: [
|
|
24
26
|
vue(),
|
|
25
27
|
Components({
|
|
26
28
|
resolvers: [
|
|
27
|
-
|
|
29
|
+
SdDesignResolver({
|
|
28
30
|
sideEffect: true,
|
|
29
31
|
}),
|
|
30
32
|
],
|
|
@@ -38,17 +40,11 @@ export default defineConfig({
|
|
|
38
40
|
## 选项
|
|
39
41
|
|
|
40
42
|
```ts
|
|
41
|
-
interface
|
|
43
|
+
interface SdDesignResolverOptions {
|
|
42
44
|
prefix?: string;
|
|
43
45
|
sideEffect?: boolean;
|
|
44
|
-
importStyle?: boolean;
|
|
45
46
|
}
|
|
46
47
|
```
|
|
47
48
|
|
|
48
49
|
- `prefix`:组件前缀,默认是 `Sd`,对应模板里的 `<sd-button />`。
|
|
49
50
|
- `sideEffect`:是否自动导入组件样式。
|
|
50
|
-
- `importStyle`:`sideEffect` 的别名,便于迁移旧配置。
|
|
51
|
-
|
|
52
|
-
## 兼容导出
|
|
53
|
-
|
|
54
|
-
包同时导出 `SDataResolver` 和 `SDResolver`。新项目建议使用 `SDataResolver`,已有文档或脚手架可以继续使用 `SDResolver`。
|
package/index.d.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { ComponentResolveResult, ComponentResolver } from 'unplugin-vue-components/types';
|
|
2
2
|
|
|
3
|
-
interface
|
|
3
|
+
interface SdDesignComponentMeta {
|
|
4
4
|
importName: string;
|
|
5
5
|
from: string;
|
|
6
6
|
sideEffects?: string;
|
|
7
7
|
}
|
|
8
|
-
interface
|
|
8
|
+
interface SdDesignResolverOptions {
|
|
9
9
|
prefix?: string;
|
|
10
10
|
sideEffect?: boolean;
|
|
11
|
-
|
|
12
|
-
resolve?: (meta: SDataComponentMeta, type: 'component') => ComponentResolveResult | undefined;
|
|
11
|
+
resolve?: (meta: SdDesignComponentMeta, type: 'component') => ComponentResolveResult | undefined;
|
|
13
12
|
}
|
|
14
|
-
declare function
|
|
15
|
-
declare const SDResolver: typeof SDataResolver;
|
|
13
|
+
declare function SdDesignResolver(options?: SdDesignResolverOptions): ComponentResolver[];
|
|
16
14
|
|
|
17
|
-
export {
|
|
15
|
+
export { type SdDesignComponentMeta, SdDesignResolver, type SdDesignResolverOptions };
|
package/index.js
CHANGED
|
@@ -86,13 +86,13 @@ var getComponentMetaMap = () => {
|
|
|
86
86
|
return componentMap;
|
|
87
87
|
};
|
|
88
88
|
var resolveSideEffects = (meta, options) => {
|
|
89
|
-
const
|
|
90
|
-
if (!
|
|
89
|
+
const shouldIncludeSideEffects = options.sideEffect ?? false;
|
|
90
|
+
if (!shouldIncludeSideEffects || !meta.sideEffects) {
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
return meta.sideEffects;
|
|
94
94
|
};
|
|
95
|
-
function
|
|
95
|
+
function SdDesignResolver(options = {}) {
|
|
96
96
|
const prefix = options.prefix ?? DEFAULT_PREFIX;
|
|
97
97
|
return [
|
|
98
98
|
{
|
|
@@ -115,8 +115,6 @@ function SDataResolver(options = {}) {
|
|
|
115
115
|
}
|
|
116
116
|
];
|
|
117
117
|
}
|
|
118
|
-
var SDResolver = SDataResolver;
|
|
119
118
|
export {
|
|
120
|
-
|
|
121
|
-
SDataResolver
|
|
119
|
+
SdDesignResolver
|
|
122
120
|
};
|