niuma-ui 1.3.1 → 1.3.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/CHANGELOG.md
CHANGED
package/dist/lib/rs-dayjs.js
CHANGED
|
@@ -19,6 +19,14 @@ export type NiumaUiBinding = {
|
|
|
19
19
|
* serve 改写具名导入到源码并 alias styles;build 只补 Tailwind @source。
|
|
20
20
|
*/
|
|
21
21
|
export declare function niumaUiHost(options?: NiumaUiHostOptions): Plugin[];
|
|
22
|
+
/**
|
|
23
|
+
* DayjsServeAliases 把 CJS 插件指到 ESM 构建。
|
|
24
|
+
* 发布桶 / 源码被 exclude 后,Vite 否则会按 ESM 加载 UMD,报没有 default。
|
|
25
|
+
*/
|
|
26
|
+
export declare function dayjsServeAliases(root: string): {
|
|
27
|
+
find: RegExp;
|
|
28
|
+
replacement: string;
|
|
29
|
+
}[];
|
|
22
30
|
/**
|
|
23
31
|
* ToSourceRel 把目录收成 Tailwind @source 可用的相对路径。
|
|
24
32
|
*/
|
|
@@ -30,7 +30,40 @@ export function niumaUiHost(options = {}) {
|
|
|
30
30
|
return [niumaUiHostAlias(ctx), niumaUiHostRewrite(ctx), niumaUiHostTailwindSource(ctx)];
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* DayjsServeAliases 把 CJS 插件指到 ESM 构建。
|
|
34
|
+
* 发布桶 / 源码被 exclude 后,Vite 否则会按 ESM 加载 UMD,报没有 default。
|
|
35
|
+
*/
|
|
36
|
+
export function dayjsServeAliases(root) {
|
|
37
|
+
let req;
|
|
38
|
+
try {
|
|
39
|
+
req = createRequire(join(root, 'package.json'));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
const aliases = [];
|
|
45
|
+
try {
|
|
46
|
+
aliases.push({
|
|
47
|
+
find: /^dayjs\/plugin\/customParseFormat(?:\.js)?$/,
|
|
48
|
+
replacement: req.resolve('dayjs/esm/plugin/customParseFormat'),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// dayjs 未装在包旁时跳过
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
aliases.push({
|
|
56
|
+
find: /^dayjs$/,
|
|
57
|
+
replacement: req.resolve('dayjs/esm'),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// dayjs 未装在包旁时跳过
|
|
62
|
+
}
|
|
63
|
+
return aliases;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* NiumaUiHostAlias 仅在 serve 时补 dayjs ESM 别名;有 src 时再改 styles 并排除整桶预构建。
|
|
34
67
|
*/
|
|
35
68
|
function niumaUiHostAlias(ctx) {
|
|
36
69
|
return {
|
|
@@ -38,15 +71,20 @@ function niumaUiHostAlias(ctx) {
|
|
|
38
71
|
apply: 'serve',
|
|
39
72
|
enforce: 'pre',
|
|
40
73
|
config() {
|
|
41
|
-
|
|
42
|
-
|
|
74
|
+
const dayjsAlias = dayjsServeAliases(ctx.root);
|
|
75
|
+
if (!ctx.hasSrc) {
|
|
76
|
+
return dayjsAlias.length > 0 ? { resolve: { alias: dayjsAlias } } : {};
|
|
77
|
+
}
|
|
43
78
|
const styles = join(ctx.root, 'src/styles.css');
|
|
44
|
-
const alias =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
79
|
+
const alias = [
|
|
80
|
+
...(existsSync(styles)
|
|
81
|
+
? [
|
|
82
|
+
{ find: '@niuma/ui/styles.css', replacement: styles },
|
|
83
|
+
{ find: 'niuma-ui/styles.css', replacement: styles },
|
|
84
|
+
]
|
|
85
|
+
: []),
|
|
86
|
+
...dayjsAlias,
|
|
87
|
+
];
|
|
50
88
|
return {
|
|
51
89
|
resolve: alias.length > 0 ? { alias } : {},
|
|
52
90
|
// 不要把 reka-ui / @lucide/vue / vue-sonner 写进 include:
|