@origen-ui/admin-cli 1.0.3 → 2.0.1

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.
Files changed (237) hide show
  1. package/README.md +11 -7
  2. package/package.json +19 -3
  3. package/templates/current/clean/CHANGELOG.md +137 -0
  4. package/templates/current/clean/component-catalog.json +58 -17
  5. package/templates/current/clean/e2e/admin-shell.spec.ts +6 -0
  6. package/templates/current/clean/e2e/demo-shell.spec.ts +90 -46
  7. package/templates/current/clean/package.json +55 -41
  8. package/templates/current/clean/playwright.config.ts +1 -0
  9. package/templates/current/clean/playwright.demo.config.ts +1 -1
  10. package/templates/current/clean/scaffold.lock.json +2 -2
  11. package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue +7 -2
  12. package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/NotFound.vue +7 -2
  13. package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/ServerError.vue +7 -2
  14. package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts +11 -2
  15. package/templates/current/clean/scripts/clean-overlay/src/main.ts +23 -14
  16. package/templates/current/clean/scripts/clean-overlay/src/router/componentCache.ts +12 -0
  17. package/templates/current/clean/scripts/clean-overlay/src/router/componentRegistry.ts +2 -13
  18. package/templates/current/clean/scripts/clean-overlay/src/router/dynamicRoutes.spec.ts +34 -4
  19. package/templates/current/clean/scripts/clean-overlay/src/router/paths.ts +21 -0
  20. package/templates/current/clean/scripts/clean-overlay/src/router/staticRoutes.ts +6 -6
  21. package/templates/current/clean/scripts/demo-api.ts +84 -8
  22. package/templates/current/clean/scripts/generate-api.ts +87 -3
  23. package/templates/current/clean/scripts/vite-build-policy.spec.ts +72 -0
  24. package/templates/current/clean/src/App.vue +10 -3
  25. package/templates/current/clean/src/api/client.ts +90 -10
  26. package/templates/current/clean/src/api/generated/data-contracts.ts +0 -3
  27. package/templates/current/clean/src/api/generated/http-client.ts +28 -26
  28. package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/206/205/345/256/271/346/226/207/347/253/240.ts +5 -8
  29. package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/256/241/350/256/241.ts +1 -4
  30. package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/346/226/207/344/273/266/344/270/212/344/274/240.ts +2 -5
  31. package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/347/224/250/346/210/267.ts +6 -9
  32. package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/217/234/345/215/225.ts +7 -10
  33. package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/247/222/350/211/262.ts +6 -9
  34. package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/256/242/345/215/225/350/215/211/347/250/277.ts +6 -9
  35. package/templates/current/clean/src/api/generated//350/256/244/350/257/201.ts +3 -6
  36. package/templates/current/clean/src/app/adminLocale.ts +90 -0
  37. package/templates/current/clean/src/app/createAdminUi.spec.ts +65 -9
  38. package/templates/current/clean/src/app/createAdminUi.ts +14 -29
  39. package/templates/current/clean/src/app/embedded-token.spec.ts +40 -0
  40. package/templates/current/clean/src/app/embedded.spec.ts +135 -0
  41. package/templates/current/clean/src/app/embedded.ts +255 -0
  42. package/templates/current/clean/src/app/errorMessage.spec.ts +76 -0
  43. package/templates/current/clean/src/app/errorMessage.ts +53 -0
  44. package/templates/current/clean/src/app/localeFormat.ts +52 -0
  45. package/templates/current/clean/src/app/menu-host.spec.ts +77 -0
  46. package/templates/current/clean/src/app/menu.spec.ts +65 -0
  47. package/templates/current/clean/src/app/menu.ts +52 -12
  48. package/templates/current/clean/src/app/menuTypes.ts +1 -0
  49. package/templates/current/clean/src/app/origenUiLocale.spec.ts +6 -5
  50. package/templates/current/clean/src/app/origenUiLocale.ts +3 -58
  51. package/templates/current/clean/src/app/permission.spec.ts +26 -0
  52. package/templates/current/clean/src/app/runtimeConfig.ts +9 -8
  53. package/templates/current/clean/src/demo-api.spec.ts +311 -0
  54. package/templates/current/clean/src/env.d.ts +18 -0
  55. package/templates/current/clean/src/features/appearance/components/ThemePanel.vue +21 -17
  56. package/templates/current/clean/src/features/appearance/store/theme.ts +2 -1
  57. package/templates/current/clean/src/features/auth/pages/Login.vue +22 -12
  58. package/templates/current/clean/src/features/auth/store/auth.ts +6 -9
  59. package/templates/current/clean/src/features/errors/pages/Forbidden.vue +7 -2
  60. package/templates/current/clean/src/features/errors/pages/NotFound.vue +7 -2
  61. package/templates/current/clean/src/features/errors/pages/ServerError.vue +7 -2
  62. package/templates/current/clean/src/features/errors/pages/error-pages.spec.ts +11 -2
  63. package/templates/current/clean/src/features/security/components/DevtoolsProtectionOverlay.vue +5 -2
  64. package/templates/current/clean/src/features/security/devtoolsProtection.spec.ts +7 -10
  65. package/templates/current/clean/src/features/security/devtoolsProtection.ts +2 -1
  66. package/templates/current/clean/src/features/system/access/api/admin-repository.spec.ts +14 -0
  67. package/templates/current/clean/src/features/system/access/api/admin-repository.ts +34 -15
  68. package/templates/current/clean/src/features/system/access/api/rbac.ts +52 -32
  69. package/templates/current/clean/src/features/system/access/composables/useAuthorizationPolling.spec.ts +134 -0
  70. package/templates/current/clean/src/features/system/access/composables/useAuthorizationPolling.ts +96 -0
  71. package/templates/current/clean/src/features/workspace/pages/Empty.vue +4 -1
  72. package/templates/current/clean/src/features/workspace/pages/Profile.vue +14 -12
  73. package/templates/current/clean/src/layouts/AdminLayout.vue +6 -1
  74. package/templates/current/clean/src/layouts/TopBar.vue +60 -11
  75. package/templates/current/clean/src/layouts/topBarMenuSearch.spec.ts +24 -1
  76. package/templates/current/clean/src/layouts/topBarMenuSearch.ts +10 -0
  77. package/templates/current/clean/src/locales/en-US.json +517 -0
  78. package/templates/current/clean/src/locales/en-US.runtime.ts +22 -0
  79. package/templates/current/clean/src/locales/index.ts +144 -47
  80. package/templates/current/clean/src/locales/messages-types.ts +62 -0
  81. package/templates/current/clean/src/locales/messages.spec.ts +113 -6
  82. package/templates/current/clean/src/locales/vue-i18n.d.ts +5 -0
  83. package/templates/current/clean/src/locales/zh-CN.json +517 -0
  84. package/templates/current/clean/src/locales/zh-CN.runtime.ts +22 -0
  85. package/templates/current/clean/src/locales/zh-TW.json +517 -0
  86. package/templates/current/clean/src/locales/zh-TW.runtime.ts +22 -0
  87. package/templates/current/clean/src/main.ts +23 -14
  88. package/templates/current/clean/src/router/bootstrap.ts +20 -11
  89. package/templates/current/clean/src/router/componentCache.ts +12 -0
  90. package/templates/current/clean/src/router/componentRegistry.ts +2 -13
  91. package/templates/current/clean/src/router/dynamicMenuRefresh.spec.ts +101 -0
  92. package/templates/current/clean/src/router/dynamicMenuRefresh.ts +24 -0
  93. package/templates/current/clean/src/router/dynamicRoutes.spec.ts +34 -4
  94. package/templates/current/clean/src/router/dynamicRoutes.ts +19 -4
  95. package/templates/current/clean/src/router/paths.spec.ts +50 -0
  96. package/templates/current/clean/src/router/paths.ts +21 -0
  97. package/templates/current/clean/src/router/queryEncryption.spec.ts +30 -4
  98. package/templates/current/clean/src/router/queryEncryption.ts +48 -44
  99. package/templates/current/clean/src/router/staticRoutes.ts +6 -6
  100. package/templates/current/clean/src/router/useRouteQueryDefaults.spec.ts +2 -1
  101. package/templates/current/clean/src/router/useRouteQueryDefaults.types.ts +2 -1
  102. package/templates/current/clean/src/templates/og-table.ts +79 -37
  103. package/templates/current/clean/src/templates/templates.spec.ts +19 -0
  104. package/templates/current/clean/tsconfig.json +0 -1
  105. package/templates/current/clean/vite.build-policy.ts +161 -289
  106. package/templates/current/clean/vite.config.ts +34 -5
  107. package/templates/current/examples/CHANGELOG.md +137 -0
  108. package/templates/current/examples/component-catalog.json +58 -17
  109. package/templates/current/examples/e2e/admin-shell.spec.ts +6 -0
  110. package/templates/current/examples/e2e/demo-shell.spec.ts +90 -46
  111. package/templates/current/examples/package.json +55 -41
  112. package/templates/current/examples/playwright.config.ts +1 -0
  113. package/templates/current/examples/playwright.demo.config.ts +1 -1
  114. package/templates/current/examples/scaffold.lock.json +2 -2
  115. package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue +7 -2
  116. package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/NotFound.vue +7 -2
  117. package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/ServerError.vue +7 -2
  118. package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts +11 -2
  119. package/templates/current/examples/scripts/clean-overlay/src/main.ts +23 -14
  120. package/templates/current/examples/scripts/clean-overlay/src/router/componentCache.ts +12 -0
  121. package/templates/current/examples/scripts/clean-overlay/src/router/componentRegistry.ts +2 -13
  122. package/templates/current/examples/scripts/clean-overlay/src/router/dynamicRoutes.spec.ts +34 -4
  123. package/templates/current/examples/scripts/clean-overlay/src/router/paths.ts +21 -0
  124. package/templates/current/examples/scripts/clean-overlay/src/router/staticRoutes.ts +6 -6
  125. package/templates/current/examples/scripts/demo-api.ts +84 -8
  126. package/templates/current/examples/scripts/generate-api.ts +87 -3
  127. package/templates/current/examples/scripts/vite-build-policy.spec.ts +72 -0
  128. package/templates/current/examples/src/App.vue +10 -3
  129. package/templates/current/examples/src/api/client.ts +90 -10
  130. package/templates/current/examples/src/api/generated/data-contracts.ts +0 -3
  131. package/templates/current/examples/src/api/generated/http-client.ts +28 -26
  132. package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/206/205/345/256/271/346/226/207/347/253/240.ts +5 -8
  133. package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/256/241/350/256/241.ts +1 -4
  134. package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/346/226/207/344/273/266/344/270/212/344/274/240.ts +2 -5
  135. package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/347/224/250/346/210/267.ts +6 -9
  136. package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/217/234/345/215/225.ts +7 -10
  137. package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/247/222/350/211/262.ts +6 -9
  138. package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/256/242/345/215/225/350/215/211/347/250/277.ts +6 -9
  139. package/templates/current/examples/src/api/generated//350/256/244/350/257/201.ts +3 -6
  140. package/templates/current/examples/src/app/adminLocale.ts +90 -0
  141. package/templates/current/examples/src/app/createAdminUi.spec.ts +65 -9
  142. package/templates/current/examples/src/app/createAdminUi.ts +14 -29
  143. package/templates/current/examples/src/app/embedded-token.spec.ts +40 -0
  144. package/templates/current/examples/src/app/embedded.spec.ts +135 -0
  145. package/templates/current/examples/src/app/embedded.ts +255 -0
  146. package/templates/current/examples/src/app/errorMessage.spec.ts +76 -0
  147. package/templates/current/examples/src/app/errorMessage.ts +53 -0
  148. package/templates/current/examples/src/app/localeFormat.ts +52 -0
  149. package/templates/current/examples/src/app/menu-host.spec.ts +77 -0
  150. package/templates/current/examples/src/app/menu.spec.ts +65 -0
  151. package/templates/current/examples/src/app/menu.ts +52 -12
  152. package/templates/current/examples/src/app/menuTypes.ts +1 -0
  153. package/templates/current/examples/src/app/origenUiLocale.spec.ts +6 -5
  154. package/templates/current/examples/src/app/origenUiLocale.ts +3 -58
  155. package/templates/current/examples/src/app/permission.spec.ts +26 -0
  156. package/templates/current/examples/src/app/runtimeConfig.ts +9 -8
  157. package/templates/current/examples/src/demo-api.spec.ts +311 -0
  158. package/templates/current/examples/src/env.d.ts +18 -0
  159. package/templates/current/examples/src/features/appearance/components/ThemePanel.vue +21 -17
  160. package/templates/current/examples/src/features/appearance/store/theme.ts +2 -1
  161. package/templates/current/examples/src/features/auth/pages/Login.vue +22 -12
  162. package/templates/current/examples/src/features/auth/store/auth.ts +6 -9
  163. package/templates/current/examples/src/features/errors/pages/Forbidden.vue +7 -2
  164. package/templates/current/examples/src/features/errors/pages/NotFound.vue +7 -2
  165. package/templates/current/examples/src/features/errors/pages/ServerError.vue +7 -2
  166. package/templates/current/examples/src/features/errors/pages/error-pages.spec.ts +9 -1
  167. package/templates/current/examples/src/features/feature-composables.spec.ts +47 -10
  168. package/templates/current/examples/src/features/security/components/DevtoolsProtectionOverlay.vue +5 -2
  169. package/templates/current/examples/src/features/security/devtoolsProtection.spec.ts +7 -10
  170. package/templates/current/examples/src/features/security/devtoolsProtection.ts +2 -1
  171. package/templates/current/examples/src/features/system/access/api/admin-repository.spec.ts +14 -0
  172. package/templates/current/examples/src/features/system/access/api/admin-repository.ts +34 -15
  173. package/templates/current/examples/src/features/system/access/api/rbac.ts +52 -32
  174. package/templates/current/examples/src/features/system/access/composables/useAuthorizationPolling.spec.ts +134 -0
  175. package/templates/current/examples/src/features/system/access/composables/useAuthorizationPolling.ts +96 -0
  176. package/templates/current/examples/src/features/system/audit/composables/useAuditManagement.ts +43 -38
  177. package/templates/current/examples/src/features/system/menus/components/MenuEditorForm.vue +137 -47
  178. package/templates/current/examples/src/features/system/menus/composables/useMenuManagement.ts +215 -107
  179. package/templates/current/examples/src/features/system/menus/menuDraft.spec.ts +204 -0
  180. package/templates/current/examples/src/features/system/menus/menuDraft.ts +116 -0
  181. package/templates/current/examples/src/features/system/menus/menuTreePrecheck.spec.ts +268 -0
  182. package/templates/current/examples/src/features/system/menus/menuTreePrecheck.ts +317 -0
  183. package/templates/current/examples/src/features/system/menus/pages/MenuList.vue +3 -1
  184. package/templates/current/examples/src/features/system/roles/components/RoleEditorForm.vue +19 -15
  185. package/templates/current/examples/src/features/system/roles/composables/useRoleManagement.ts +49 -53
  186. package/templates/current/examples/src/features/system/roles/pages/RoleList.vue +3 -1
  187. package/templates/current/examples/src/features/system/users/components/UserEditorForm.vue +22 -19
  188. package/templates/current/examples/src/features/system/users/composables/useUserManagement.ts +59 -64
  189. package/templates/current/examples/src/features/system/users/pages/UserList.vue +3 -1
  190. package/templates/current/examples/src/features/workspace/pages/Dashboard.spec.ts +9 -0
  191. package/templates/current/examples/src/features/workspace/pages/Dashboard.vue +54 -26
  192. package/templates/current/examples/src/features/workspace/pages/Empty.vue +4 -1
  193. package/templates/current/examples/src/features/workspace/pages/Profile.vue +14 -12
  194. package/templates/current/examples/src/layouts/AdminLayout.vue +6 -1
  195. package/templates/current/examples/src/layouts/TopBar.vue +60 -11
  196. package/templates/current/examples/src/layouts/topBarMenuSearch.spec.ts +24 -1
  197. package/templates/current/examples/src/layouts/topBarMenuSearch.ts +10 -0
  198. package/templates/current/examples/src/locales/en-US.json +517 -0
  199. package/templates/current/examples/src/locales/en-US.runtime.ts +22 -0
  200. package/templates/current/examples/src/locales/index.ts +144 -47
  201. package/templates/current/examples/src/locales/messages-types.ts +62 -0
  202. package/templates/current/examples/src/locales/messages.spec.ts +113 -6
  203. package/templates/current/examples/src/locales/vue-i18n.d.ts +5 -0
  204. package/templates/current/examples/src/locales/zh-CN.json +517 -0
  205. package/templates/current/examples/src/locales/zh-CN.runtime.ts +22 -0
  206. package/templates/current/examples/src/locales/zh-TW.json +517 -0
  207. package/templates/current/examples/src/locales/zh-TW.runtime.ts +22 -0
  208. package/templates/current/examples/src/main.ts +43 -15
  209. package/templates/current/examples/src/router/bootstrap.ts +20 -11
  210. package/templates/current/examples/src/router/componentCache.ts +18 -0
  211. package/templates/current/examples/src/router/componentRegistry.ts +1 -18
  212. package/templates/current/examples/src/router/dynamicMenuRefresh.spec.ts +101 -0
  213. package/templates/current/examples/src/router/dynamicMenuRefresh.ts +24 -0
  214. package/templates/current/examples/src/router/dynamicRoutes.spec.ts +37 -2
  215. package/templates/current/examples/src/router/dynamicRoutes.ts +19 -4
  216. package/templates/current/examples/src/router/paths.spec.ts +50 -0
  217. package/templates/current/examples/src/router/paths.ts +21 -0
  218. package/templates/current/examples/src/router/queryEncryption.spec.ts +30 -4
  219. package/templates/current/examples/src/router/queryEncryption.ts +48 -44
  220. package/templates/current/examples/src/router/staticRoutes.ts +4 -4
  221. package/templates/current/examples/src/router/useRouteQueryDefaults.spec.ts +2 -1
  222. package/templates/current/examples/src/router/useRouteQueryDefaults.types.ts +2 -1
  223. package/templates/current/examples/src/templates/og-table.ts +79 -37
  224. package/templates/current/examples/src/templates/templates.spec.ts +19 -0
  225. package/templates/current/examples/tsconfig.json +0 -1
  226. package/templates/current/examples/vite.build-policy.ts +161 -289
  227. package/templates/current/examples/vite.config.ts +34 -5
  228. package/templates/current/clean/scripts/check-admin-bundle.mjs +0 -214
  229. package/templates/current/clean/scripts/performance/baselines/bundle-gzip-v2-pre-entry-unification.json +0 -38
  230. package/templates/current/clean/src/locales/en-US.ts +0 -55
  231. package/templates/current/clean/src/locales/zh-CN.ts +0 -55
  232. package/templates/current/clean/src/locales/zh-TW.ts +0 -44
  233. package/templates/current/examples/scripts/check-admin-bundle.mjs +0 -214
  234. package/templates/current/examples/scripts/performance/baselines/bundle-gzip-v2-pre-entry-unification.json +0 -38
  235. package/templates/current/examples/src/locales/en-US.ts +0 -55
  236. package/templates/current/examples/src/locales/zh-CN.ts +0 -55
  237. package/templates/current/examples/src/locales/zh-TW.ts +0 -44
@@ -1,12 +1,13 @@
1
- import type { Plugin, Rollup, UserConfig } from 'vite'
1
+ import type { Plugin, Rolldown, UserConfig } from 'vite'
2
2
  import { writeFile } from 'node:fs/promises'
3
3
  import { resolve } from 'node:path'
4
4
  import process from 'node:process'
5
5
 
6
6
  const packageBuildDirectories = new Set(['dist', 'es', 'esm', 'lib', 'src'])
7
- const splitModuleDirectories = new Set(['components', 'languages', 'locale'])
8
- const ASYNC_COMPONENT_CHUNK_BUCKETS = 4
9
- const INITIAL_CHUNK_BUCKETS = 3
7
+ const MAX_INITIAL_VENDOR_CHUNK_BYTES = 300 * 1024
8
+ const MAX_ASYNC_VENDOR_CHUNK_BYTES = 400 * 1024
9
+
10
+ type AdminCodeSplitting = Exclude<NonNullable<Rolldown.OutputOptions['codeSplitting']>, boolean>
10
11
 
11
12
  function chunkName(value: string): string {
12
13
  return value
@@ -16,7 +17,12 @@ function chunkName(value: string): string {
16
17
  .toLowerCase()
17
18
  }
18
19
 
19
- function dependencyPath(normalized: string): { name: string, path: string[] } | undefined {
20
+ interface ModuleLocation {
21
+ name: string
22
+ path: string[]
23
+ }
24
+
25
+ function dependencyPath(normalized: string): ModuleLocation | undefined {
20
26
  const marker = '/node_modules/'
21
27
  const nodeModulesIndex = normalized.lastIndexOf(marker)
22
28
  if (nodeModulesIndex < 0) return undefined
@@ -31,7 +37,7 @@ function dependencyPath(normalized: string): { name: string, path: string[] } |
31
37
  }
32
38
  }
33
39
 
34
- function workspacePackagePath(normalized: string): { name: string, path: string[] } | undefined {
40
+ function workspacePackagePath(normalized: string): ModuleLocation | undefined {
35
41
  const match = normalized.match(/\/packages\/([^/]+)\/(?:dist|src)\/(.+)$/)
36
42
  if (!match) return undefined
37
43
  return { name: `og-${match[1]}`, path: match[2].split('/') }
@@ -51,294 +57,148 @@ function isStyleModule(id: string): boolean {
51
57
  return /\.(?:css|less|sass|scss|styl)(?:$|\?)/.test(id)
52
58
  }
53
59
 
54
- function moduleUnitKey(id: string): string | undefined {
55
- const location = moduleLocation(id)
56
- if (!location) return undefined
57
- const [directory, moduleName] = location.path
58
- if (!directory || !splitModuleDirectories.has(directory)) return location.name
59
- if (directory === 'components' && moduleName)
60
- return `${location.name}\0${directory}\0${moduleName}`
61
- return `${location.name}\0${directory}`
62
- }
63
-
64
- function stableHash(value: string): string {
65
- let hash = 2_166_136_261
66
- for (let index = 0; index < value.length; index += 1) {
67
- hash ^= value.charCodeAt(index)
68
- hash = Math.imul(hash, 16_777_619)
69
- }
70
- return (hash >>> 0).toString(36)
71
- }
72
-
73
- function dynamicRootLabels(ids: readonly string[]): ReadonlyMap<string, string> {
74
- const used = new Map<string, number>()
75
- const labels = new Map<string, string>()
76
- for (const id of [...ids].sort()) {
77
- const normalized = id.split('?')[0].replaceAll('\\', '/')
78
- const filename = normalized.slice(normalized.lastIndexOf('/') + 1).replace(/\.[^.]+$/, '')
79
- const base = chunkName(filename || 'async') || 'async'
80
- const count = (used.get(base) ?? 0) + 1
81
- used.set(base, count)
82
- labels.set(id, count === 1 ? base : `${base}-${count}`)
83
- }
84
- return labels
85
- }
86
-
87
- function moduleOwners(
88
- meta: Parameters<Rollup.GetManualChunk>[1],
89
- ): ReadonlyMap<string, readonly string[]> {
90
- const ids = [...meta.getModuleIds()].sort()
91
- const ownerSets = new Map<string, Set<string>>()
92
- const entryRoots = ids.filter((id) => meta.getModuleInfo(id)?.isEntry)
93
- const dynamicRoots = [
94
- ...new Set(ids.flatMap((id) => meta.getModuleInfo(id)?.dynamicallyImportedIds ?? [])),
95
- ]
96
- const labels = dynamicRootLabels(dynamicRoots)
97
-
98
- function markStaticClosure(root: string, owner: string): void {
99
- const stack = [root]
100
- while (stack.length > 0) {
101
- const id = stack.pop()!
102
- const info = meta.getModuleInfo(id)
103
- if (!info || info.isExternal) continue
104
- const owners = ownerSets.get(id) ?? new Set<string>()
105
- if (owners.has(owner)) continue
106
- owners.add(owner)
107
- ownerSets.set(id, owners)
108
- stack.push(...info.importedIds)
109
- }
110
- }
111
-
112
- for (const root of entryRoots) markStaticClosure(root, 'entry')
113
- for (const root of dynamicRoots) markStaticClosure(root, labels.get(root) ?? 'async')
114
-
115
- return new Map([...ownerSets].map(([id, owners]) => [id, [...owners].sort()]))
116
- }
117
-
118
- function asyncOwnerLabel(owners: readonly string[]): string {
119
- const asyncOwners = owners.filter((owner) => owner !== 'entry')
120
- if (asyncOwners.length === 0) return 'orphan'
121
- if (asyncOwners.length === 1) return asyncOwners[0]
122
- return `shared-${stableHash(asyncOwners.join('|'))}`
123
- }
124
-
125
- function isInitialOnly(owners: readonly string[]): boolean {
126
- return owners.length === 1 && owners[0] === 'entry'
127
- }
128
-
129
- function stronglyConnectedComponents(units: Map<string, { edges: Set<string> }>): string[][] {
130
- const indices = new Map<string, number>()
131
- const lowLinks = new Map<string, number>()
132
- const stack: string[] = []
133
- const stacked = new Set<string>()
134
- const components: string[][] = []
135
- let index = 0
136
-
137
- function visit(key: string) {
138
- indices.set(key, index)
139
- lowLinks.set(key, index++)
140
- stack.push(key)
141
- stacked.add(key)
142
-
143
- for (const edge of [...(units.get(key)?.edges ?? [])].sort()) {
144
- if (!units.has(edge)) continue
145
- if (!indices.has(edge)) {
146
- visit(edge)
147
- lowLinks.set(key, Math.min(lowLinks.get(key)!, lowLinks.get(edge)!))
148
- } else if (stacked.has(edge)) {
149
- lowLinks.set(key, Math.min(lowLinks.get(key)!, indices.get(edge)!))
150
- }
151
- }
152
-
153
- if (lowLinks.get(key) !== indices.get(key)) return
154
- const component: string[] = []
155
- let member: string
156
- do {
157
- member = stack.pop()!
158
- stacked.delete(member)
159
- component.push(member)
160
- } while (member !== key)
161
- components.push(component.sort())
162
- }
163
-
164
- for (const key of [...units.keys()].sort()) {
165
- if (!indices.has(key)) visit(key)
166
- }
167
- return components
60
+ function vendorLocation(id: string) {
61
+ if (id.startsWith('\0') || isStyleModule(id)) return undefined
62
+ return moduleLocation(id)
168
63
  }
169
64
 
170
- function topologicallyOrderedComponents(units: Map<string, { edges: Set<string> }>): string[][] {
171
- const components = stronglyConnectedComponents(units)
172
- const componentByUnit = new Map<string, number>()
173
- components.forEach((component, index) => {
174
- for (const key of component) componentByUnit.set(key, index)
175
- })
176
-
177
- const edges = components.map(() => new Set<number>())
178
- const indegrees = components.map(() => 0)
179
- for (const [unit, value] of units) {
180
- const from = componentByUnit.get(unit)!
181
- for (const dependency of value.edges) {
182
- const to = componentByUnit.get(dependency)
183
- if (to === undefined || to === from || edges[from].has(to)) continue
184
- edges[from].add(to)
185
- indegrees[to] += 1
186
- }
187
- }
188
-
189
- const available = components
190
- .map((_, index) => index)
191
- .filter((index) => indegrees[index] === 0)
192
- .sort((left, right) => components[left].join('\0').localeCompare(components[right].join('\0')))
193
- const ordered: string[][] = []
194
- while (available.length > 0) {
195
- const index = available.shift()!
196
- ordered.push(components[index])
197
- for (const dependency of edges[index]) {
198
- indegrees[dependency] -= 1
199
- if (indegrees[dependency] === 0) {
200
- available.push(dependency)
201
- available.sort((left, right) =>
202
- components[left].join('\0').localeCompare(components[right].join('\0')),
203
- )
204
- }
205
- }
206
- }
207
- return ordered
208
- }
209
-
210
- function assignBuckets(
211
- units: Map<string, { edges: Set<string>, size: number }>,
212
- bucketCount: number,
213
- ): ReadonlyMap<string, string> {
214
- const components = topologicallyOrderedComponents(units)
215
- const totalSize = components.reduce(
216
- (total, component) => total + component.reduce((size, key) => size + units.get(key)!.size, 0),
217
- 0,
65
+ function matchesPackageFamily(id: string, names: readonly string[]): boolean {
66
+ const name = vendorLocation(id)?.name
67
+ return Boolean(
68
+ name && names.some((candidate) => name === candidate || name.startsWith(`${candidate}/`)),
218
69
  )
219
- const assignments = new Map<string, string>()
220
- let consumedSize = 0
221
- for (const component of components) {
222
- const componentSize = component.reduce((size, key) => size + units.get(key)!.size, 0)
223
- const midpoint = consumedSize + componentSize / 2
224
- const bucket = Math.min(
225
- Math.floor((midpoint * bucketCount) / Math.max(totalSize, 1)),
226
- bucketCount - 1,
227
- )
228
- for (const key of component) assignments.set(key, String(bucket))
229
- consumedSize += componentSize
230
- }
231
- return assignments
232
70
  }
233
71
 
234
- function initialChunkAssignments(
235
- meta: Parameters<Rollup.GetManualChunk>[1],
236
- owners: ReadonlyMap<string, readonly string[]>,
237
- ): ReadonlyMap<string, string> {
238
- const units = new Map<string, { edges: Set<string>, size: number }>()
239
- const unitByModule = new Map<string, string>()
240
-
241
- for (const id of [...meta.getModuleIds()].sort()) {
242
- if (!isInitialOnly(owners.get(id) ?? [])) continue
243
- const key = moduleUnitKey(id)
244
- if (!key) continue
245
- const unit = units.get(key) ?? { edges: new Set(), size: 0 }
246
- unit.size += meta.getModuleInfo(id)?.code?.length ?? 1
247
- units.set(key, unit)
248
- unitByModule.set(id, key)
249
- }
250
-
251
- for (const [id, key] of unitByModule) {
252
- for (const importedId of meta.getModuleInfo(id)?.importedIds ?? []) {
253
- const importedKey = unitByModule.get(importedId)
254
- if (importedKey && importedKey !== key) units.get(key)!.edges.add(importedKey)
255
- }
256
- }
257
-
258
- const unitAssignments = assignBuckets(units, INITIAL_CHUNK_BUCKETS)
259
- return new Map([...unitByModule].map(([id, key]) => [id, unitAssignments.get(key) ?? '0']))
72
+ function matchesPackageEntry(id: string, packageName: string, entry: string): boolean {
73
+ const location = vendorLocation(id)
74
+ return location?.name === packageName && location.path[0] === entry
260
75
  }
261
76
 
262
- function asyncComponentAssignments(
263
- meta: Parameters<Rollup.GetManualChunk>[1],
264
- owners: ReadonlyMap<string, readonly string[]>,
265
- ): ReadonlyMap<string, string> {
266
- const modulesByGroup = new Map<string, Map<string, string>>()
267
- const unitsByGroup = new Map<string, Map<string, { edges: Set<string>, size: number }>>()
268
-
269
- for (const id of [...meta.getModuleIds()].sort()) {
270
- const location = moduleLocation(id)
271
- const moduleOwners = owners.get(id) ?? []
272
- if (isInitialOnly(moduleOwners) || location?.path[0] !== 'components' || !location.path[1])
273
- continue
274
- const group = `${asyncOwnerLabel(moduleOwners)}\0${location.name}`
275
- const key = `${group}\0${location.path[1]}`
276
- const units = unitsByGroup.get(group) ?? new Map()
277
- const unit = units.get(key) ?? { edges: new Set<string>(), size: 0 }
278
- unit.size += meta.getModuleInfo(id)?.code?.length ?? 1
279
- units.set(key, unit)
280
- unitsByGroup.set(group, units)
281
- const modules = modulesByGroup.get(group) ?? new Map()
282
- modules.set(id, key)
283
- modulesByGroup.set(group, modules)
284
- }
285
-
286
- const assignments = new Map<string, string>()
287
- for (const [group, modules] of modulesByGroup) {
288
- const units = unitsByGroup.get(group)!
289
- for (const [id, key] of modules) {
290
- for (const importedId of meta.getModuleInfo(id)?.importedIds ?? []) {
291
- const importedKey = modules.get(importedId)
292
- if (importedKey && importedKey !== key) units.get(key)!.edges.add(importedKey)
293
- }
294
- }
295
- const buckets = assignBuckets(units, ASYNC_COMPONENT_CHUNK_BUCKETS)
296
- for (const [id, key] of modules) assignments.set(id, buckets.get(key) ?? '0')
297
- }
298
- return assignments
77
+ /**
78
+ * Element Plus table internals are extracted from the table-suite chunk they
79
+ * would otherwise co-locate with. The og-table family chunk itself must stay
80
+ * a single chunk — splitting it creates circular chunk-evaluation edges
81
+ * before Element Plus initializes (see the vendor-table-suite note) — but the
82
+ * Element Plus table code it pulls in is a leaf dependency and splits safely.
83
+ * This separation is what keeps the family chunk under the single-chunk
84
+ * budget instead of carrying the whole Element Plus table surface.
85
+ *
86
+ * `moduleLocation` strips the build directory, so published `es/components/…`
87
+ * paths start at `components`.
88
+ */
89
+ function matchesElementPlusTableModule(id: string, component: 'table' | 'table-v2'): boolean {
90
+ const location = vendorLocation(id)
91
+ if (!location || location.name !== 'element-plus') return false
92
+ return location.path[0] === 'components' && location.path[1] === component
299
93
  }
300
94
 
301
- export function createAdminManualChunks(): Rollup.GetManualChunk {
302
- let owners: ReadonlyMap<string, readonly string[]> | undefined
303
- let initialChunks: ReadonlyMap<string, string> | undefined
304
- let componentChunks: ReadonlyMap<string, string> | undefined
305
- return (id, meta) => {
306
- if (id.startsWith('\0') || isStyleModule(id)) return undefined
307
- const location = moduleLocation(id)
308
- if (!location) return undefined
309
-
310
- owners ??= moduleOwners(meta)
311
- initialChunks ??= initialChunkAssignments(meta, owners)
312
- componentChunks ??= asyncComponentAssignments(meta, owners)
313
- const currentOwners = owners.get(id) ?? []
314
- // These runtime families are shared by the same feature surfaces; keeping
315
- // them together avoids repeated module wrappers across async chunks.
316
- if (location.name === 'vue' || location.name.startsWith('@vue/')) return 'vendor-vue-runtime'
317
- if (location.name === 'vue-i18n' || location.name.startsWith('@intlify/'))
318
- return 'vendor-vue-i18n'
319
- if (location.name.startsWith('@vueuse/')) return 'vendor-vueuse'
320
- if (location.name.startsWith('@floating-ui/') || location.name === '@sxzz/popperjs-es')
321
- return 'vendor-positioning'
322
- if (
323
- location.name === 'og-table' ||
324
- location.name === 'og-table-search' ||
325
- location.name === 'og-search'
326
- ) {
327
- return 'vendor-table-suite'
328
- }
329
- if (isInitialOnly(currentOwners)) return `vendor-initial-${initialChunks.get(id) ?? '0'}`
330
- if (currentOwners.includes('entry')) return undefined
331
- if (location.name === 'element-plus') return undefined
95
+ function dynamicPackageGroup(
96
+ id: string,
97
+ directory?: 'components' | 'languages' | 'locale',
98
+ ): string | undefined {
99
+ const location = vendorLocation(id)
100
+ if (!location || location.name === 'element-plus') return undefined
101
+ if (directory && location.path[0] !== directory) return undefined
102
+ const suffix =
103
+ directory === 'components' ? '-components' : directory ? `-${chunkName(directory)}` : ''
104
+ return `vendor-${chunkName(location.name)}${suffix}`
105
+ }
332
106
 
333
- const owner = asyncOwnerLabel(currentOwners)
334
- const packageName = chunkName(location.name)
335
- const [directory, moduleName] = location.path
336
- if (splitModuleDirectories.has(directory)) {
337
- if (directory === 'components' && moduleName)
338
- return `vendor-${owner}-${packageName}-components-${componentChunks.get(id) ?? '0'}`
339
- return `vendor-${owner}-${packageName}-${chunkName(directory)}`
340
- }
341
- return `vendor-${owner}-${packageName}`
107
+ export function createAdminCodeSplitting(): AdminCodeSplitting {
108
+ return {
109
+ groups: [
110
+ {
111
+ name: 'vendor-vue-runtime',
112
+ test: (id) => matchesPackageFamily(id, ['vue', '@vue']),
113
+ priority: 100,
114
+ },
115
+ {
116
+ name: 'vendor-vue-i18n',
117
+ test: (id) => matchesPackageFamily(id, ['vue-i18n', '@intlify']),
118
+ priority: 95,
119
+ },
120
+ {
121
+ name: 'vendor-vueuse',
122
+ test: (id) => matchesPackageFamily(id, ['@vueuse']),
123
+ priority: 90,
124
+ },
125
+ {
126
+ name: 'vendor-positioning',
127
+ test: (id) => matchesPackageFamily(id, ['@floating-ui', '@sxzz/popperjs-es']),
128
+ priority: 85,
129
+ },
130
+ {
131
+ // async-validator is a leaf dependency shared by the form and table
132
+ // surfaces. Keeping it outside the table family avoids making the
133
+ // deliberately single-chunk family carry validation internals.
134
+ name: 'vendor-async-validator',
135
+ test: (id) => matchesPackageFamily(id, ['async-validator']),
136
+ priority: 83,
137
+ },
138
+ {
139
+ name: 'vendor-table-suite',
140
+ test: (id) =>
141
+ matchesPackageFamily(id, [
142
+ 'og-table',
143
+ 'og-table-search',
144
+ 'og-search',
145
+ '@origen-ui/table',
146
+ '@origen-ui/table-search',
147
+ '@origen-ui/search',
148
+ ]) ||
149
+ matchesPackageEntry(id, 'origen-ui', 'table') ||
150
+ matchesPackageEntry(id, 'origen-ui', 'table-search') ||
151
+ matchesPackageEntry(id, 'origen-ui', 'search'),
152
+ // Rolldown can otherwise split this mutually dependent family into a
153
+ // circular chunk-evaluation edge before Element Plus initializes.
154
+ priority: 80,
155
+ },
156
+ {
157
+ // Leaf dependency of the table-suite family: extracted so the family
158
+ // chunk stays under the single-chunk budget. The priority must sit
159
+ // ABOVE vendor-table-suite — Rolldown lets a higher-priority chunk
160
+ // pull lower-priority-grouped dependencies into itself, which is
161
+ // exactly how the Element Plus table internals ended up inside the
162
+ // family chunk — but still below the positioning/vueuse families.
163
+ name: 'vendor-element-table-v2',
164
+ test: (id) => matchesElementPlusTableModule(id, 'table-v2'),
165
+ priority: 82,
166
+ },
167
+ {
168
+ name: 'vendor-element-table',
169
+ test: (id) => matchesElementPlusTableModule(id, 'table'),
170
+ priority: 81,
171
+ },
172
+ {
173
+ name: 'vendor-initial',
174
+ test: (id) => Boolean(vendorLocation(id)),
175
+ tags: ['$initial'],
176
+ maxSize: MAX_INITIAL_VENDOR_CHUNK_BYTES,
177
+ priority: 60,
178
+ },
179
+ {
180
+ name: (id) => dynamicPackageGroup(id, 'components'),
181
+ entriesAware: true,
182
+ maxSize: MAX_ASYNC_VENDOR_CHUNK_BYTES,
183
+ priority: 50,
184
+ },
185
+ {
186
+ name: (id) => dynamicPackageGroup(id, 'languages'),
187
+ entriesAware: true,
188
+ priority: 40,
189
+ },
190
+ {
191
+ name: (id) => dynamicPackageGroup(id, 'locale'),
192
+ entriesAware: true,
193
+ priority: 40,
194
+ },
195
+ {
196
+ name: (id) => dynamicPackageGroup(id),
197
+ entriesAware: true,
198
+ maxSize: MAX_ASYNC_VENDOR_CHUNK_BYTES,
199
+ priority: 30,
200
+ },
201
+ ],
342
202
  }
343
203
  }
344
204
 
@@ -347,7 +207,9 @@ function normalizeEmptyChunks(): Plugin {
347
207
  name: 'admin-normalize-empty-chunks',
348
208
  renderChunk(code) {
349
209
  const payload = code.replaceAll(/\/\*[\s\S]*?\*\//g, '').trim()
350
- if (!payload || /^export\s*\{\s*\}\s*;?$/.test(payload)) return 'void 0;\n'
210
+ if (!payload || /^export\s*\{\s*\}\s*;?$/.test(payload)) {
211
+ return { code: 'void 0;\n', map: { mappings: '' } }
212
+ }
351
213
  return null
352
214
  },
353
215
  generateBundle(_options, bundle) {
@@ -382,10 +244,12 @@ export function createAdminBuildOptions(isDebugBuild: boolean): UserConfig['buil
382
244
  return {
383
245
  outDir: 'dist',
384
246
  sourcemap: isDebugBuild,
385
- minify: isDebugBuild ? false : 'esbuild',
247
+ // Keep the oxc minifier: it honours the `oxc.dropConsole` production
248
+ // policy, while overriding the minifier would silently keep console calls.
249
+ minify: !isDebugBuild,
386
250
  target: 'es2020',
387
251
  modulePreload: false,
388
- rollupOptions: {
252
+ rolldownOptions: {
389
253
  onwarn(warning, warn) {
390
254
  if (warning.code === 'EMPTY_BUNDLE') return
391
255
  if (
@@ -397,8 +261,16 @@ export function createAdminBuildOptions(isDebugBuild: boolean): UserConfig['buil
397
261
  warn(warning)
398
262
  },
399
263
  output: {
400
- manualChunks: createAdminManualChunks(),
401
- onlyExplicitManualChunks: true,
264
+ codeSplitting: createAdminCodeSplitting(),
265
+ ...(!isDebugBuild
266
+ ? {
267
+ minify: {
268
+ compress: { dropConsole: true, dropDebugger: true },
269
+ mangle: true,
270
+ codegen: true,
271
+ },
272
+ }
273
+ : {}),
402
274
  },
403
275
  },
404
276
  }
@@ -1,3 +1,5 @@
1
+ import { existsSync, readdirSync } from 'node:fs'
2
+ import { dirname, join } from 'node:path'
1
3
  import process from 'node:process'
2
4
  import { fileURLToPath } from 'node:url'
3
5
  import vue from '@vitejs/plugin-vue'
@@ -7,7 +9,18 @@ import { loadEnv } from 'vite'
7
9
  import { defineConfig } from 'vitest/config'
8
10
  // This file is copied to the scaffold root, where the shared policy is copied
9
11
  // with the application source as ./vite.build-policy.ts.
10
- import { createAdminBuildOptions, createAdminBuildPlugins } from './vite.build-policy'
12
+ import { createAdminBuildOptions, createAdminBuildPlugins } from './vite.build-policy.js'
13
+
14
+ const elementPlusPackageRoot = dirname(dirname(fileURLToPath(import.meta.resolve('element-plus'))))
15
+ const elementPlusStyleIncludes = readdirSync(join(elementPlusPackageRoot, 'es/components'), {
16
+ withFileTypes: true,
17
+ })
18
+ .filter(
19
+ (entry) =>
20
+ entry.isDirectory() &&
21
+ existsSync(join(elementPlusPackageRoot, 'es/components', entry.name, 'style/index.mjs')),
22
+ )
23
+ .map((entry) => `element-plus/es/components/${entry.name}/style/index`)
11
24
 
12
25
  export default defineConfig(({ command, mode }) => {
13
26
  const loadedEnv = loadEnv(mode, process.cwd(), '')
@@ -17,10 +30,26 @@ export default defineConfig(({ command, mode }) => {
17
30
  return {
18
31
  plugins: [vue(), vueJsx(), ...createAdminBuildPlugins(), ElementPlus({ useSource: true })],
19
32
  resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } },
20
- esbuild: {
21
- jsx: 'preserve',
22
- jsxImportSource: 'vue',
23
- ...(command === 'build' && !isDebugBuild ? { drop: ['console', 'debugger'] } : {}),
33
+ optimizeDeps: {
34
+ // Element Plus injects these entries only after lazy SFCs transform.
35
+ // Pre-bundle them up front and keep the dependency set fixed for route loads.
36
+ noDiscovery: true,
37
+ include: [
38
+ '@element-plus/icons-vue',
39
+ '@vueuse/core',
40
+ 'axios',
41
+ 'element-plus',
42
+ 'pinia',
43
+ 'sortablejs',
44
+ 'vue',
45
+ 'vue-i18n',
46
+ 'vue-router',
47
+ ...elementPlusStyleIncludes,
48
+ ],
49
+ },
50
+ oxc: {
51
+ jsx: { runtime: 'automatic', importSource: 'vue' },
52
+ ...(command === 'build' && !isDebugBuild ? { dropConsole: true, dropDebugger: true } : {}),
24
53
  },
25
54
  server: {
26
55
  port: 5175,