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
@@ -6,6 +6,12 @@
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.3.2] - 2026-09-09
10
+
11
+ ### 修复
12
+
13
+ - `rs-dayjs`:插件改从 `dayjs/esm` 引入。宿主 `optimizeDeps.exclude` `@niuma/ui` 时,Vite 不再把 CJS UMD 插件当成缺少 `default` 的 ESM。
14
+
9
15
  ## [1.3.1] - 2026-09-09
10
16
 
11
17
  ### 修复
@@ -1,5 +1,5 @@
1
1
  import dayjs from "dayjs";
2
- import customParseFormat from "dayjs/plugin/customParseFormat";
2
+ import customParseFormat from "dayjs/esm/plugin/customParseFormat";
3
3
  //#region src/lib/rs-dayjs.ts
4
4
  dayjs.extend(customParseFormat);
5
5
  /** 日期 v-model / 展示格式 */
@@ -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
- * NiumaUiHostAlias 仅在 serve 且存在 src 时把 styles.css 指到源码,并排除整桶预构建。
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
- if (!ctx.hasSrc)
42
- return {};
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 = existsSync(styles)
45
- ? [
46
- { find: '@niuma/ui/styles.css', replacement: styles },
47
- { find: 'niuma-ui/styles.css', replacement: styles },
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:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "niuma-ui",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "Vue 3 工作台设计系统(Rs* 组件、--rs-* token;含可选编辑器 / 终端)",