@absolutejs/absolute 0.19.0-beta.808 → 0.19.0-beta.809

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 (260) hide show
  1. package/dist/angular/browser.js +9801 -57
  2. package/dist/angular/browser.js.map +246 -4
  3. package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
  4. package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
  5. package/dist/angular/index.js +14877 -60
  6. package/dist/angular/index.js.map +281 -4
  7. package/dist/angular/server.js +5610 -45
  8. package/dist/angular/server.js.map +51 -3
  9. package/dist/build.js +18092 -45
  10. package/dist/build.js.map +99 -3
  11. package/dist/cli/index.js +317 -86
  12. package/dist/client/index.js +1100 -40
  13. package/dist/client/index.js.map +24 -4
  14. package/dist/core/streamingSlotRegistrar.js +108 -11
  15. package/dist/core/streamingSlotRegistrar.js.map +4 -3
  16. package/dist/core/streamingSlotRegistry.js +169 -7
  17. package/dist/core/streamingSlotRegistry.js.map +5 -3
  18. package/dist/index.js +19957 -547
  19. package/dist/index.js.map +116 -3
  20. package/dist/islands/browser.js +228 -9
  21. package/dist/islands/browser.js.map +9 -4
  22. package/dist/islands/index.js +1908 -17
  23. package/dist/islands/index.js.map +27 -3
  24. package/dist/react/browser.js +328 -12
  25. package/dist/react/browser.js.map +12 -4
  26. package/dist/react/components/index.js +167 -16
  27. package/dist/react/components/index.js.map +6 -3
  28. package/dist/react/hooks/index.js +183 -8
  29. package/dist/react/hooks/index.js.map +7 -3
  30. package/dist/react/index.js +3627 -36
  31. package/dist/react/index.js.map +45 -4
  32. package/dist/react/jsxDevRuntimeCompat.js +61 -2
  33. package/dist/react/jsxDevRuntimeCompat.js.map +2 -2
  34. package/dist/react/server.js +1789 -18
  35. package/dist/react/server.js.map +21 -3
  36. package/dist/src/angular/injectorPatch.d.ts +1 -0
  37. package/dist/src/index.d.ts +1 -0
  38. package/dist/svelte/browser.js +247 -12
  39. package/dist/svelte/browser.js.map +10 -3
  40. package/dist/svelte/index.js +3732 -37
  41. package/dist/svelte/index.js.map +47 -4
  42. package/dist/svelte/server.js +2794 -21
  43. package/dist/svelte/server.js.map +27 -3
  44. package/dist/vue/browser.js +348 -12
  45. package/dist/vue/browser.js.map +12 -4
  46. package/dist/vue/components/Image.js +240 -7
  47. package/dist/vue/components/Image.js.map +6 -3
  48. package/dist/vue/components/index.js +544 -11
  49. package/dist/vue/components/index.js.map +9 -3
  50. package/dist/vue/index.js +4212 -52
  51. package/dist/vue/index.js.map +50 -4
  52. package/dist/vue/server.js +1849 -18
  53. package/dist/vue/server.js.map +21 -3
  54. package/package.json +1 -1
  55. package/dist/chunk-0867j0r0.js +0 -136
  56. package/dist/chunk-0867j0r0.js.map +0 -10
  57. package/dist/chunk-0kdc6r16.js +0 -20
  58. package/dist/chunk-0kdc6r16.js.map +0 -10
  59. package/dist/chunk-102fp7xe.js +0 -63
  60. package/dist/chunk-102fp7xe.js.map +0 -10
  61. package/dist/chunk-11zpfqz6.js +0 -19
  62. package/dist/chunk-11zpfqz6.js.map +0 -10
  63. package/dist/chunk-1rfh7hw9.js +0 -319
  64. package/dist/chunk-1rfh7hw9.js.map +0 -11
  65. package/dist/chunk-25v9t56f.js +0 -29
  66. package/dist/chunk-25v9t56f.js.map +0 -11
  67. package/dist/chunk-2f21eenc.js +0 -21
  68. package/dist/chunk-2f21eenc.js.map +0 -10
  69. package/dist/chunk-2ga2znex.js +0 -13
  70. package/dist/chunk-2ga2znex.js.map +0 -9
  71. package/dist/chunk-30yrw0f6.js +0 -33
  72. package/dist/chunk-30yrw0f6.js.map +0 -10
  73. package/dist/chunk-38jwhqcw.js +0 -4410
  74. package/dist/chunk-38jwhqcw.js.map +0 -28
  75. package/dist/chunk-3g91wb4f.js +0 -358
  76. package/dist/chunk-3g91wb4f.js.map +0 -10
  77. package/dist/chunk-3yjzpcne.js +0 -34
  78. package/dist/chunk-3yjzpcne.js.map +0 -10
  79. package/dist/chunk-41bf6aqt.js +0 -17
  80. package/dist/chunk-41bf6aqt.js.map +0 -9
  81. package/dist/chunk-4d39r92n.js +0 -81
  82. package/dist/chunk-4d39r92n.js.map +0 -10
  83. package/dist/chunk-5003emhv.js +0 -17
  84. package/dist/chunk-5003emhv.js.map +0 -10
  85. package/dist/chunk-5f67rsed.js +0 -466
  86. package/dist/chunk-5f67rsed.js.map +0 -10
  87. package/dist/chunk-5fhp1jap.js +0 -9169
  88. package/dist/chunk-5fhp1jap.js.map +0 -236
  89. package/dist/chunk-6pdj08z3.js +0 -73
  90. package/dist/chunk-6pdj08z3.js.map +0 -12
  91. package/dist/chunk-6qjbrt0k.js +0 -13
  92. package/dist/chunk-6qjbrt0k.js.map +0 -9
  93. package/dist/chunk-6sccb4jr.js +0 -14
  94. package/dist/chunk-6sccb4jr.js.map +0 -9
  95. package/dist/chunk-798spvzv.js +0 -50
  96. package/dist/chunk-798spvzv.js.map +0 -10
  97. package/dist/chunk-7fw6x3js.js +0 -131
  98. package/dist/chunk-7fw6x3js.js.map +0 -11
  99. package/dist/chunk-7kjj42xm.js +0 -11
  100. package/dist/chunk-7kjj42xm.js.map +0 -10
  101. package/dist/chunk-7mtstdqn.js +0 -90
  102. package/dist/chunk-7mtstdqn.js.map +0 -10
  103. package/dist/chunk-851whwc7.js +0 -17
  104. package/dist/chunk-851whwc7.js.map +0 -10
  105. package/dist/chunk-85n68sy6.js +0 -103
  106. package/dist/chunk-85n68sy6.js.map +0 -10
  107. package/dist/chunk-8kcfffry.js +0 -35
  108. package/dist/chunk-8kcfffry.js.map +0 -10
  109. package/dist/chunk-8qqxc1h2.js +0 -426
  110. package/dist/chunk-8qqxc1h2.js.map +0 -14
  111. package/dist/chunk-92fsjfpp.js +0 -1731
  112. package/dist/chunk-92fsjfpp.js.map +0 -11
  113. package/dist/chunk-93sqk7be.js +0 -139
  114. package/dist/chunk-93sqk7be.js.map +0 -12
  115. package/dist/chunk-94gvx0hg.js +0 -28
  116. package/dist/chunk-94gvx0hg.js.map +0 -10
  117. package/dist/chunk-9c5tj4k3.js +0 -130
  118. package/dist/chunk-9c5tj4k3.js.map +0 -10
  119. package/dist/chunk-9ve9jq72.js +0 -203
  120. package/dist/chunk-9ve9jq72.js.map +0 -10
  121. package/dist/chunk-9xrsjeem.js +0 -12
  122. package/dist/chunk-9xrsjeem.js.map +0 -9
  123. package/dist/chunk-a9mvyp04.js +0 -87
  124. package/dist/chunk-a9mvyp04.js.map +0 -10
  125. package/dist/chunk-b3gbnrwe.js +0 -21
  126. package/dist/chunk-b3gbnrwe.js.map +0 -10
  127. package/dist/chunk-bmgqm774.js +0 -65
  128. package/dist/chunk-bmgqm774.js.map +0 -9
  129. package/dist/chunk-bxfghpma.js +0 -69
  130. package/dist/chunk-bxfghpma.js.map +0 -10
  131. package/dist/chunk-c1jfjnka.js +0 -74
  132. package/dist/chunk-c1jfjnka.js.map +0 -10
  133. package/dist/chunk-cbkrwmvh.js +0 -80
  134. package/dist/chunk-cbkrwmvh.js.map +0 -10
  135. package/dist/chunk-cdxd7sy2.js +0 -71
  136. package/dist/chunk-cdxd7sy2.js.map +0 -10
  137. package/dist/chunk-cg95827x.js +0 -21
  138. package/dist/chunk-cg95827x.js.map +0 -10
  139. package/dist/chunk-cm0g4q6w.js +0 -149
  140. package/dist/chunk-cm0g4q6w.js.map +0 -10
  141. package/dist/chunk-cwfy538a.js +0 -51
  142. package/dist/chunk-cwfy538a.js.map +0 -9
  143. package/dist/chunk-d7mwkzry.js +0 -261
  144. package/dist/chunk-d7mwkzry.js.map +0 -10
  145. package/dist/chunk-d8w0qm28.js +0 -184
  146. package/dist/chunk-d8w0qm28.js.map +0 -11
  147. package/dist/chunk-d9c0am65.js +0 -12
  148. package/dist/chunk-d9c0am65.js.map +0 -10
  149. package/dist/chunk-daqghmg8.js +0 -12
  150. package/dist/chunk-daqghmg8.js.map +0 -9
  151. package/dist/chunk-e3r9fxaa.js +0 -149
  152. package/dist/chunk-e3r9fxaa.js.map +0 -10
  153. package/dist/chunk-e8eecyrq.js +0 -244
  154. package/dist/chunk-e8eecyrq.js.map +0 -10
  155. package/dist/chunk-ex2hxe0v.js +0 -160
  156. package/dist/chunk-ex2hxe0v.js.map +0 -11
  157. package/dist/chunk-fak944et.js +0 -91
  158. package/dist/chunk-fak944et.js.map +0 -10
  159. package/dist/chunk-ff70rnhd.js +0 -672
  160. package/dist/chunk-ff70rnhd.js.map +0 -15
  161. package/dist/chunk-fygx2ymm.js +0 -118
  162. package/dist/chunk-fygx2ymm.js.map +0 -12
  163. package/dist/chunk-g15qj669.js +0 -271
  164. package/dist/chunk-g15qj669.js.map +0 -11
  165. package/dist/chunk-gd6wmknh.js +0 -121
  166. package/dist/chunk-gd6wmknh.js.map +0 -11
  167. package/dist/chunk-gf0ygptk.js +0 -85
  168. package/dist/chunk-gf0ygptk.js.map +0 -11
  169. package/dist/chunk-gytkmthr.js +0 -220
  170. package/dist/chunk-gytkmthr.js.map +0 -10
  171. package/dist/chunk-h5bbfn3n.js +0 -28
  172. package/dist/chunk-h5bbfn3n.js.map +0 -11
  173. package/dist/chunk-h6mye9r3.js +0 -93
  174. package/dist/chunk-h6mye9r3.js.map +0 -10
  175. package/dist/chunk-hcsmxw1v.js +0 -85
  176. package/dist/chunk-hcsmxw1v.js.map +0 -10
  177. package/dist/chunk-hyjs4bqs.js +0 -8
  178. package/dist/chunk-hyjs4bqs.js.map +0 -10
  179. package/dist/chunk-j88z31ep.js +0 -25
  180. package/dist/chunk-j88z31ep.js.map +0 -10
  181. package/dist/chunk-jn91vzkh.js +0 -66
  182. package/dist/chunk-jn91vzkh.js.map +0 -10
  183. package/dist/chunk-jpkjdgsk.js +0 -167
  184. package/dist/chunk-jpkjdgsk.js.map +0 -11
  185. package/dist/chunk-jwxt8gnp.js +0 -13
  186. package/dist/chunk-jwxt8gnp.js.map +0 -9
  187. package/dist/chunk-kk8w9rh5.js +0 -195
  188. package/dist/chunk-kk8w9rh5.js.map +0 -10
  189. package/dist/chunk-m97ze5hz.js +0 -46
  190. package/dist/chunk-m97ze5hz.js.map +0 -10
  191. package/dist/chunk-mbazhahf.js +0 -60
  192. package/dist/chunk-mbazhahf.js.map +0 -10
  193. package/dist/chunk-mgfwq18r.js +0 -15
  194. package/dist/chunk-mgfwq18r.js.map +0 -9
  195. package/dist/chunk-mtgf69xn.js +0 -88
  196. package/dist/chunk-mtgf69xn.js.map +0 -10
  197. package/dist/chunk-mtxzyxpg.js +0 -102
  198. package/dist/chunk-mtxzyxpg.js.map +0 -10
  199. package/dist/chunk-nehhtthw.js +0 -225
  200. package/dist/chunk-nehhtthw.js.map +0 -10
  201. package/dist/chunk-p5504p14.js +0 -16
  202. package/dist/chunk-p5504p14.js.map +0 -10
  203. package/dist/chunk-pnscgw95.js +0 -90
  204. package/dist/chunk-pnscgw95.js.map +0 -10
  205. package/dist/chunk-pvpp4pvs.js +0 -17
  206. package/dist/chunk-pvpp4pvs.js.map +0 -10
  207. package/dist/chunk-qh75agse.js +0 -95
  208. package/dist/chunk-qh75agse.js.map +0 -10
  209. package/dist/chunk-qxq2zcty.js +0 -52
  210. package/dist/chunk-qxq2zcty.js.map +0 -10
  211. package/dist/chunk-r6e8pytx.js +0 -22
  212. package/dist/chunk-r6e8pytx.js.map +0 -9
  213. package/dist/chunk-r7jmgqnw.js +0 -114
  214. package/dist/chunk-r7jmgqnw.js.map +0 -10
  215. package/dist/chunk-s6defjk2.js +0 -116
  216. package/dist/chunk-s6defjk2.js.map +0 -10
  217. package/dist/chunk-sd39p726.js +0 -619
  218. package/dist/chunk-sd39p726.js.map +0 -10
  219. package/dist/chunk-swrnzs4c.js +0 -63
  220. package/dist/chunk-swrnzs4c.js.map +0 -10
  221. package/dist/chunk-tfe3sb44.js +0 -33
  222. package/dist/chunk-tfe3sb44.js.map +0 -10
  223. package/dist/chunk-tjr0kcev.js +0 -41
  224. package/dist/chunk-tjr0kcev.js.map +0 -9
  225. package/dist/chunk-tx9edm1x.js +0 -34
  226. package/dist/chunk-tx9edm1x.js.map +0 -10
  227. package/dist/chunk-txhm2vb5.js +0 -18
  228. package/dist/chunk-txhm2vb5.js.map +0 -9
  229. package/dist/chunk-v5vmsxmy.js +0 -526
  230. package/dist/chunk-v5vmsxmy.js.map +0 -12
  231. package/dist/chunk-vjhxm8n2.js +0 -29
  232. package/dist/chunk-vjhxm8n2.js.map +0 -9
  233. package/dist/chunk-vkrpm7kc.js +0 -247
  234. package/dist/chunk-vkrpm7kc.js.map +0 -12
  235. package/dist/chunk-w3m4m5we.js +0 -4925
  236. package/dist/chunk-w3m4m5we.js.map +0 -12
  237. package/dist/chunk-wrxtn9ve.js +0 -18
  238. package/dist/chunk-wrxtn9ve.js.map +0 -10
  239. package/dist/chunk-wwzvp0zn.js +0 -192
  240. package/dist/chunk-wwzvp0zn.js.map +0 -10
  241. package/dist/chunk-x09cskqd.js +0 -377
  242. package/dist/chunk-x09cskqd.js.map +0 -10
  243. package/dist/chunk-xnt8c6h2.js +0 -576
  244. package/dist/chunk-xnt8c6h2.js.map +0 -10
  245. package/dist/chunk-xw0tx842.js +0 -13
  246. package/dist/chunk-xw0tx842.js.map +0 -9
  247. package/dist/chunk-xx5b6b9m.js +0 -69
  248. package/dist/chunk-xx5b6b9m.js.map +0 -10
  249. package/dist/chunk-xz1kdswj.js +0 -21
  250. package/dist/chunk-xz1kdswj.js.map +0 -9
  251. package/dist/chunk-y84qnsd3.js +0 -32
  252. package/dist/chunk-y84qnsd3.js.map +0 -10
  253. package/dist/chunk-ywjn0rad.js +0 -14
  254. package/dist/chunk-ywjn0rad.js.map +0 -9
  255. package/dist/chunk-z9nvhm6r.js +0 -13
  256. package/dist/chunk-z9nvhm6r.js.map +0 -9
  257. package/dist/chunk-zhmvdpk6.js +0 -15
  258. package/dist/chunk-zhmvdpk6.js.map +0 -9
  259. package/dist/chunk-zrg9d4zw.js +0 -784
  260. package/dist/chunk-zrg9d4zw.js.map +0 -10
@@ -1,4410 +0,0 @@
1
- // @bun
2
- import {
3
- broadcastToClients,
4
- cleanStaleAssets,
5
- createModuleVersionTracker,
6
- incrementModuleVersions,
7
- populateAssetStore,
8
- serializeModuleVersions
9
- } from "./chunk-vkrpm7kc.js";
10
- import {
11
- validateSafePath
12
- } from "./chunk-cg95827x.js";
13
- import {
14
- patchRefreshGlobals,
15
- rewriteReactImports
16
- } from "./chunk-hcsmxw1v.js";
17
- import {
18
- generateReactIndexFiles
19
- } from "./chunk-3g91wb4f.js";
20
- import {
21
- optimizeHtmlImages
22
- } from "./chunk-4d39r92n.js";
23
- import {
24
- sendTelemetryEvent,
25
- updateAssetPaths
26
- } from "./chunk-93sqk7be.js";
27
- import {
28
- buildAngularServerVendor,
29
- buildAngularVendor,
30
- computeAngularServerVendorPaths,
31
- computeAngularServerVendorPathsAsync,
32
- computeAngularVendorPaths,
33
- computeAngularVendorPathsAsync,
34
- createAngularLinkerPlugin
35
- } from "./chunk-1rfh7hw9.js";
36
- import {
37
- buildVueVendor,
38
- computeVueVendorPaths
39
- } from "./chunk-bxfghpma.js";
40
- import {
41
- buildSvelteVendor,
42
- computeSvelteVendorPaths
43
- } from "./chunk-cdxd7sy2.js";
44
- import {
45
- invalidate
46
- } from "./chunk-swrnzs4c.js";
47
- import {
48
- commonAncestor
49
- } from "./chunk-b3gbnrwe.js";
50
- import {
51
- generateManifest
52
- } from "./chunk-mtxzyxpg.js";
53
- import {
54
- normalizePath
55
- } from "./chunk-hyjs4bqs.js";
56
- import {
57
- getAngularServerVendorPaths,
58
- getAngularVendorPaths,
59
- getDevVendorPaths,
60
- getSvelteVendorPaths,
61
- getVueVendorPaths,
62
- setAngularServerVendorPaths,
63
- setAngularVendorPaths,
64
- setDevVendorPaths,
65
- setSvelteVendorPaths,
66
- setVueVendorPaths
67
- } from "./chunk-y84qnsd3.js";
68
- import {
69
- buildReactVendor,
70
- computeVendorPaths
71
- } from "./chunk-85n68sy6.js";
72
- import {
73
- collectIslandFrameworkSources,
74
- compileTailwindConfig,
75
- generateIslandEntryPoints,
76
- getPagesUsingIslandSource,
77
- isTailwindCandidate,
78
- loadIslandRegistryBuildInfo,
79
- loadPageIslandMetadata,
80
- logStartupTimingBlock,
81
- setCurrentPageIslandMetadata,
82
- transformStaticPagesWithIslands
83
- } from "./chunk-ff70rnhd.js";
84
- import {
85
- disposeTailwindCompiler,
86
- incrementalTailwindBuild
87
- } from "./chunk-d7mwkzry.js";
88
- import {
89
- scanEntryPoints
90
- } from "./chunk-11zpfqz6.js";
91
- import {
92
- markSsrCacheDirty
93
- } from "./chunk-d9c0am65.js";
94
- import {
95
- logCssUpdate,
96
- logError,
97
- logHmrUpdate,
98
- logScriptUpdate,
99
- logServerReload,
100
- logWarn
101
- } from "./chunk-cbkrwmvh.js";
102
- import {
103
- toPascal
104
- } from "./chunk-p5504p14.js";
105
- import {
106
- createStylePreprocessorPlugin,
107
- createStyleTransformConfig,
108
- findStyleEntriesImporting,
109
- getStyleBaseName,
110
- isStyleModulePath,
111
- isStylePath
112
- } from "./chunk-xnt8c6h2.js";
113
- import {
114
- BUN_BUILD_WARNING_SUPPRESSION,
115
- DEFAULT_DEBOUNCE_MS,
116
- REBUILD_BATCH_DELAY_MS,
117
- UNFOUND_INDEX
118
- } from "./chunk-qh75agse.js";
119
- import {
120
- __require
121
- } from "./chunk-bmgqm774.js";
122
-
123
- // src/core/devBuild.ts
124
- import { readdir } from "fs/promises";
125
- import { statSync as statSync2 } from "fs";
126
- import { resolve as resolve10 } from "path";
127
-
128
- // src/core/build.ts
129
- import {
130
- copyFileSync,
131
- cpSync,
132
- existsSync as existsSync4,
133
- mkdirSync,
134
- readFileSync,
135
- rmSync,
136
- statSync,
137
- writeFileSync
138
- } from "fs";
139
- import { basename as basename2, dirname, extname, join as join2, relative, resolve as resolve3 } from "path";
140
- import { cwd, env, exit } from "process";
141
- var {build: bunBuild2, Glob: Glob4 } = globalThis.Bun;
142
-
143
- // src/build/wrapHTMLScript.ts
144
- var wrapHTMLScriptWithHMR = (code, scriptId) => {
145
- const escapedId = JSON.stringify(scriptId);
146
- return `${code}
147
-
148
- // HMR acceptance - allows this script to be hot-reloaded
149
- if (typeof import.meta !== "undefined" && import.meta.hot) {
150
- import.meta.hot.accept();
151
- console.log('[HMR] Script ready:', ${escapedId});
152
- }
153
- `;
154
- };
155
-
156
- // src/build/htmlScriptHMRPlugin.ts
157
- var scriptLoaders = new Set(["ts", "js", "tsx", "jsx"]);
158
- var toLoader = (ext) => {
159
- for (const loader of scriptLoaders) {
160
- if (loader === ext)
161
- return loader;
162
- }
163
- return "ts";
164
- };
165
- var createHTMLScriptHMRPlugin = (htmlDir, htmxDir) => ({
166
- name: "html-script-hmr",
167
- setup(build) {
168
- build.onLoad({ filter: /\.(ts|js|tsx|jsx)$/ }, async (args) => {
169
- const normalizedPath = args.path.replace(/\\/g, "/");
170
- const isHtmlScript = htmlDir && normalizedPath.includes(htmlDir.replace(/\\/g, "/")) && normalizedPath.includes("/scripts/");
171
- const isHtmxScript = htmxDir && normalizedPath.includes(htmxDir.replace(/\\/g, "/")) && normalizedPath.includes("/scripts/");
172
- if (!isHtmlScript && !isHtmxScript) {
173
- return;
174
- }
175
- const text = await Bun.file(args.path).text();
176
- const wrapped = wrapHTMLScriptWithHMR(text, normalizedPath);
177
- const ext = args.path.split(".").pop() ?? "ts";
178
- const loader = toLoader(ext);
179
- return {
180
- contents: wrapped,
181
- loader
182
- };
183
- });
184
- }
185
- });
186
-
187
- // src/build/outputLogs.ts
188
- var outputLogs = (logs) => {
189
- for (const log of logs) {
190
- if (log.message.includes(BUN_BUILD_WARNING_SUPPRESSION))
191
- continue;
192
- if (log.level === "error")
193
- console.error(log);
194
- else if (log.level === "warning")
195
- console.warn(log);
196
- else
197
- console.info(log);
198
- }
199
- };
200
-
201
- // src/build/scanConventions.ts
202
- import { basename } from "path";
203
- var {Glob } = globalThis.Bun;
204
- import { existsSync } from "fs";
205
- var CONVENTION_RE = /^(?:(.+)\.)?(error|loading|not-found)\.[^.]+$/;
206
- var classifyFile = (file, pageFiles, defaults, pages) => {
207
- const fileName = basename(file);
208
- const match = CONVENTION_RE.exec(fileName);
209
- if (!match) {
210
- pageFiles.push(file);
211
- return;
212
- }
213
- const [, pageName, kind] = match;
214
- if (!pageName) {
215
- if (kind === "error")
216
- defaults.error = file;
217
- else if (kind === "loading")
218
- defaults.loading = file;
219
- else if (kind === "not-found")
220
- defaults.notFound = file;
221
- return;
222
- }
223
- if (!pages[pageName])
224
- pages[pageName] = {};
225
- if (kind === "error")
226
- pages[pageName].error = file;
227
- else if (kind === "loading")
228
- pages[pageName].loading = file;
229
- };
230
- var scanConventions = async (pagesDir, pattern) => {
231
- if (!existsSync(pagesDir)) {
232
- const pageFiles2 = [];
233
- return { conventions: undefined, pageFiles: pageFiles2 };
234
- }
235
- const pageFiles = [];
236
- const defaults = {};
237
- const pages = {};
238
- const glob = new Glob(pattern);
239
- for await (const file of glob.scan({ absolute: true, cwd: pagesDir })) {
240
- classifyFile(file, pageFiles, defaults, pages);
241
- }
242
- const hasConventions = defaults.error !== undefined || defaults.loading !== undefined || defaults.notFound !== undefined || Object.keys(pages).length > 0;
243
- const conventions = hasConventions ? {
244
- ...defaults.error || defaults.loading || defaults.notFound ? { defaults } : {},
245
- ...Object.keys(pages).length > 0 ? { pages } : {}
246
- } : undefined;
247
- return { conventions, pageFiles };
248
- };
249
-
250
- // src/build/scanCssEntryPoints.ts
251
- import { existsSync as existsSync2 } from "fs";
252
- var {Glob: Glob2 } = globalThis.Bun;
253
- var scanCssEntryPoints = async (dir, ignore) => {
254
- if (!existsSync2(dir))
255
- return [];
256
- const entryPaths = [];
257
- const glob = new Glob2("**/*.{css,scss,sass,less,styl,stylus}");
258
- for await (const file of glob.scan({ absolute: true, cwd: dir })) {
259
- const normalized = normalizePath(file);
260
- if (isStyleModulePath(normalized) || ignore?.some((pattern) => normalized.includes(pattern)))
261
- continue;
262
- entryPaths.push(file);
263
- }
264
- return entryPaths;
265
- };
266
-
267
- // src/dev/buildHMRClient.ts
268
- import { existsSync as existsSync3 } from "fs";
269
- import { resolve } from "path";
270
- var {build: bunBuild } = globalThis.Bun;
271
- var resolveHmrClientPath = () => {
272
- const projectRoot = process.cwd();
273
- const fromSource = resolve(import.meta.dir, "client/hmrClient.ts");
274
- if (existsSync3(fromSource) && fromSource.startsWith(projectRoot)) {
275
- return fromSource;
276
- }
277
- const fromNodeModules = resolve(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client/hmrClient.ts");
278
- if (existsSync3(fromNodeModules))
279
- return fromNodeModules;
280
- return resolve(import.meta.dir, "dev/client/hmrClient.ts");
281
- };
282
- var hmrClientPath = resolveHmrClientPath();
283
- var buildHMRClient = async () => {
284
- const entryPoint = hmrClientPath;
285
- const result = await bunBuild({
286
- entrypoints: [entryPoint],
287
- format: "iife",
288
- minify: false,
289
- target: "browser"
290
- });
291
- if (!result.success) {
292
- console.error("Failed to build HMR client:", result.logs);
293
- sendTelemetryEvent("hmr:client-build-failed", {
294
- logCount: result.logs.length,
295
- message: result.logs.map((log) => log.message).join("; ")
296
- });
297
- return "// HMR client build failed";
298
- }
299
- const [firstOutput] = result.outputs;
300
- if (!firstOutput)
301
- return "// HMR client build failed";
302
- return firstOutput.text();
303
- };
304
-
305
- // src/utils/cleanStaleOutputs.ts
306
- import { rm } from "fs/promises";
307
- import { resolve as resolve2 } from "path";
308
- var {Glob: Glob3 } = globalThis.Bun;
309
- var HASHED_FILE_PATTERN = /\.[a-f0-9]{8,}\.\w+$/;
310
- var cleanStaleOutputs = async (buildPath, currentOutputPaths) => {
311
- const currentPaths = new Set(currentOutputPaths.map((path) => resolve2(path)));
312
- const glob = new Glob3("**/*");
313
- const removals = [];
314
- for (const relative of glob.scanSync({ cwd: buildPath })) {
315
- const absolute = resolve2(buildPath, relative);
316
- if (currentPaths.has(absolute))
317
- continue;
318
- if (!HASHED_FILE_PATTERN.test(relative))
319
- continue;
320
- removals.push(rm(absolute, { force: true }));
321
- }
322
- await Promise.all(removals);
323
- };
324
-
325
- // src/utils/cleanup.ts
326
- import { rm as rm2 } from "fs/promises";
327
- import { join } from "path";
328
- var cleanup = async ({
329
- angularDir,
330
- reactDir,
331
- svelteDir,
332
- vueDir
333
- }) => {
334
- await Promise.all([
335
- angularDir ? rm2(join(angularDir, "generated"), {
336
- force: true,
337
- recursive: true
338
- }) : undefined,
339
- reactDir ? rm2(join(reactDir, "generated"), {
340
- force: true,
341
- recursive: true
342
- }) : undefined,
343
- svelteDir ? rm2(join(svelteDir, "generated"), {
344
- force: true,
345
- recursive: true
346
- }) : undefined,
347
- vueDir ? rm2(join(vueDir, "generated"), {
348
- force: true,
349
- recursive: true
350
- }) : undefined
351
- ]);
352
- };
353
-
354
- // src/core/build.ts
355
- var isDev = env.NODE_ENV === "development";
356
- var isBuildTraceEnabled = () => {
357
- const value = env.ABSOLUTE_BUILD_TRACE?.toLowerCase();
358
- return value === "1" || value === "true" || value === "yes";
359
- };
360
- var collectConventionSourceFiles = (entry) => {
361
- if (!entry)
362
- return [];
363
- const files = [];
364
- if (entry.defaults?.error)
365
- files.push(entry.defaults.error);
366
- if (entry.defaults?.loading)
367
- files.push(entry.defaults.loading);
368
- if (entry.defaults?.notFound)
369
- files.push(entry.defaults.notFound);
370
- if (!entry.pages)
371
- return files;
372
- for (const page of Object.values(entry.pages)) {
373
- if (page.error)
374
- files.push(page.error);
375
- if (page.loading)
376
- files.push(page.loading);
377
- }
378
- return files;
379
- };
380
- var updateConventionCompiledPaths = (entry, sourcePaths, compiledPaths) => {
381
- if (!entry || sourcePaths.length !== compiledPaths.length)
382
- return;
383
- const pathMap = new Map;
384
- for (let idx = 0;idx < sourcePaths.length; idx++) {
385
- const src = sourcePaths[idx];
386
- const compiled = compiledPaths[idx];
387
- if (src && compiled)
388
- pathMap.set(src, compiled);
389
- }
390
- if (entry.defaults) {
391
- const errorPath = entry.defaults.error ? pathMap.get(entry.defaults.error) : undefined;
392
- if (errorPath)
393
- entry.defaults.error = errorPath;
394
- const loadingPath = entry.defaults.loading ? pathMap.get(entry.defaults.loading) : undefined;
395
- if (loadingPath)
396
- entry.defaults.loading = loadingPath;
397
- const notFoundPath = entry.defaults.notFound ? pathMap.get(entry.defaults.notFound) : undefined;
398
- if (notFoundPath)
399
- entry.defaults.notFound = notFoundPath;
400
- }
401
- if (!entry.pages)
402
- return;
403
- for (const page of Object.values(entry.pages)) {
404
- const errorPath = page.error ? pathMap.get(page.error) : undefined;
405
- if (errorPath)
406
- page.error = errorPath;
407
- const loadingPath = page.loading ? pathMap.get(page.loading) : undefined;
408
- if (loadingPath)
409
- page.loading = loadingPath;
410
- }
411
- };
412
- var extractBuildError = (logs, pass, label, frameworkNames, isIncremental, throwOnError) => {
413
- const errLog = logs.find((log) => log.level === "error") ?? logs[0];
414
- if (!errLog) {
415
- exit(1);
416
- return;
417
- }
418
- const err = new Error(typeof errLog.message === "string" ? errLog.message : String(errLog.message));
419
- Object.assign(err, { logs });
420
- sendTelemetryEvent("build:error", {
421
- frameworks: frameworkNames,
422
- incremental: Boolean(isIncremental),
423
- message: err.message,
424
- pass
425
- });
426
- logError(`${label} build failed`, err);
427
- if (throwOnError)
428
- throw err;
429
- exit(1);
430
- };
431
- var copyHtmxVendor = (htmxDir, htmxDestDir) => {
432
- mkdirSync(htmxDestDir, { recursive: true });
433
- const glob = new Glob4("htmx*.min.js");
434
- for (const relPath of glob.scanSync({ cwd: htmxDir })) {
435
- const src = join2(htmxDir, relPath);
436
- const dest = join2(htmxDestDir, "htmx.min.js");
437
- copyFileSync(src, dest);
438
- return;
439
- }
440
- };
441
- var tryReadPackageJson = async (path) => {
442
- try {
443
- return await Bun.file(path).json();
444
- } catch {
445
- return null;
446
- }
447
- };
448
- var resolveAbsoluteVersion = async () => {
449
- const candidates = [
450
- resolve3(import.meta.dir, "..", "..", "package.json"),
451
- resolve3(import.meta.dir, "..", "package.json")
452
- ];
453
- const resolveCandidate = async (remaining) => {
454
- const [candidate, ...rest] = remaining;
455
- if (!candidate) {
456
- return;
457
- }
458
- const pkg = await tryReadPackageJson(candidate);
459
- if (!pkg || pkg.name !== "@absolutejs/absolute") {
460
- await resolveCandidate(rest);
461
- return;
462
- }
463
- globalThis.__absoluteVersion = pkg.version;
464
- };
465
- await resolveCandidate(candidates);
466
- };
467
- var SKIP_DIRS = new Set([
468
- "build",
469
- "node_modules",
470
- ".absolutejs",
471
- "generated"
472
- ]);
473
- var addWorkerPathIfExists = (file, relPath, workerPaths) => {
474
- const absPath = resolve3(file, "..", relPath);
475
- try {
476
- statSync(absPath);
477
- workerPaths.add(absPath);
478
- } catch {}
479
- };
480
- var collectWorkerPathsFromContent = (content, pattern, file, workerPaths) => {
481
- pattern.lastIndex = 0;
482
- let match;
483
- while ((match = pattern.exec(content)) !== null) {
484
- const [, relPath] = match;
485
- if (!relPath)
486
- continue;
487
- addWorkerPathIfExists(file, relPath, workerPaths);
488
- }
489
- };
490
- var collectWorkerPathsFromFile = (file, patterns, workerPaths) => {
491
- const content = readFileSync(file, "utf-8");
492
- for (const pattern of patterns) {
493
- collectWorkerPathsFromContent(content, pattern, file, workerPaths);
494
- }
495
- };
496
- var scanWorkerReferencesInDir = async (dir, patterns, workerPaths) => {
497
- const glob = new Glob4("**/*.{ts,tsx,js,jsx,svelte,vue}");
498
- for await (const file of glob.scan({ absolute: true, cwd: dir })) {
499
- const relToDir = file.slice(dir.length + 1);
500
- const [firstSegment] = relToDir.split("/");
501
- if (firstSegment && SKIP_DIRS.has(firstSegment))
502
- continue;
503
- collectWorkerPathsFromFile(file, patterns, workerPaths);
504
- }
505
- };
506
- var scanWorkerReferences = async (dirs) => {
507
- const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
508
- const resolvePattern = /import\.meta\.resolve\(\s*["'](\.\.?\/[^"']+)["']\s*\)/g;
509
- const workerPaths = new Set;
510
- await Promise.all(dirs.map((dir) => scanWorkerReferencesInDir(dir, [urlPattern, resolvePattern], workerPaths)));
511
- return [...workerPaths];
512
- };
513
- var copyDevIndexes = async ({
514
- buildPath,
515
- reactIndexesPath,
516
- reactPagesPath,
517
- svelteDir,
518
- svelteEntries,
519
- sveltePagesPath,
520
- vueDir,
521
- vueEntries,
522
- vuePagesPath
523
- }) => {
524
- const { readdirSync: readDir } = await import("fs");
525
- const devIndexDir = join2(buildPath, "_src_indexes");
526
- mkdirSync(devIndexDir, { recursive: true });
527
- if (reactIndexesPath && reactPagesPath) {
528
- copyReactDevIndexes(reactIndexesPath, reactPagesPath, devIndexDir, readDir);
529
- }
530
- if (svelteDir && sveltePagesPath) {
531
- copySvelteDevIndexes(svelteDir, sveltePagesPath, svelteEntries, devIndexDir);
532
- }
533
- if (vueDir && vuePagesPath) {
534
- copyVueDevIndexes(vueDir, vuePagesPath, vueEntries, devIndexDir);
535
- }
536
- };
537
- var copyReactDevIndexes = (reactIndexesPath, reactPagesPath, devIndexDir, readDir) => {
538
- if (!existsSync4(reactIndexesPath)) {
539
- return;
540
- }
541
- const indexFiles = readDir(reactIndexesPath).filter((file) => file.endsWith(".tsx"));
542
- const pagesRel = relative(process.cwd(), resolve3(reactPagesPath)).replace(/\\/g, "/");
543
- for (const file of indexFiles) {
544
- let content = readFileSync(join2(reactIndexesPath, file), "utf-8");
545
- content = content.replace(/from\s*['"]([^'"]*\/pages\/([^'"]+))['"]/g, (_match, _fullPath, componentName) => `from '/@src/${pagesRel}/${componentName}'`);
546
- writeFileSync(join2(devIndexDir, file), content);
547
- }
548
- };
549
- var copySvelteDevIndexes = (svelteDir, sveltePagesPath, svelteEntries, devIndexDir) => {
550
- const svelteIndexDir = join2(svelteDir, "generated", "indexes");
551
- const sveltePageEntries = svelteEntries.filter((file) => resolve3(file).startsWith(resolve3(sveltePagesPath)));
552
- for (const entry of sveltePageEntries) {
553
- const name = basename2(entry).replace(/\.svelte(\.(ts|js))?$/, "");
554
- const indexFile = join2(svelteIndexDir, "pages", `${name}.js`);
555
- if (!existsSync4(indexFile))
556
- continue;
557
- let content = readFileSync(indexFile, "utf-8");
558
- const srcRel = relative(process.cwd(), resolve3(entry)).replace(/\\/g, "/");
559
- content = content.replace(/import\s+Component\s+from\s+['"]([^'"]+)['"]/, `import Component from "/@src/${srcRel}"`);
560
- writeFileSync(join2(devIndexDir, `${name}.svelte.js`), content);
561
- }
562
- };
563
- var copyVueDevIndexes = (vueDir, vuePagesPath, vueEntries, devIndexDir) => {
564
- const vueIndexDir = join2(vueDir, "generated", "indexes");
565
- const vuePageEntries = vueEntries.filter((file) => resolve3(file).startsWith(resolve3(vuePagesPath)));
566
- for (const entry of vuePageEntries) {
567
- const name = basename2(entry, ".vue");
568
- const indexFile = join2(vueIndexDir, `${name}.js`);
569
- if (!existsSync4(indexFile))
570
- continue;
571
- let content = readFileSync(indexFile, "utf-8");
572
- const srcRel = relative(process.cwd(), resolve3(entry)).replace(/\\/g, "/");
573
- content = content.replace(/import\s+Comp\s+from\s+['"]([^'"]+)['"]/, `import Comp from "/@src/${srcRel}"`);
574
- writeFileSync(join2(devIndexDir, `${name}.vue.js`), content);
575
- }
576
- };
577
- var resolveVueRuntimeId = (content, firstUseName, outputPath, projectRoot) => {
578
- const varIdx = content.indexOf(`var ${firstUseName} =`);
579
- if (varIdx <= 0)
580
- return JSON.stringify(outputPath);
581
- const before = content.slice(0, varIdx);
582
- const allComments = [...before.matchAll(/\/\/\s*(src\/[^\n]*\.js)\s*\n/g)];
583
- const last = allComments[allComments.length - 1];
584
- if (!last?.[1])
585
- return JSON.stringify(outputPath);
586
- const srcPath = resolve3(projectRoot, last[1].replace("/client/", "/").replace(/\.js$/, ".ts"));
587
- return JSON.stringify(srcPath);
588
- };
589
- var QUOTE_CHARS = new Set(['"', "'", "`"]);
590
- var OPEN_BRACES = new Set(["{", "("]);
591
- var CLOSE_BRACES = new Set(["}", ")"]);
592
- var findFunctionExpressionEnd = (content, startPos) => {
593
- let depth = 0;
594
- let inStr = false;
595
- for (let i = startPos;i < content.length; i++) {
596
- const char = content[i] ?? "";
597
- if (inStr && char === inStr && content[i - 1] !== "\\")
598
- inStr = false;
599
- if (inStr)
600
- continue;
601
- if (QUOTE_CHARS.has(char))
602
- inStr = char;
603
- if (QUOTE_CHARS.has(char))
604
- continue;
605
- if (OPEN_BRACES.has(char))
606
- depth++;
607
- if (CLOSE_BRACES.has(char))
608
- depth--;
609
- if (depth === 0 && char === ";")
610
- return i;
611
- }
612
- return startPos;
613
- };
614
- var wrapUseFunctions = (content, useNames) => {
615
- let result = content;
616
- for (const name of useNames) {
617
- const marker = `var ${name} = `;
618
- const pos = result.indexOf(marker);
619
- if (pos === UNFOUND_INDEX)
620
- continue;
621
- const afterMarker = pos + marker.length;
622
- const endPos = findFunctionExpressionEnd(result, afterMarker);
623
- const funcBody = result.slice(afterMarker, endPos);
624
- result = `${result.slice(0, afterMarker)}__hmr_wrap(${JSON.stringify(name)}, ${funcBody})${result.slice(endPos)}`;
625
- }
626
- return result;
627
- };
628
- var VUE_HMR_RUNTIME = [
629
- `var __hmr_cs=(globalThis.__HMR_COMPOSABLE_STATE__??={});`,
630
- `var __hmr_mid=__HMR_MID__;`,
631
- `var __hmr_prev_refs=__hmr_cs[__hmr_mid];`,
632
- `var __hmr_idx={};`,
633
- `__hmr_cs[__hmr_mid]={};`,
634
- `function __hmr_wrap(n,fn){return function(){`,
635
- `var i=(__hmr_idx[n]=(__hmr_idx[n]??-1)+1);`,
636
- `var r=fn.apply(this,arguments);`,
637
- `if(r&&typeof r==="object"){`,
638
- `var refs={};for(var k in r){var v=r[k];`,
639
- `if(v&&typeof v==="object"&&"value"in v&&!v.effect&&typeof v.value!=="function")refs[k]=v;}`,
640
- `(__hmr_cs[__hmr_mid][n]??=[])[i]=refs;`,
641
- `if(__hmr_prev_refs&&__hmr_prev_refs[n]&&__hmr_prev_refs[n][i]){`,
642
- `var old=__hmr_prev_refs[n][i];`,
643
- `for(var k in old){var nv=r[k],ov=old[k];`,
644
- `if(nv&&ov&&typeof nv==="object"&&"value"in nv&&!nv.effect&&typeof nv.value===typeof ov.value)nv.value=ov.value;}`,
645
- `}}return r;};}`
646
- ].join("");
647
- var injectVueComposableTracking = (outputPath, projectRoot) => {
648
- let content = readFileSync(outputPath, "utf-8");
649
- const usePattern = /^var\s+(use[A-Z]\w*)\s*=/gm;
650
- const useNames = [];
651
- let match;
652
- while ((match = usePattern.exec(content)) !== null) {
653
- if (match[1])
654
- useNames.push(match[1]);
655
- }
656
- if (useNames.length === 0)
657
- return;
658
- const [firstUseName] = useNames;
659
- if (!firstUseName)
660
- return;
661
- const runtimeId = resolveVueRuntimeId(content, firstUseName, outputPath, projectRoot);
662
- const runtime = VUE_HMR_RUNTIME.replace("__HMR_MID__", runtimeId);
663
- const firstUseIdx = content.indexOf(`var ${firstUseName} =`);
664
- if (firstUseIdx === UNFOUND_INDEX)
665
- return;
666
- content = `${content.slice(0, firstUseIdx) + runtime}
667
- ${content.slice(firstUseIdx)}`;
668
- content = wrapUseFunctions(content, useNames);
669
- writeFileSync(outputPath, content);
670
- };
671
- var buildDevUrlFileMap = (urlReferencedFiles, projectRoot) => {
672
- const urlFileMap = new Map;
673
- for (const srcPath of urlReferencedFiles) {
674
- const rel = relative(projectRoot, srcPath).replace(/\\/g, "/");
675
- const name = basename2(srcPath);
676
- const mtime = Math.round(statSync(srcPath).mtimeMs);
677
- const url = `/@src/${rel}?v=${mtime}`;
678
- urlFileMap.set(name, url);
679
- urlFileMap.set(name.replace(/\.tsx?$/, ".js"), url);
680
- }
681
- return urlFileMap;
682
- };
683
- var buildProdUrlFileMap = (urlReferencedFiles, buildPath, nonReactClientOutputs) => {
684
- const urlFileMap = new Map;
685
- for (const srcPath of urlReferencedFiles) {
686
- const srcBase = basename2(srcPath).replace(/\.[^.]+$/, "");
687
- const output = nonReactClientOutputs.find((artifact) => basename2(artifact.path).startsWith(`${srcBase}.`));
688
- if (!output)
689
- continue;
690
- urlFileMap.set(basename2(srcPath), `/${relative(buildPath, output.path).replace(/\\/g, "/")}`);
691
- }
692
- return urlFileMap;
693
- };
694
- var buildUrlFileMap = (urlReferencedFiles, hmr, projectRoot, buildPath, nonReactClientOutputs) => {
695
- if (hmr)
696
- return buildDevUrlFileMap(urlReferencedFiles, projectRoot);
697
- return buildProdUrlFileMap(urlReferencedFiles, buildPath, nonReactClientOutputs);
698
- };
699
- var rewriteUrlReferences = (outputPaths, urlFileMap) => {
700
- const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
701
- for (const outputPath of outputPaths) {
702
- let content = readFileSync(outputPath, "utf-8");
703
- let changed = false;
704
- content = content.replace(urlPattern, (_match, relPath) => {
705
- const targetName = basename2(relPath);
706
- const resolvedPath = urlFileMap.get(targetName);
707
- if (!resolvedPath)
708
- return _match;
709
- changed = true;
710
- return `new URL('${resolvedPath}', import.meta.url)`;
711
- });
712
- if (changed)
713
- writeFileSync(outputPath, content);
714
- }
715
- };
716
- var vueFeatureFlags = {
717
- __VUE_OPTIONS_API__: "true",
718
- __VUE_PROD_DEVTOOLS__: isDev ? "true" : "false",
719
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: isDev ? "true" : "false"
720
- };
721
- var bunBuildPassKeys = [
722
- "server",
723
- "reactClient",
724
- "nonReactClient",
725
- "islandClient",
726
- "globalCss",
727
- "vueCss"
728
- ];
729
- var bunBuildPassKeySet = new Set(["default", ...bunBuildPassKeys]);
730
- var reservedBunBuildConfigKeys = new Set([
731
- "entrypoints",
732
- "outdir",
733
- "outfile",
734
- "root",
735
- "target",
736
- "format",
737
- "throw",
738
- "compile"
739
- ]);
740
- var passLockedKeys = {
741
- reactClient: new Set(["splitting"])
742
- };
743
- var isObject = (value) => typeof value === "object" && value !== null;
744
- var isBunBuildPassConfig = (config) => isObject(config) && Object.keys(config).some((key) => bunBuildPassKeySet.has(key));
745
- var sanitizeBunBuildOverride = (override, extraReservedKeys = new Set) => {
746
- if (!override)
747
- return {};
748
- const sanitized = { ...override };
749
- for (const key of reservedBunBuildConfigKeys) {
750
- delete sanitized[key];
751
- }
752
- for (const key of extraReservedKeys) {
753
- delete sanitized[key];
754
- }
755
- return sanitized;
756
- };
757
- var resolveBunBuildOverride = (config, pass) => {
758
- const locked = passLockedKeys[pass] ?? new Set;
759
- if (!config)
760
- return {};
761
- if (!isBunBuildPassConfig(config)) {
762
- return sanitizeBunBuildOverride(config, locked);
763
- }
764
- return sanitizeBunBuildOverride({
765
- ...config.default ?? {},
766
- ...config[pass] ?? {}
767
- }, locked);
768
- };
769
- var dedupe = (values) => [...new Set(values)];
770
- var mergeBunBuildConfig = (base, override) => {
771
- const sanitized = sanitizeBunBuildOverride(override);
772
- const merged = {
773
- ...base,
774
- ...sanitized
775
- };
776
- return {
777
- ...merged,
778
- define: base.define || sanitized.define ? {
779
- ...sanitized.define ?? {},
780
- ...base.define ?? {}
781
- } : undefined,
782
- external: dedupe([
783
- ...base.external ?? [],
784
- ...sanitized.external ?? []
785
- ]),
786
- plugins: [...base.plugins ?? [], ...sanitized.plugins ?? []]
787
- };
788
- };
789
- var build = async ({
790
- buildDirectory = "build",
791
- assetsDirectory,
792
- publicDirectory,
793
- islands,
794
- reactDirectory,
795
- htmlDirectory,
796
- htmxDirectory,
797
- angularDirectory,
798
- svelteDirectory,
799
- vueDirectory,
800
- stylesConfig,
801
- stylePreprocessors,
802
- postcss,
803
- tailwind,
804
- bunBuild: bunBuildConfig,
805
- options,
806
- incrementalFiles,
807
- mode
808
- }) => {
809
- const buildStart = performance.now();
810
- const projectRoot = cwd();
811
- const traceEnabled = isBuildTraceEnabled();
812
- const traceEvents = [];
813
- let traceFrameworkNames = [];
814
- const traceGlobal = globalThis;
815
- const previousTracePhase = traceGlobal.__absoluteBuildTracePhase;
816
- const restoreTracePhase = () => {
817
- if (previousTracePhase) {
818
- traceGlobal.__absoluteBuildTracePhase = previousTracePhase;
819
- } else {
820
- delete traceGlobal.__absoluteBuildTracePhase;
821
- }
822
- };
823
- const tracePhase = async (name, fn, metadata) => {
824
- if (!traceEnabled)
825
- return await fn();
826
- const phaseStart = performance.now();
827
- try {
828
- const result = await fn();
829
- traceEvents.push({
830
- durationMs: performance.now() - phaseStart,
831
- metadata,
832
- name,
833
- ok: true,
834
- startMs: phaseStart - buildStart
835
- });
836
- return result;
837
- } catch (error) {
838
- traceEvents.push({
839
- durationMs: performance.now() - phaseStart,
840
- metadata: {
841
- ...metadata,
842
- error: error instanceof Error ? error.message : String(error)
843
- },
844
- name,
845
- ok: false,
846
- startMs: phaseStart - buildStart
847
- });
848
- throw error;
849
- }
850
- };
851
- if (traceEnabled) {
852
- traceGlobal.__absoluteBuildTracePhase = tracePhase;
853
- }
854
- const writeBuildTrace = (buildPath2) => {
855
- if (!traceEnabled) {
856
- restoreTracePhase();
857
- return;
858
- }
859
- const traceDir = join2(buildPath2, ".absolute-trace");
860
- const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
861
- mkdirSync(traceDir, { recursive: true });
862
- writeFileSync(join2(traceDir, `build-trace-${timestamp}.json`), JSON.stringify({
863
- events: traceEvents,
864
- frameworks: traceFrameworkNames,
865
- generatedAt: new Date().toISOString(),
866
- mode: mode ?? (isDev ? "development" : "production"),
867
- totalDurationMs: performance.now() - buildStart,
868
- version: 1
869
- }, null, 2));
870
- restoreTracePhase();
871
- };
872
- await tracePhase("absolute/version", () => resolveAbsoluteVersion());
873
- const isIncremental = incrementalFiles && incrementalFiles.length > 0;
874
- const styleTransformConfig = createStyleTransformConfig(stylePreprocessors, postcss);
875
- const stylePreprocessorPlugin = createStylePreprocessorPlugin(styleTransformConfig);
876
- const normalizedIncrementalFiles = incrementalFiles?.map(normalizePath);
877
- const throwOnError = options?.throwOnError === true;
878
- const hmr = options?.injectHMR === true;
879
- const buildPath = validateSafePath(buildDirectory, projectRoot);
880
- const assetsPath = assetsDirectory && validateSafePath(assetsDirectory, projectRoot);
881
- const reactDir = reactDirectory && validateSafePath(reactDirectory, projectRoot);
882
- const htmlDir = htmlDirectory && validateSafePath(htmlDirectory, projectRoot);
883
- const htmxDir = htmxDirectory && validateSafePath(htmxDirectory, projectRoot);
884
- const svelteDir = svelteDirectory && validateSafePath(svelteDirectory, projectRoot);
885
- const vueDir = vueDirectory && validateSafePath(vueDirectory, projectRoot);
886
- const angularDir = angularDirectory && validateSafePath(angularDirectory, projectRoot);
887
- const islandBootstrapPath = islands?.bootstrap && validateSafePath(islands.bootstrap, projectRoot);
888
- const islandRegistryPath = islands?.registry && validateSafePath(islands.registry, projectRoot);
889
- const stylesPath = typeof stylesConfig === "string" ? stylesConfig : stylesConfig?.path;
890
- const stylesIgnore = typeof stylesConfig === "object" ? stylesConfig.ignore : undefined;
891
- const stylesDir = stylesPath && validateSafePath(stylesPath, projectRoot);
892
- const reactIndexesPath = reactDir && join2(reactDir, "generated", "indexes");
893
- const reactPagesPath = reactDir && join2(reactDir, "pages");
894
- const htmlPagesPath = htmlDir && join2(htmlDir, "pages");
895
- const htmlScriptsPath = htmlDir && join2(htmlDir, "scripts");
896
- const sveltePagesPath = svelteDir && join2(svelteDir, "pages");
897
- const vuePagesPath = vueDir && join2(vueDir, "pages");
898
- const htmxPagesPath = htmxDir && join2(htmxDir, "pages");
899
- const angularPagesPath = angularDir && join2(angularDir, "pages");
900
- const frontends = [
901
- reactDir,
902
- htmlDir,
903
- htmxDir,
904
- svelteDir,
905
- vueDir,
906
- angularDir
907
- ].filter(Boolean);
908
- const isSingle = frontends.length === 1;
909
- const frameworkNames = [
910
- reactDir && "react",
911
- htmlDir && "html",
912
- htmxDir && "htmx",
913
- svelteDir && "svelte",
914
- vueDir && "vue",
915
- angularDir && "angular"
916
- ].filter((name) => Boolean(name));
917
- traceFrameworkNames = frameworkNames;
918
- sendTelemetryEvent("build:start", {
919
- framework: frameworkNames[0],
920
- frameworks: frameworkNames,
921
- mode: mode ?? (isDev ? "development" : "production"),
922
- tailwind: Boolean(tailwind)
923
- });
924
- const sourceClientRoots = [
925
- reactDir,
926
- svelteDir,
927
- htmlDir,
928
- vueDir,
929
- angularDir,
930
- islandBootstrapPath && dirname(islandBootstrapPath)
931
- ].filter((dir) => Boolean(dir));
932
- const clientRoot = isSingle ? sourceClientRoots[0] ?? projectRoot : commonAncestor(sourceClientRoots, projectRoot);
933
- const serverDirMap = [];
934
- if (svelteDir)
935
- serverDirMap.push({
936
- dir: svelteDir,
937
- subdir: join2("generated", "server")
938
- });
939
- if (vueDir)
940
- serverDirMap.push({
941
- dir: vueDir,
942
- subdir: join2("generated", "server")
943
- });
944
- if (angularDir)
945
- serverDirMap.push({ dir: angularDir, subdir: "generated" });
946
- let serverOutDir;
947
- let serverRoot;
948
- if (serverDirMap.length === 1) {
949
- const [firstEntry] = serverDirMap;
950
- if (!firstEntry)
951
- throw new Error("Expected at least one server directory entry");
952
- serverRoot = join2(firstEntry.dir, firstEntry.subdir);
953
- serverOutDir = join2(buildPath, basename2(firstEntry.dir));
954
- } else if (serverDirMap.length > 1) {
955
- serverRoot = commonAncestor(serverDirMap.map((entry) => entry.dir), projectRoot);
956
- serverOutDir = buildPath;
957
- }
958
- const publicPath = publicDirectory && validateSafePath(publicDirectory, projectRoot);
959
- await tracePhase("build-dir/create", () => mkdirSync(buildPath, { recursive: true }));
960
- if (publicPath)
961
- await tracePhase("public/copy", () => cpSync(publicPath, buildPath, { force: true, recursive: true }));
962
- const filterToIncrementalEntries = (entryPoints, mapToSource) => {
963
- if (!isIncremental || !incrementalFiles)
964
- return entryPoints;
965
- const normalizedIncremental = new Set(incrementalFiles.map((f) => resolve3(f)));
966
- const matchingEntries = [];
967
- for (const entry of entryPoints) {
968
- const sourceFile = mapToSource(entry);
969
- if (!sourceFile)
970
- continue;
971
- if (!normalizedIncremental.has(resolve3(sourceFile)))
972
- continue;
973
- matchingEntries.push(entry);
974
- }
975
- return matchingEntries;
976
- };
977
- if (reactIndexesPath && reactPagesPath) {
978
- await tracePhase("react/index-generation", () => generateReactIndexFiles(reactPagesPath, reactIndexesPath, hmr));
979
- }
980
- if (assetsPath && (!isIncremental || normalizedIncrementalFiles?.some((f) => f.includes("/assets/")))) {
981
- await tracePhase("assets/copy", () => cpSync(assetsPath, join2(buildPath, "assets"), {
982
- force: true,
983
- recursive: true
984
- }));
985
- }
986
- const tailwindPromise = tailwind && (!isIncremental || normalizedIncrementalFiles?.some(isTailwindCandidate)) ? tracePhase("tailwind/build", () => compileTailwindConfig(tailwind, buildPath, styleTransformConfig)) : undefined;
987
- const emptyConventionResult = {
988
- conventions: undefined,
989
- pageFiles: []
990
- };
991
- const [
992
- ,
993
- allReactEntries,
994
- allHtmlEntries,
995
- reactConventionResult,
996
- svelteConventionResult,
997
- vueConventionResult,
998
- angularConventionResult,
999
- allGlobalCssEntries
1000
- ] = await Promise.all([
1001
- tailwindPromise,
1002
- reactIndexesPath ? tracePhase("scan/react-indexes", () => scanEntryPoints(reactIndexesPath, "*.tsx")) : [],
1003
- htmlScriptsPath ? tracePhase("scan/html-scripts", () => scanEntryPoints(htmlScriptsPath, "*.{js,ts}")) : [],
1004
- reactPagesPath ? tracePhase("scan/react-conventions", () => scanConventions(reactPagesPath, "*.tsx")) : emptyConventionResult,
1005
- sveltePagesPath ? tracePhase("scan/svelte-conventions", () => scanConventions(sveltePagesPath, "*.svelte")) : emptyConventionResult,
1006
- vuePagesPath ? tracePhase("scan/vue-conventions", () => scanConventions(vuePagesPath, "*.vue")) : emptyConventionResult,
1007
- angularPagesPath ? tracePhase("scan/angular-conventions", () => scanConventions(angularPagesPath, "*.ts")) : emptyConventionResult,
1008
- stylesDir ? tracePhase("scan/css", () => scanCssEntryPoints(stylesDir, stylesIgnore)) : []
1009
- ]);
1010
- const allSvelteEntries = svelteConventionResult.pageFiles;
1011
- const allVueEntries = vueConventionResult.pageFiles;
1012
- const allAngularEntries = angularConventionResult.pageFiles;
1013
- const conventionsMap = {};
1014
- if (reactConventionResult.conventions)
1015
- conventionsMap.react = reactConventionResult.conventions;
1016
- if (svelteConventionResult.conventions)
1017
- conventionsMap.svelte = svelteConventionResult.conventions;
1018
- if (vueConventionResult.conventions)
1019
- conventionsMap.vue = vueConventionResult.conventions;
1020
- if (angularConventionResult.conventions)
1021
- conventionsMap.angular = angularConventionResult.conventions;
1022
- const notFoundFrameworks = ["react", "svelte", "vue", "angular"].filter((framework) => conventionsMap[framework]?.defaults?.notFound);
1023
- if (notFoundFrameworks.length > 1) {
1024
- logWarn(`Multiple frameworks define not-found convention files: ${notFoundFrameworks.join(", ")}. Only one will be used (priority: ${notFoundFrameworks[0]}). Remove not-found files from other frameworks to avoid ambiguity.`);
1025
- }
1026
- const shouldIncludeHtmlAssets = !isIncremental || normalizedIncrementalFiles?.some((f) => f.includes("/html/") && (f.endsWith(".html") || isStylePath(f)));
1027
- const reactEntries = isIncremental && reactIndexesPath && reactPagesPath ? filterToIncrementalEntries(allReactEntries, (entry) => {
1028
- if (entry.startsWith(resolve3(reactIndexesPath))) {
1029
- const pageName = basename2(entry, ".tsx");
1030
- return join2(reactPagesPath, `${pageName}.tsx`);
1031
- }
1032
- return null;
1033
- }) : allReactEntries;
1034
- const htmlEntries = isIncremental && htmlScriptsPath && !shouldIncludeHtmlAssets ? filterToIncrementalEntries(allHtmlEntries, (entry) => entry) : allHtmlEntries;
1035
- const svelteEntries = isIncremental ? filterToIncrementalEntries(allSvelteEntries, (entry) => entry) : allSvelteEntries;
1036
- const vueEntries = isIncremental ? filterToIncrementalEntries(allVueEntries, (entry) => entry) : allVueEntries;
1037
- const angularEntries = isIncremental ? filterToIncrementalEntries(allAngularEntries, (entry) => entry) : allAngularEntries;
1038
- const globalCssEntries = isIncremental ? filterToIncrementalEntries(allGlobalCssEntries, (entry) => entry) : allGlobalCssEntries;
1039
- const hmrClientBundlePromise = hmr && (htmlDir || htmxDir) ? buildHMRClient() : undefined;
1040
- const allFrameworkDirs = [
1041
- reactDir,
1042
- svelteDir,
1043
- vueDir,
1044
- angularDir,
1045
- htmlDir,
1046
- htmxDir
1047
- ].filter((dir) => Boolean(dir));
1048
- const urlReferencedFilesPromise = tracePhase("scan/worker-references", () => scanWorkerReferences(allFrameworkDirs));
1049
- const shouldCompileSvelte = svelteDir && svelteEntries.length > 0;
1050
- const shouldCompileVue = vueDir && vueEntries.length > 0;
1051
- const shouldCompileAngular = angularDir && angularEntries.length > 0;
1052
- const emptyStringArray = [];
1053
- const islandBuildInfo = islandRegistryPath ? await tracePhase("islands/registry", () => loadIslandRegistryBuildInfo(islandRegistryPath)) : null;
1054
- const islandFrameworkSources = islandBuildInfo ? collectIslandFrameworkSources(islandBuildInfo) : {};
1055
- const islandSvelteSources = islandFrameworkSources.svelte ?? emptyStringArray;
1056
- const islandVueSources = islandFrameworkSources.vue ?? emptyStringArray;
1057
- const islandAngularSources = islandFrameworkSources.angular ?? emptyStringArray;
1058
- const shouldCompileIslandSvelte = svelteDir && islandSvelteSources.length > 0;
1059
- const shouldCompileIslandVue = vueDir && islandVueSources.length > 0;
1060
- const shouldCompileIslandAngular = angularDir && islandAngularSources.length > 0;
1061
- const [
1062
- { svelteServerPaths, svelteIndexPaths, svelteClientPaths },
1063
- { vueServerPaths, vueIndexPaths, vueClientPaths, vueCssPaths },
1064
- { clientPaths: angularClientPaths, serverPaths: angularServerPaths },
1065
- { svelteClientPaths: islandSvelteClientPaths },
1066
- { vueClientPaths: islandVueClientPaths },
1067
- { clientPaths: islandAngularClientPaths }
1068
- ] = await Promise.all([
1069
- shouldCompileSvelte ? tracePhase("compile/svelte", () => import("./chunk-x09cskqd.js").then((mod) => mod.compileSvelte(svelteEntries, svelteDir, new Map, hmr, styleTransformConfig))) : {
1070
- svelteClientPaths: [...emptyStringArray],
1071
- svelteIndexPaths: [...emptyStringArray],
1072
- svelteServerPaths: [...emptyStringArray]
1073
- },
1074
- shouldCompileVue ? tracePhase("compile/vue", () => import("./chunk-5f67rsed.js").then((mod) => mod.compileVue(vueEntries, vueDir, hmr, styleTransformConfig))) : {
1075
- vueClientPaths: [...emptyStringArray],
1076
- vueCssPaths: [...emptyStringArray],
1077
- vueIndexPaths: [...emptyStringArray],
1078
- vueServerPaths: [...emptyStringArray]
1079
- },
1080
- shouldCompileAngular ? tracePhase("compile/angular", () => import("./chunk-92fsjfpp.js").then((mod) => mod.compileAngular(angularEntries, angularDir, hmr, styleTransformConfig))) : {
1081
- clientPaths: [...emptyStringArray],
1082
- serverPaths: [...emptyStringArray]
1083
- },
1084
- shouldCompileIslandSvelte ? tracePhase("compile/island-svelte", () => import("./chunk-x09cskqd.js").then((mod) => mod.compileSvelte(islandSvelteSources, svelteDir, new Map, hmr, styleTransformConfig))) : {
1085
- svelteClientPaths: [...emptyStringArray]
1086
- },
1087
- shouldCompileIslandVue ? tracePhase("compile/island-vue", () => import("./chunk-5f67rsed.js").then((mod) => mod.compileVue(islandVueSources, vueDir, hmr, styleTransformConfig))) : {
1088
- vueClientPaths: [...emptyStringArray]
1089
- },
1090
- shouldCompileIslandAngular ? tracePhase("compile/island-angular", () => import("./chunk-92fsjfpp.js").then((mod) => mod.compileAngular(islandAngularSources, angularDir, hmr, styleTransformConfig))) : {
1091
- clientPaths: [...emptyStringArray]
1092
- }
1093
- ]);
1094
- const islandSvelteClientPathMap = new Map;
1095
- for (let idx = 0;idx < islandSvelteSources.length; idx++) {
1096
- const sourcePath = islandSvelteSources[idx];
1097
- const clientPath = islandSvelteClientPaths[idx];
1098
- if (!sourcePath || !clientPath)
1099
- continue;
1100
- islandSvelteClientPathMap.set(resolve3(sourcePath), clientPath);
1101
- }
1102
- const islandVueClientPathMap = new Map;
1103
- for (let idx = 0;idx < islandVueSources.length; idx++) {
1104
- const sourcePath = islandVueSources[idx];
1105
- const clientPath = islandVueClientPaths[idx];
1106
- if (!sourcePath || !clientPath)
1107
- continue;
1108
- islandVueClientPathMap.set(resolve3(sourcePath), clientPath);
1109
- }
1110
- const islandAngularClientPathMap = new Map;
1111
- for (let idx = 0;idx < islandAngularSources.length; idx++) {
1112
- const sourcePath = islandAngularSources[idx];
1113
- const clientPath = islandAngularClientPaths[idx];
1114
- if (!sourcePath || !clientPath)
1115
- continue;
1116
- islandAngularClientPathMap.set(resolve3(sourcePath), clientPath);
1117
- }
1118
- const reactConventionSources = collectConventionSourceFiles(conventionsMap.react);
1119
- const svelteConventionSources = collectConventionSourceFiles(conventionsMap.svelte);
1120
- const vueConventionSources = collectConventionSourceFiles(conventionsMap.vue);
1121
- const angularConventionSources = collectConventionSourceFiles(conventionsMap.angular);
1122
- let conventionOutputPaths = [];
1123
- if (reactConventionSources.length > 0 || svelteConventionSources.length > 0 || vueConventionSources.length > 0 || angularConventionSources.length > 0) {
1124
- const compileReactConventions = async () => {
1125
- if (reactConventionSources.length === 0)
1126
- return emptyStringArray;
1127
- const destDir = join2(buildPath, "conventions", "react");
1128
- rmSync(destDir, { force: true, recursive: true });
1129
- mkdirSync(destDir, { recursive: true });
1130
- const destPaths = [];
1131
- for (let idx = 0;idx < reactConventionSources.length; idx++) {
1132
- const source = reactConventionSources[idx];
1133
- if (!source)
1134
- continue;
1135
- const result = await bunBuild2({
1136
- entrypoints: [source],
1137
- format: "esm",
1138
- jsx: { development: false },
1139
- minify: !isDev,
1140
- naming: `${idx}-[name].[ext]`,
1141
- outdir: destDir,
1142
- plugins: [stylePreprocessorPlugin],
1143
- root: dirname(source),
1144
- target: "bun",
1145
- throw: false,
1146
- tsconfig: "./tsconfig.json"
1147
- });
1148
- if (!result.success) {
1149
- outputLogs(result.logs);
1150
- throw new Error(`Failed to compile React convention: ${source}`);
1151
- }
1152
- const output = result.outputs.find((artifact) => artifact.path.endsWith(".js"));
1153
- if (!output)
1154
- throw new Error(`React convention did not emit JavaScript: ${source}`);
1155
- destPaths.push(output.path);
1156
- }
1157
- return destPaths;
1158
- };
1159
- const [
1160
- reactConvPaths,
1161
- svelteConvResult,
1162
- vueConvResult,
1163
- angularConvResult
1164
- ] = await Promise.all([
1165
- tracePhase("compile/convention-react", compileReactConventions),
1166
- svelteConventionSources.length > 0 && svelteDir ? tracePhase("compile/convention-svelte", () => import("./chunk-x09cskqd.js").then((mod) => mod.compileSvelte(svelteConventionSources, svelteDir, new Map, false, styleTransformConfig))) : { svelteServerPaths: emptyStringArray },
1167
- vueConventionSources.length > 0 && vueDir ? tracePhase("compile/convention-vue", () => import("./chunk-5f67rsed.js").then((mod) => mod.compileVue(vueConventionSources, vueDir, false, styleTransformConfig))) : { vueServerPaths: emptyStringArray },
1168
- angularConventionSources.length > 0 && angularDir ? tracePhase("compile/convention-angular", () => import("./chunk-92fsjfpp.js").then((mod) => mod.compileAngular(angularConventionSources, angularDir, hmr, styleTransformConfig))) : { serverPaths: emptyStringArray }
1169
- ]);
1170
- const bundleConventionFiles = async (framework, compiledPaths) => {
1171
- const destDir = join2(buildPath, "conventions", framework);
1172
- rmSync(destDir, { force: true, recursive: true });
1173
- mkdirSync(destDir, { recursive: true });
1174
- const destPaths = [];
1175
- for (let idx = 0;idx < compiledPaths.length; idx++) {
1176
- const compiledPath = compiledPaths[idx];
1177
- if (!compiledPath)
1178
- continue;
1179
- const name = basename2(compiledPath).replace(/\.[^.]+$/, "");
1180
- const result = await bunBuild2({
1181
- entrypoints: [compiledPath],
1182
- format: "esm",
1183
- minify: !isDev,
1184
- naming: `${idx}-${name}.[ext]`,
1185
- outdir: destDir,
1186
- splitting: false,
1187
- target: "bun",
1188
- throw: false
1189
- });
1190
- if (!result.success) {
1191
- outputLogs(result.logs);
1192
- throw new Error(`Failed to bundle ${framework} convention: ${compiledPath}`);
1193
- }
1194
- const output = result.outputs.find((artifact) => artifact.path.endsWith(".js"));
1195
- if (!output)
1196
- throw new Error(`${framework} convention did not emit JavaScript: ${compiledPath}`);
1197
- destPaths.push(output.path);
1198
- }
1199
- return destPaths;
1200
- };
1201
- const [svelteDests, vueDests, angularDests] = await Promise.all([
1202
- tracePhase("bundle/convention-svelte", () => bundleConventionFiles("svelte", svelteConvResult.svelteServerPaths)),
1203
- tracePhase("bundle/convention-vue", () => bundleConventionFiles("vue", vueConvResult.vueServerPaths)),
1204
- tracePhase("bundle/convention-angular", () => bundleConventionFiles("angular", angularConvResult.serverPaths))
1205
- ]);
1206
- conventionOutputPaths = [
1207
- ...reactConvPaths,
1208
- ...svelteDests,
1209
- ...vueDests,
1210
- ...angularDests
1211
- ];
1212
- updateConventionCompiledPaths(conventionsMap.react, reactConventionSources, reactConvPaths);
1213
- updateConventionCompiledPaths(conventionsMap.svelte, svelteConventionSources, svelteDests);
1214
- updateConventionCompiledPaths(conventionsMap.vue, vueConventionSources, vueDests);
1215
- updateConventionCompiledPaths(conventionsMap.angular, angularConventionSources, angularDests);
1216
- }
1217
- const serverEntryPoints = [
1218
- ...svelteServerPaths,
1219
- ...vueServerPaths,
1220
- ...angularServerPaths
1221
- ];
1222
- const reactClientEntryPoints = [...reactEntries];
1223
- const urlReferencedFiles = await urlReferencedFilesPromise;
1224
- const nonReactClientEntryPoints = [
1225
- ...svelteIndexPaths,
1226
- ...svelteClientPaths,
1227
- ...htmlEntries,
1228
- ...vueIndexPaths,
1229
- ...vueClientPaths,
1230
- ...angularClientPaths,
1231
- ...islandBootstrapPath ? [islandBootstrapPath] : [],
1232
- ...urlReferencedFiles
1233
- ];
1234
- const islandEntryResult = islandBuildInfo ? await tracePhase("islands/client-entry-generation", () => generateIslandEntryPoints({
1235
- buildInfo: islandBuildInfo,
1236
- buildPath,
1237
- clientPathMaps: {
1238
- angular: islandAngularClientPathMap,
1239
- svelte: islandSvelteClientPathMap,
1240
- vue: islandVueClientPathMap
1241
- }
1242
- })) : {
1243
- entries: [],
1244
- generatedRoot: join2(buildPath, "_island_entries")
1245
- };
1246
- const islandClientEntryPoints = islandEntryResult.entries.map((entry) => entry.entryPath);
1247
- if (serverEntryPoints.length === 0 && reactClientEntryPoints.length === 0 && nonReactClientEntryPoints.length === 0 && islandClientEntryPoints.length === 0 && htmxDir === undefined && htmlDir === undefined) {
1248
- logWarn("No entry points found, manifest will be empty");
1249
- sendTelemetryEvent("build:empty", {
1250
- configuredDirs: {
1251
- angular: Boolean(angularDir),
1252
- html: Boolean(htmlDir),
1253
- htmx: Boolean(htmxDir),
1254
- react: Boolean(reactDir),
1255
- svelte: Boolean(svelteDir),
1256
- vue: Boolean(vueDir)
1257
- },
1258
- filteredEntries: {
1259
- angular: angularEntries.length,
1260
- html: htmlEntries.length,
1261
- react: reactEntries.length,
1262
- svelte: svelteEntries.length,
1263
- vue: vueEntries.length
1264
- },
1265
- frameworks: frameworkNames,
1266
- incremental: Boolean(isIncremental),
1267
- mode: mode ?? (isDev ? "development" : "production"),
1268
- scannedEntries: {
1269
- angular: allAngularEntries.length,
1270
- html: allHtmlEntries.length,
1271
- react: allReactEntries.length,
1272
- svelte: allSvelteEntries.length,
1273
- vue: allVueEntries.length
1274
- }
1275
- });
1276
- writeBuildTrace(buildPath);
1277
- return {};
1278
- }
1279
- if (hmr && reactIndexesPath && reactClientEntryPoints.length > 0) {
1280
- const refreshEntry = join2(reactIndexesPath, "_refresh.tsx");
1281
- if (!reactClientEntryPoints.includes(refreshEntry))
1282
- reactClientEntryPoints.push(refreshEntry);
1283
- }
1284
- let vendorPaths = getDevVendorPaths();
1285
- if (!vendorPaths && hmr && reactDir) {
1286
- const { computeVendorPaths: computeVendorPaths2 } = await import("./chunk-z9nvhm6r.js");
1287
- vendorPaths = computeVendorPaths2();
1288
- setDevVendorPaths(vendorPaths);
1289
- }
1290
- let angularVendorPaths = getAngularVendorPaths();
1291
- if (!angularVendorPaths && hmr && angularDir) {
1292
- const { computeAngularVendorPaths: computeAngularVendorPaths2 } = await import("./chunk-r6e8pytx.js");
1293
- angularVendorPaths = computeAngularVendorPaths2(globalThis.__angularVendorSpecifiers);
1294
- setAngularVendorPaths(angularVendorPaths);
1295
- }
1296
- let angularServerVendorPaths = getAngularServerVendorPaths();
1297
- if (!angularServerVendorPaths && hmr && angularDir) {
1298
- const { computeAngularServerVendorPaths: computeAngularServerVendorPaths2 } = await import("./chunk-r6e8pytx.js");
1299
- angularServerVendorPaths = computeAngularServerVendorPaths2(buildPath, globalThis.__angularVendorSpecifiers ?? []);
1300
- setAngularServerVendorPaths(angularServerVendorPaths);
1301
- }
1302
- if (!hmr && angularDir) {
1303
- const angularSourceDirs = [
1304
- angularDir,
1305
- reactDir,
1306
- svelteDir,
1307
- vueDir,
1308
- htmlDir,
1309
- htmxDir
1310
- ].filter((dir) => Boolean(dir));
1311
- const {
1312
- buildAngularVendor: buildAngularVendor2,
1313
- buildAngularServerVendor: buildAngularServerVendor2,
1314
- computeAngularVendorPathsAsync: computeAngularVendorPathsAsync2,
1315
- computeAngularServerVendorPathsAsync: computeAngularServerVendorPathsAsync2
1316
- } = await import("./chunk-r6e8pytx.js");
1317
- [angularVendorPaths, angularServerVendorPaths] = await Promise.all([
1318
- computeAngularVendorPathsAsync2(angularSourceDirs, false),
1319
- computeAngularServerVendorPathsAsync2(buildPath, angularSourceDirs, false)
1320
- ]);
1321
- setAngularVendorPaths(angularVendorPaths);
1322
- setAngularServerVendorPaths(angularServerVendorPaths);
1323
- await Promise.all([
1324
- buildAngularVendor2(buildPath, angularSourceDirs, false, []),
1325
- buildAngularServerVendor2(buildPath, angularSourceDirs, false)
1326
- ]);
1327
- process.env.ABSOLUTE_BUILD_DIR ??= buildPath;
1328
- }
1329
- let vueVendorPaths = getVueVendorPaths();
1330
- if (!vueVendorPaths && hmr && vueDir) {
1331
- const { computeVueVendorPaths: computeVueVendorPaths2 } = await import("./chunk-6qjbrt0k.js");
1332
- vueVendorPaths = computeVueVendorPaths2();
1333
- setVueVendorPaths(vueVendorPaths);
1334
- }
1335
- let svelteVendorPaths = getSvelteVendorPaths();
1336
- if (!svelteVendorPaths && hmr && svelteDir) {
1337
- const { computeSvelteVendorPaths: computeSvelteVendorPaths2 } = await import("./chunk-2ga2znex.js");
1338
- svelteVendorPaths = computeSvelteVendorPaths2();
1339
- setSvelteVendorPaths(svelteVendorPaths);
1340
- }
1341
- const depVendorPaths = hmr && globalThis.__depVendorPaths ? globalThis.__depVendorPaths : {};
1342
- const reactExternalPaths = {
1343
- ...vendorPaths ?? {},
1344
- ...depVendorPaths
1345
- };
1346
- const nonReactExternalPaths = {
1347
- ...reactExternalPaths,
1348
- ...angularVendorPaths ?? {},
1349
- ...vueVendorPaths ?? {},
1350
- ...svelteVendorPaths ?? {}
1351
- };
1352
- const serverBuildExternals = [
1353
- "react",
1354
- "react/*",
1355
- "react-dom",
1356
- "react-dom/*",
1357
- "svelte",
1358
- "svelte/*",
1359
- "vue",
1360
- "vue/*",
1361
- "@angular/*",
1362
- "typescript"
1363
- ];
1364
- const htmlScriptPlugin = hmr ? createHTMLScriptHMRPlugin(htmlDir, htmxDir) : undefined;
1365
- const reactBuildConfig = reactClientEntryPoints.length > 0 ? mergeBunBuildConfig({
1366
- entrypoints: reactClientEntryPoints,
1367
- ...Object.keys(reactExternalPaths).length > 0 ? { external: Object.keys(reactExternalPaths) } : {},
1368
- format: "esm",
1369
- minify: !isDev,
1370
- naming: `[dir]/[name].[hash].[ext]`,
1371
- outdir: buildPath,
1372
- ...hmr ? {
1373
- jsx: { development: true },
1374
- reactFastRefresh: true
1375
- } : {},
1376
- plugins: [stylePreprocessorPlugin],
1377
- root: clientRoot,
1378
- splitting: true,
1379
- target: "browser",
1380
- throw: false
1381
- }, resolveBunBuildOverride(bunBuildConfig, "reactClient")) : undefined;
1382
- if (reactDir && reactClientEntryPoints.length > 0) {
1383
- rmSync(join2(buildPath, "react", "generated", "indexes"), {
1384
- force: true,
1385
- recursive: true
1386
- });
1387
- }
1388
- if (angularDir && angularClientPaths.length > 0) {
1389
- rmSync(join2(buildPath, "angular", "indexes"), {
1390
- force: true,
1391
- recursive: true
1392
- });
1393
- }
1394
- if (islandClientEntryPoints.length > 0) {
1395
- rmSync(join2(buildPath, "islands"), {
1396
- force: true,
1397
- recursive: true
1398
- });
1399
- }
1400
- const [
1401
- serverResult,
1402
- reactClientResult,
1403
- nonReactClientResult,
1404
- islandClientResult,
1405
- globalCssResult,
1406
- vueCssResult
1407
- ] = await Promise.all([
1408
- serverEntryPoints.length > 0 ? tracePhase("bun/server", () => bunBuild2(mergeBunBuildConfig({
1409
- entrypoints: serverEntryPoints,
1410
- external: serverBuildExternals,
1411
- format: "esm",
1412
- naming: `[dir]/[name].[hash].[ext]`,
1413
- outdir: serverOutDir,
1414
- plugins: [stylePreprocessorPlugin],
1415
- root: serverRoot,
1416
- target: "bun",
1417
- throw: false,
1418
- tsconfig: "./tsconfig.json"
1419
- }, resolveBunBuildOverride(bunBuildConfig, "server")))) : undefined,
1420
- reactBuildConfig ? tracePhase("bun/react-client", () => bunBuild2(reactBuildConfig)) : undefined,
1421
- nonReactClientEntryPoints.length > 0 ? tracePhase("bun/non-react-client", () => bunBuild2(mergeBunBuildConfig({
1422
- define: vueDirectory ? vueFeatureFlags : undefined,
1423
- entrypoints: nonReactClientEntryPoints,
1424
- external: Object.keys(nonReactExternalPaths),
1425
- format: "esm",
1426
- minify: !isDev,
1427
- naming: `[dir]/[name].[hash].[ext]`,
1428
- outdir: buildPath,
1429
- plugins: [
1430
- stylePreprocessorPlugin,
1431
- ...angularDir ? [createAngularLinkerPlugin(hmr)] : [],
1432
- ...htmlScriptPlugin ? [htmlScriptPlugin] : []
1433
- ],
1434
- root: clientRoot,
1435
- splitting: !isDev,
1436
- target: "browser",
1437
- throw: false,
1438
- tsconfig: "./tsconfig.json"
1439
- }, resolveBunBuildOverride(bunBuildConfig, "nonReactClient")))) : undefined,
1440
- islandClientEntryPoints.length > 0 ? tracePhase("bun/island-client", () => bunBuild2(mergeBunBuildConfig({
1441
- define: vueDirectory ? vueFeatureFlags : undefined,
1442
- entrypoints: islandClientEntryPoints,
1443
- external: Object.keys(nonReactExternalPaths),
1444
- format: "esm",
1445
- minify: !isDev,
1446
- naming: `[dir]/[name].[hash].[ext]`,
1447
- outdir: buildPath,
1448
- plugins: [
1449
- stylePreprocessorPlugin,
1450
- ...angularDir ? [createAngularLinkerPlugin(hmr)] : []
1451
- ],
1452
- root: islandEntryResult.generatedRoot,
1453
- splitting: !isDev,
1454
- target: "browser",
1455
- throw: false,
1456
- tsconfig: "./tsconfig.json"
1457
- }, resolveBunBuildOverride(bunBuildConfig, "islandClient")))) : undefined,
1458
- globalCssEntries.length > 0 ? tracePhase("bun/global-css", () => bunBuild2(mergeBunBuildConfig({
1459
- entrypoints: globalCssEntries,
1460
- naming: `[dir]/[name].[hash].[ext]`,
1461
- outdir: stylesDir ? join2(buildPath, basename2(stylesDir)) : buildPath,
1462
- plugins: [stylePreprocessorPlugin],
1463
- root: stylesDir || clientRoot,
1464
- target: "browser",
1465
- throw: false
1466
- }, resolveBunBuildOverride(bunBuildConfig, "globalCss")))) : undefined,
1467
- vueCssPaths.length > 0 ? tracePhase("bun/vue-css", () => bunBuild2(mergeBunBuildConfig({
1468
- entrypoints: vueCssPaths,
1469
- naming: `[name].[hash].[ext]`,
1470
- outdir: join2(buildPath, assetsPath ? basename2(assetsPath) : "assets", "css"),
1471
- target: "browser",
1472
- throw: false
1473
- }, resolveBunBuildOverride(bunBuildConfig, "vueCss")))) : undefined
1474
- ]);
1475
- const serverLogs = serverResult?.logs ?? [];
1476
- const serverOutputs = serverResult?.outputs ?? [];
1477
- if (serverResult && !serverResult.success && serverLogs.length > 0) {
1478
- extractBuildError(serverLogs, "server", "Server", frameworkNames, isIncremental, throwOnError);
1479
- }
1480
- const reactClientLogs = reactClientResult?.logs ?? [];
1481
- const reactClientOutputs = reactClientResult?.outputs ?? [];
1482
- if (reactClientResult && !reactClientResult.success && reactClientLogs.length > 0) {
1483
- extractBuildError(reactClientLogs, "react-client", "React client", frameworkNames, isIncremental, throwOnError);
1484
- }
1485
- const reactClientOutputPaths = reactClientOutputs.map((artifact) => artifact.path);
1486
- if (vendorPaths && reactClientOutputPaths.length > 0) {
1487
- await tracePhase("postprocess/react-imports", () => rewriteReactImports(reactClientOutputPaths, vendorPaths));
1488
- }
1489
- if (hmr && reactClientOutputPaths.length > 0) {
1490
- await tracePhase("postprocess/react-refresh-globals", () => patchRefreshGlobals(reactClientOutputPaths));
1491
- }
1492
- const nonReactClientLogs = nonReactClientResult?.logs ?? [];
1493
- const nonReactClientOutputs = nonReactClientResult?.outputs ?? [];
1494
- const nonReactClientOutputPaths = nonReactClientOutputs.map((artifact) => artifact.path);
1495
- const islandClientLogs = islandClientResult?.logs ?? [];
1496
- const islandClientOutputs = islandClientResult?.outputs ?? [];
1497
- const islandClientOutputPaths = islandClientOutputs.map((artifact) => artifact.path);
1498
- if (vendorPaths && nonReactClientOutputPaths.length > 0) {
1499
- await tracePhase("postprocess/non-react-react-imports", () => rewriteReactImports(nonReactClientOutputPaths, vendorPaths));
1500
- }
1501
- if (hmr && nonReactClientOutputPaths.length > 0) {
1502
- await tracePhase("postprocess/non-react-refresh-globals", () => patchRefreshGlobals(nonReactClientOutputPaths));
1503
- }
1504
- if (vendorPaths && islandClientOutputPaths.length > 0) {
1505
- await tracePhase("postprocess/island-react-imports", () => rewriteReactImports(islandClientOutputPaths, vendorPaths));
1506
- }
1507
- if (hmr && islandClientOutputPaths.length > 0) {
1508
- await tracePhase("postprocess/island-refresh-globals", () => patchRefreshGlobals(islandClientOutputPaths));
1509
- }
1510
- if (nonReactClientResult && !nonReactClientResult.success && nonReactClientLogs.length > 0) {
1511
- extractBuildError(nonReactClientLogs, "non-react-client", "Non-React client", frameworkNames, isIncremental, throwOnError);
1512
- }
1513
- if (islandClientResult && !islandClientResult.success && islandClientLogs.length > 0) {
1514
- extractBuildError(islandClientLogs, "island-client", "Island client", frameworkNames, isIncremental, throwOnError);
1515
- }
1516
- const allNonReactVendorPaths = {
1517
- ...depVendorPaths,
1518
- ...angularVendorPaths ?? {},
1519
- ...vueVendorPaths ?? {},
1520
- ...svelteVendorPaths ?? {}
1521
- };
1522
- const allIslandVendorPaths = {
1523
- ...reactExternalPaths,
1524
- ...allNonReactVendorPaths
1525
- };
1526
- if (nonReactClientOutputs.length > 0 && Object.keys(allNonReactVendorPaths).length > 0) {
1527
- const { rewriteImports } = await import("./chunk-r7jmgqnw.js");
1528
- await tracePhase("postprocess/non-react-vendor-imports", () => rewriteImports(nonReactClientOutputs.map((artifact) => artifact.path), allNonReactVendorPaths));
1529
- }
1530
- if (islandClientOutputs.length > 0 && Object.keys(allIslandVendorPaths).length > 0) {
1531
- const { rewriteImports } = await import("./chunk-r7jmgqnw.js");
1532
- await tracePhase("postprocess/island-vendor-imports", () => rewriteImports(islandClientOutputs.map((artifact) => artifact.path), allIslandVendorPaths));
1533
- }
1534
- if (serverOutputs.length > 0 && angularServerVendorPaths && Object.keys(angularServerVendorPaths).length > 0) {
1535
- const { rewriteImports } = await import("./chunk-r7jmgqnw.js");
1536
- await tracePhase("postprocess/server-angular-vendor-imports", () => rewriteImports(serverOutputs.filter((artifact) => artifact.path.endsWith(".js")).map((artifact) => artifact.path), angularServerVendorPaths));
1537
- }
1538
- const cssLogs = [
1539
- ...globalCssResult?.logs ?? [],
1540
- ...vueCssResult?.logs ?? []
1541
- ];
1542
- const cssOutputs = [
1543
- ...globalCssResult?.outputs ?? [],
1544
- ...vueCssResult?.outputs ?? []
1545
- ];
1546
- if (globalCssResult && !globalCssResult.success && globalCssResult.logs.length > 0) {
1547
- extractBuildError(globalCssResult.logs, "global-css", "Global CSS", frameworkNames, isIncremental, throwOnError);
1548
- }
1549
- if (vueCssResult && !vueCssResult.success && vueCssResult.logs.length > 0) {
1550
- extractBuildError(vueCssResult.logs, "vue-css", "Vue CSS", frameworkNames, isIncremental, throwOnError);
1551
- }
1552
- const allClientOutputPaths = [
1553
- ...reactClientOutputPaths,
1554
- ...nonReactClientOutputs.map((artifact) => artifact.path)
1555
- ];
1556
- if (urlReferencedFiles.length > 0) {
1557
- const urlFileMap = buildUrlFileMap(urlReferencedFiles, hmr, projectRoot, buildPath, nonReactClientOutputs);
1558
- await tracePhase("postprocess/url-references", () => rewriteUrlReferences(allClientOutputPaths, urlFileMap));
1559
- }
1560
- const vueOutputPaths = nonReactClientOutputs.map((artifact) => artifact.path).filter((path) => path.includes("/vue/"));
1561
- if (hmr && vueDirectory) {
1562
- await tracePhase("postprocess/vue-hmr", () => vueOutputPaths.forEach((outputPath) => injectVueComposableTracking(outputPath, projectRoot)));
1563
- }
1564
- const allLogs = [
1565
- ...serverLogs,
1566
- ...reactClientLogs,
1567
- ...nonReactClientLogs,
1568
- ...islandClientLogs,
1569
- ...cssLogs
1570
- ];
1571
- outputLogs(allLogs);
1572
- const manifest = {
1573
- ...options?.baseManifest || {},
1574
- ...generateManifest([
1575
- ...serverOutputs,
1576
- ...reactClientOutputs,
1577
- ...nonReactClientOutputs,
1578
- ...islandClientOutputs,
1579
- ...cssOutputs
1580
- ], buildPath)
1581
- };
1582
- for (const artifact of serverOutputs) {
1583
- if (extname(artifact.path) !== ".js")
1584
- continue;
1585
- const fileWithHash = basename2(artifact.path);
1586
- const [baseName] = fileWithHash.split(`.${artifact.hash}.`);
1587
- if (!baseName)
1588
- continue;
1589
- manifest[toPascal(baseName)] = artifact.path;
1590
- }
1591
- const shouldCopyHtmx = !isIncremental || normalizedIncrementalFiles?.some((f) => f.includes("/htmx/") && f.endsWith(".html"));
1592
- const shouldUpdateHtmlAssetPaths = !isIncremental || normalizedIncrementalFiles?.some((f) => f.includes("/html/") && (f.endsWith(".html") || isStylePath(f)));
1593
- const shouldUpdateHtmxAssetPaths = !isIncremental || normalizedIncrementalFiles?.some((f) => f.includes("/htmx/") && (f.endsWith(".html") || isStylePath(f)));
1594
- const hmrClientBundle = hmrClientBundlePromise ? await hmrClientBundlePromise : null;
1595
- const injectHMRIntoHTMLFile = (filePath, framework) => {
1596
- if (!hmrClientBundle)
1597
- return;
1598
- let html = readFileSync(filePath, "utf-8");
1599
- if (html.includes("data-hmr-client"))
1600
- return;
1601
- const tag = `<script>window.__HMR_FRAMEWORK__="${framework}";</script><script data-hmr-client>${hmrClientBundle}</script>`;
1602
- const bodyClose = /<\/body\s*>/i.exec(html);
1603
- html = bodyClose ? html.slice(0, bodyClose.index) + tag + html.slice(bodyClose.index) : html + tag;
1604
- writeFileSync(filePath, html);
1605
- };
1606
- const processHtmlPages = async () => {
1607
- if (!(htmlDir && htmlPagesPath))
1608
- return;
1609
- const outputHtmlPages = isSingle ? join2(buildPath, "pages") : join2(buildPath, basename2(htmlDir), "pages");
1610
- mkdirSync(outputHtmlPages, { recursive: true });
1611
- cpSync(htmlPagesPath, outputHtmlPages, {
1612
- force: true,
1613
- recursive: true
1614
- });
1615
- if (shouldUpdateHtmlAssetPaths) {
1616
- await updateAssetPaths(manifest, outputHtmlPages);
1617
- await optimizeHtmlImages(outputHtmlPages);
1618
- }
1619
- const htmlPageFiles = await scanEntryPoints(outputHtmlPages, "*.html");
1620
- await transformStaticPagesWithIslands(islandRegistryPath, htmlPageFiles);
1621
- for (const htmlFile of htmlPageFiles) {
1622
- if (hmr)
1623
- injectHMRIntoHTMLFile(htmlFile, "html");
1624
- const fileName = basename2(htmlFile, ".html");
1625
- manifest[fileName] = htmlFile;
1626
- }
1627
- };
1628
- const processHtmxPages = async () => {
1629
- if (!(htmxDir && htmxPagesPath))
1630
- return;
1631
- const outputHtmxPages = isSingle ? join2(buildPath, "pages") : join2(buildPath, basename2(htmxDir), "pages");
1632
- mkdirSync(outputHtmxPages, { recursive: true });
1633
- cpSync(htmxPagesPath, outputHtmxPages, {
1634
- force: true,
1635
- recursive: true
1636
- });
1637
- if (shouldCopyHtmx) {
1638
- const htmxDestDir = isSingle ? buildPath : join2(buildPath, basename2(htmxDir));
1639
- copyHtmxVendor(htmxDir, htmxDestDir);
1640
- }
1641
- if (shouldUpdateHtmxAssetPaths) {
1642
- await updateAssetPaths(manifest, outputHtmxPages);
1643
- await optimizeHtmlImages(outputHtmxPages);
1644
- }
1645
- const htmxPageFiles = await scanEntryPoints(outputHtmxPages, "*.html");
1646
- await transformStaticPagesWithIslands(islandRegistryPath, htmxPageFiles);
1647
- for (const htmxFile of htmxPageFiles) {
1648
- if (hmr)
1649
- injectHMRIntoHTMLFile(htmxFile, "htmx");
1650
- const fileName = basename2(htmxFile, ".html");
1651
- manifest[fileName] = htmxFile;
1652
- }
1653
- };
1654
- await Promise.all([
1655
- tracePhase("postprocess/html-pages", processHtmlPages),
1656
- tracePhase("postprocess/htmx-pages", processHtmxPages)
1657
- ]);
1658
- if (!isIncremental) {
1659
- await tracePhase("cleanup/stale-outputs", () => cleanStaleOutputs(buildPath, [
1660
- ...serverOutputs.map((a) => a.path),
1661
- ...reactClientOutputs.map((a) => a.path),
1662
- ...nonReactClientOutputs.map((a) => a.path),
1663
- ...islandClientOutputs.map((a) => a.path),
1664
- ...cssOutputs.map((a) => a.path),
1665
- ...conventionOutputPaths
1666
- ]));
1667
- }
1668
- if (hmr) {
1669
- await tracePhase("dev/copy-indexes", () => copyDevIndexes({
1670
- buildPath,
1671
- reactIndexesPath,
1672
- reactPagesPath,
1673
- svelteDir,
1674
- svelteEntries,
1675
- sveltePagesPath,
1676
- vueDir,
1677
- vueEntries,
1678
- vuePagesPath
1679
- }));
1680
- }
1681
- await tracePhase("cleanup/generated", () => cleanup({
1682
- angularDir,
1683
- reactDir,
1684
- svelteDir,
1685
- vueDir
1686
- }));
1687
- if (!isIncremental) {
1688
- globalThis.__hmrBuildDuration = performance.now() - buildStart;
1689
- }
1690
- sendTelemetryEvent("build:complete", {
1691
- durationMs: Math.round(performance.now() - buildStart),
1692
- frameworks: frameworkNames,
1693
- mode: mode ?? (isDev ? "development" : "production")
1694
- });
1695
- if (isIncremental) {
1696
- writeBuildTrace(buildPath);
1697
- return { conventions: conventionsMap, manifest };
1698
- }
1699
- writeFileSync(join2(buildPath, "manifest.json"), JSON.stringify(manifest, null, "\t"));
1700
- if (Object.keys(conventionsMap).length > 0) {
1701
- writeFileSync(join2(buildPath, "conventions.json"), JSON.stringify(conventionsMap, null, "\t"));
1702
- }
1703
- writeBuildTrace(buildPath);
1704
- if (tailwind && mode === "production") {
1705
- disposeTailwindCompiler(tailwind.input);
1706
- }
1707
- return { conventions: conventionsMap, manifest };
1708
- };
1709
-
1710
- // src/dev/dependencyGraph.ts
1711
- import { existsSync as existsSync5, readFileSync as readFileSync2 } from "fs";
1712
- var {Glob: Glob5 } = globalThis.Bun;
1713
- import { resolve as resolve4 } from "path";
1714
- var emptyDependencyGraph = {
1715
- dependencies: new Map,
1716
- dependents: new Map
1717
- };
1718
- var tsTranspiler = new Bun.Transpiler({ loader: "tsx" });
1719
- var jsTranspiler = new Bun.Transpiler({ loader: "js" });
1720
- var loaderForFile = (filePath) => {
1721
- const lower = filePath.toLowerCase();
1722
- if (lower.endsWith(".ts") || lower.endsWith(".tsx") || lower.endsWith(".jsx"))
1723
- return "tsx";
1724
- if (lower.endsWith(".js") || lower.endsWith(".mjs"))
1725
- return "js";
1726
- if (lower.endsWith(".html") || lower.endsWith(".htm"))
1727
- return "html";
1728
- return null;
1729
- };
1730
- var resolveImportPath = (importPath, fromFile) => {
1731
- if (!importPath.startsWith(".") && !importPath.startsWith("/")) {
1732
- return null;
1733
- }
1734
- const fromDir = resolve4(fromFile, "..");
1735
- const normalized = resolve4(fromDir, importPath);
1736
- const extensions = [
1737
- ".ts",
1738
- ".tsx",
1739
- ".js",
1740
- ".jsx",
1741
- ".vue",
1742
- ".svelte",
1743
- ".css",
1744
- ".html"
1745
- ];
1746
- for (const ext of extensions) {
1747
- const withExt = normalized + ext;
1748
- if (existsSync5(withExt))
1749
- return withExt;
1750
- }
1751
- if (existsSync5(normalized))
1752
- return normalized;
1753
- return null;
1754
- };
1755
- var clearExistingDependents = (graph, normalizedPath) => {
1756
- const existingDeps = graph.dependencies.get(normalizedPath);
1757
- if (!existingDeps)
1758
- return;
1759
- for (const dep of existingDeps) {
1760
- const dependents = graph.dependents.get(dep);
1761
- if (!dependents)
1762
- continue;
1763
- dependents.delete(normalizedPath);
1764
- }
1765
- };
1766
- var addFileToGraph = (graph, filePath) => {
1767
- const normalizedPath = resolve4(filePath);
1768
- if (!existsSync5(normalizedPath))
1769
- return;
1770
- const dependencies = extractDependencies(normalizedPath);
1771
- clearExistingDependents(graph, normalizedPath);
1772
- const newDeps = new Set(dependencies);
1773
- graph.dependencies.set(normalizedPath, newDeps);
1774
- const addDependent = (dep) => {
1775
- if (!graph.dependents.has(dep)) {
1776
- graph.dependents.set(dep, new Set);
1777
- }
1778
- graph.dependents.get(dep)?.add(normalizedPath);
1779
- };
1780
- dependencies.forEach(addDependent);
1781
- };
1782
- var IGNORED_SEGMENTS = [
1783
- "/node_modules/",
1784
- "/.git/",
1785
- "/build/",
1786
- "/compiled/",
1787
- "/indexes/",
1788
- "/server/",
1789
- "/client/"
1790
- ];
1791
- var buildInitialDependencyGraph = (graph, directories) => {
1792
- const processedFiles = new Set;
1793
- const glob = new Glob5("**/*.{ts,tsx,js,jsx,vue,svelte,html,htm}");
1794
- const resolvedDirs = directories.map((dir) => resolve4(dir)).filter((dir) => existsSync5(dir));
1795
- const allFiles = resolvedDirs.flatMap((dir) => Array.from(glob.scanSync({ absolute: true, cwd: dir })));
1796
- for (const file of allFiles) {
1797
- const fullPath = resolve4(file);
1798
- if (IGNORED_SEGMENTS.some((seg) => fullPath.includes(seg)))
1799
- continue;
1800
- if (processedFiles.has(fullPath))
1801
- continue;
1802
- addFileToGraph(graph, fullPath);
1803
- processedFiles.add(fullPath);
1804
- }
1805
- };
1806
- var extractHtmlDependencies = (filePath, content) => {
1807
- const dependencies = [];
1808
- const linkRegex = /<link\s+[^>]*rel=["']stylesheet["'][^>]*href=["']([^"']+)["'][^>]*>/gi;
1809
- let matchLink;
1810
- while ((matchLink = linkRegex.exec(content)) !== null) {
1811
- const [, href] = matchLink;
1812
- if (!href)
1813
- continue;
1814
- const resolvedHref = resolveImportPath(href, filePath);
1815
- if (resolvedHref)
1816
- dependencies.push(resolvedHref);
1817
- }
1818
- return dependencies;
1819
- };
1820
- var resolveRegexMatches = (regex, content, filePath, dependencies) => {
1821
- let match;
1822
- while ((match = regex.exec(content)) !== null) {
1823
- if (!match[1])
1824
- continue;
1825
- const resolved = resolveImportPath(match[1], filePath);
1826
- if (resolved)
1827
- dependencies.push(resolved);
1828
- }
1829
- };
1830
- var resolveStyleUrls = (matchContent, filePath, dependencies) => {
1831
- const stringLiteralRegex = /['"]([^'"]+)['"]/g;
1832
- let urlMatch;
1833
- while ((urlMatch = stringLiteralRegex.exec(matchContent)) !== null) {
1834
- if (!urlMatch[1])
1835
- continue;
1836
- const resolved = resolveImportPath(urlMatch[1], filePath);
1837
- if (resolved)
1838
- dependencies.push(resolved);
1839
- }
1840
- };
1841
- var extractStyleUrlsDependencies = (content, filePath, dependencies) => {
1842
- const styleUrlsRegex = /styleUrls\s*:\s*\[([^\]]*)\]/g;
1843
- let match;
1844
- while ((match = styleUrlsRegex.exec(content)) !== null) {
1845
- if (!match[1])
1846
- continue;
1847
- resolveStyleUrls(match[1], filePath, dependencies);
1848
- }
1849
- };
1850
- var extractAngularDependencies = (content, filePath, dependencies) => {
1851
- const templateUrlRegex = /templateUrl\s*:\s*['"]([^'"]+)['"]/g;
1852
- const styleUrlSingularRegex = /styleUrl\s*:\s*['"]([^'"]+)['"]/g;
1853
- resolveRegexMatches(templateUrlRegex, content, filePath, dependencies);
1854
- resolveRegexMatches(styleUrlSingularRegex, content, filePath, dependencies);
1855
- extractStyleUrlsDependencies(content, filePath, dependencies);
1856
- };
1857
- var extractJsDependencies = (filePath, content, loader) => {
1858
- const transpiler = loader === "tsx" ? tsTranspiler : jsTranspiler;
1859
- const imports = transpiler.scanImports(content);
1860
- const dependencies = [];
1861
- for (const imp of imports) {
1862
- const resolved = resolveImportPath(imp.path, filePath);
1863
- if (resolved)
1864
- dependencies.push(resolved);
1865
- }
1866
- if (content.includes("@Component")) {
1867
- extractAngularDependencies(content, filePath, dependencies);
1868
- }
1869
- return dependencies;
1870
- };
1871
- var resolveScannedImports = (imports, filePath, dependencies) => {
1872
- for (const imp of imports) {
1873
- const resolved = resolveImportPath(imp.path, filePath);
1874
- if (resolved)
1875
- dependencies.push(resolved);
1876
- }
1877
- };
1878
- var extractScriptImports = (scriptContent, filePath, dependencies) => {
1879
- try {
1880
- const imports = tsTranspiler.scanImports(scriptContent);
1881
- resolveScannedImports(imports, filePath, dependencies);
1882
- } catch {}
1883
- };
1884
- var extractSvelteVueDependencies = (filePath, content) => {
1885
- const dependencies = [];
1886
- const scriptRegex = /<script[^>]*>([\s\S]*?)<\/script>/gi;
1887
- let scriptMatch;
1888
- while ((scriptMatch = scriptRegex.exec(content)) !== null) {
1889
- const [, scriptContent] = scriptMatch;
1890
- if (!scriptContent?.trim())
1891
- continue;
1892
- extractScriptImports(scriptContent, filePath, dependencies);
1893
- }
1894
- return dependencies;
1895
- };
1896
- var extractDependenciesForFile = (filePath) => {
1897
- const loader = loaderForFile(filePath);
1898
- const lowerPath = filePath.toLowerCase();
1899
- const isSvelteOrVue = lowerPath.endsWith(".svelte") || lowerPath.endsWith(".vue");
1900
- if (loader === "html") {
1901
- const content = readFileSync2(filePath, "utf-8");
1902
- return extractHtmlDependencies(filePath, content);
1903
- }
1904
- if (loader === "tsx" || loader === "js") {
1905
- const content = readFileSync2(filePath, "utf-8");
1906
- return extractJsDependencies(filePath, content, loader);
1907
- }
1908
- if (isSvelteOrVue) {
1909
- const content = readFileSync2(filePath, "utf-8");
1910
- return extractSvelteVueDependencies(filePath, content);
1911
- }
1912
- return [];
1913
- };
1914
- var extractDependencies = (filePath) => {
1915
- try {
1916
- return extractDependenciesForFile(filePath);
1917
- } catch {
1918
- return [];
1919
- }
1920
- };
1921
- var getAffectedFiles = (graph, changedFile) => {
1922
- const normalizedPath = resolve4(changedFile);
1923
- const affected = new Set;
1924
- const toProcess = [normalizedPath];
1925
- const processNode = (current) => {
1926
- if (affected.has(current))
1927
- return;
1928
- affected.add(current);
1929
- const dependents = graph.dependents.get(current);
1930
- if (!dependents)
1931
- return;
1932
- dependents.forEach((dependent) => toProcess.push(dependent));
1933
- };
1934
- while (toProcess.length > 0) {
1935
- const current = toProcess.pop() ?? normalizedPath;
1936
- processNode(current);
1937
- }
1938
- return Array.from(affected);
1939
- };
1940
- var removeDepsForFile = (graph, normalizedPath) => {
1941
- const deps = graph.dependencies.get(normalizedPath);
1942
- if (!deps)
1943
- return;
1944
- for (const dep of deps) {
1945
- const dependents = graph.dependents.get(dep);
1946
- if (!dependents)
1947
- continue;
1948
- dependents.delete(normalizedPath);
1949
- }
1950
- graph.dependencies.delete(normalizedPath);
1951
- };
1952
- var removeDependentsForFile = (graph, normalizedPath) => {
1953
- const dependents = graph.dependents.get(normalizedPath);
1954
- if (!dependents)
1955
- return;
1956
- for (const dependent of dependents) {
1957
- const depList = graph.dependencies.get(dependent);
1958
- if (!depList)
1959
- continue;
1960
- depList.delete(normalizedPath);
1961
- }
1962
- graph.dependents.delete(normalizedPath);
1963
- };
1964
- var removeFileFromGraph = (graph, filePath) => {
1965
- const normalizedPath = resolve4(filePath);
1966
- removeDepsForFile(graph, normalizedPath);
1967
- removeDependentsForFile(graph, normalizedPath);
1968
- };
1969
-
1970
- // src/dev/configResolver.ts
1971
- import { resolve as resolve5 } from "path";
1972
- var resolveBuildPaths = (config) => {
1973
- const cwd2 = process.cwd();
1974
- const normalize = (path) => path.replace(/\\/g, "/");
1975
- const withDefault = (value, fallback) => normalize(resolve5(cwd2, value ?? fallback));
1976
- const optional = (value) => value ? normalize(resolve5(cwd2, value)) : undefined;
1977
- return {
1978
- angularDir: optional(config.angularDirectory),
1979
- assetsDir: optional(config.assetsDirectory),
1980
- buildDir: withDefault(config.buildDirectory, "build"),
1981
- htmlDir: optional(config.htmlDirectory),
1982
- htmxDir: optional(config.htmxDirectory),
1983
- reactDir: optional(config.reactDirectory),
1984
- stylesDir: optional(typeof config.stylesConfig === "string" ? config.stylesConfig : config.stylesConfig?.path),
1985
- svelteDir: optional(config.svelteDirectory),
1986
- vueDir: optional(config.vueDirectory)
1987
- };
1988
- };
1989
-
1990
- // src/dev/clientManager.ts
1991
- var createHMRState = (config) => ({
1992
- activeFrameworks: new Set,
1993
- assetStore: new Map,
1994
- config,
1995
- connectedClients: new Set,
1996
- debounceTimeout: null,
1997
- dependencyGraph: emptyDependencyGraph,
1998
- fileChangeQueue: new Map,
1999
- fileHashes: new Map,
2000
- isRebuilding: false,
2001
- manifest: {},
2002
- moduleVersions: createModuleVersionTracker(),
2003
- rebuildCount: 0,
2004
- rebuildQueue: new Set,
2005
- rebuildTimeout: null,
2006
- resolvedPaths: resolveBuildPaths(config),
2007
- sourceFileVersions: new Map,
2008
- vueChangeTypes: new Map,
2009
- watchers: []
2010
- });
2011
- var incrementSourceFileVersion = (state, filePath) => {
2012
- const currentVersion = state.sourceFileVersions.get(filePath) || 0;
2013
- const newVersion = currentVersion + 1;
2014
- state.sourceFileVersions.set(filePath, newVersion);
2015
- return newVersion;
2016
- };
2017
- var incrementSourceFileVersions = (state, filePaths) => {
2018
- for (const filePath of filePaths) {
2019
- incrementSourceFileVersion(state, filePath);
2020
- }
2021
- };
2022
-
2023
- // src/dev/fileWatcher.ts
2024
- import { watch } from "fs";
2025
- import { existsSync as existsSync6 } from "fs";
2026
- import { join as join3, resolve as resolve6 } from "path";
2027
-
2028
- // src/dev/pathUtils.ts
2029
- import { readdirSync } from "fs";
2030
- var STYLE_EXTENSION_PATTERN = /\.(css|s[ac]ss|less|styl(?:us)?)$/i;
2031
- var detectFramework = (filePath, resolved) => {
2032
- if (shouldIgnorePath(filePath, resolved)) {
2033
- return "ignored";
2034
- }
2035
- const normalized = filePath.replace(/\\/g, "/");
2036
- const startsWithDir = (dir) => dir ? normalized.startsWith(dir.replace(/\\/g, "/")) : false;
2037
- if (resolved) {
2038
- if (startsWithDir(resolved.stylesDir))
2039
- return "styles";
2040
- if (startsWithDir(resolved.htmxDir))
2041
- return "htmx";
2042
- if (startsWithDir(resolved.reactDir))
2043
- return "react";
2044
- if (startsWithDir(resolved.svelteDir))
2045
- return "svelte";
2046
- if (startsWithDir(resolved.vueDir))
2047
- return "vue";
2048
- if (startsWithDir(resolved.angularDir))
2049
- return "angular";
2050
- if (startsWithDir(resolved.htmlDir))
2051
- return "html";
2052
- if (startsWithDir(resolved.assetsDir))
2053
- return "assets";
2054
- } else {
2055
- if (normalized.includes("/htmx/"))
2056
- return "htmx";
2057
- if (normalized.includes("/react/"))
2058
- return "react";
2059
- if (normalized.includes("/svelte/"))
2060
- return "svelte";
2061
- if (normalized.includes("/vue/"))
2062
- return "vue";
2063
- if (normalized.includes("/angular/"))
2064
- return "angular";
2065
- if (normalized.includes("/html/"))
2066
- return "html";
2067
- }
2068
- if (normalized.endsWith(".tsx") || normalized.endsWith(".jsx"))
2069
- return "react";
2070
- if (normalized.endsWith(".svelte"))
2071
- return "svelte";
2072
- if (normalized.endsWith(".vue"))
2073
- return "vue";
2074
- if (normalized.endsWith(".html"))
2075
- return "html";
2076
- if (normalized.endsWith(".ts") && normalized.includes("angular"))
2077
- return "angular";
2078
- if (normalized.includes("/assets/"))
2079
- return "assets";
2080
- if (STYLE_EXTENSION_PATTERN.test(normalized)) {
2081
- if (normalized.includes("/vue/") || normalized.includes("/vue-"))
2082
- return "vue";
2083
- if (normalized.includes("/svelte/") || normalized.includes("/svelte-"))
2084
- return "svelte";
2085
- if (normalized.includes("/react/") || normalized.includes("/react-"))
2086
- return "react";
2087
- if (normalized.includes("/angular/") || normalized.includes("/angular-"))
2088
- return "angular";
2089
- if (normalized.includes("/html/") || normalized.includes("/html-"))
2090
- return "html";
2091
- if (normalized.includes("/htmx/") || normalized.includes("/htmx-"))
2092
- return "htmx";
2093
- return "assets";
2094
- }
2095
- return "unknown";
2096
- };
2097
- var getSiblingDirs = (frameworkDirs, cfg) => {
2098
- if (frameworkDirs.length === 0)
2099
- return [];
2100
- const root = commonAncestor(frameworkDirs);
2101
- if (!root)
2102
- return [];
2103
- const knownNames = new Set([...frameworkDirs, cfg.assetsDir, cfg.stylesDir].filter((dir) => Boolean(dir)).map((dir) => normalizePath(dir).split("/").pop()));
2104
- knownNames.add("build");
2105
- knownNames.add("node_modules");
2106
- knownNames.add(".absolutejs");
2107
- try {
2108
- return readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !knownNames.has(entry.name)).map((entry) => `${root}/${entry.name}`);
2109
- } catch {
2110
- return [];
2111
- }
2112
- };
2113
- var getWatchPaths = (config, resolved) => {
2114
- const paths = [];
2115
- const push = (base, sub) => {
2116
- if (!base)
2117
- return;
2118
- const normalizedBase = normalizePath(base);
2119
- paths.push(sub ? `${normalizedBase}/${sub}` : normalizedBase);
2120
- };
2121
- const cfg = resolved ?? {
2122
- angularDir: config.angularDirectory,
2123
- assetsDir: config.assetsDirectory,
2124
- htmlDir: config.htmlDirectory,
2125
- htmxDir: config.htmxDirectory,
2126
- reactDir: config.reactDirectory,
2127
- stylesDir: typeof config.stylesConfig === "string" ? config.stylesConfig : config.stylesConfig?.path,
2128
- svelteDir: config.svelteDirectory,
2129
- vueDir: config.vueDirectory
2130
- };
2131
- push(cfg.reactDir);
2132
- push(cfg.svelteDir);
2133
- push(cfg.vueDir);
2134
- push(cfg.angularDir);
2135
- push(cfg.htmlDir, "pages");
2136
- push(cfg.htmlDir, "scripts");
2137
- push(cfg.htmlDir, "styles");
2138
- push(cfg.htmxDir, "pages");
2139
- push(cfg.htmxDir, "scripts");
2140
- push(cfg.htmxDir, "styles");
2141
- push(cfg.assetsDir);
2142
- push(cfg.stylesDir);
2143
- const frameworkDirs = [
2144
- cfg.reactDir,
2145
- cfg.svelteDir,
2146
- cfg.vueDir,
2147
- cfg.angularDir,
2148
- cfg.htmlDir,
2149
- cfg.htmxDir
2150
- ].filter((dir) => Boolean(dir)).map(normalizePath);
2151
- for (const siblingPath of getSiblingDirs(frameworkDirs, cfg)) {
2152
- push(siblingPath);
2153
- }
2154
- return paths;
2155
- };
2156
- var shouldIgnorePath = (path, resolved) => {
2157
- const normalizedPath = path.replace(/\\/g, "/");
2158
- if (resolved?.stylesDir && normalizedPath.startsWith(resolved.stylesDir)) {
2159
- return false;
2160
- }
2161
- const managedDirPattern = /(^|\/)(build|generated|\.absolutejs|node_modules|\.git)(\/|$)/;
2162
- return managedDirPattern.test(normalizedPath) || normalizedPath.endsWith(".log") || normalizedPath.endsWith(".tmp");
2163
- };
2164
-
2165
- // src/dev/fileWatcher.ts
2166
- var safeRemoveFromGraph = (graph, fullPath) => {
2167
- try {
2168
- removeFileFromGraph(graph, fullPath);
2169
- } catch (err) {
2170
- sendTelemetryEvent("hmr:graph-error", {
2171
- message: err instanceof Error ? err.message : String(err),
2172
- operation: "remove"
2173
- });
2174
- }
2175
- };
2176
- var safeAddToGraph = (graph, fullPath) => {
2177
- try {
2178
- addFileToGraph(graph, fullPath);
2179
- } catch (err) {
2180
- sendTelemetryEvent("hmr:graph-error", {
2181
- message: err instanceof Error ? err.message : String(err),
2182
- operation: "add"
2183
- });
2184
- }
2185
- };
2186
- var shouldSkipFilename = (filename, isStylesDir) => !isStylesDir && (filename === "compiled" || filename === "generated" || filename === "build" || filename === "indexes" || filename === "server" || filename === "client" || filename.includes("/compiled/") || filename.includes("/generated/") || filename.includes("/build/") || filename.includes("/indexes/") || filename.includes("/server/") || filename.includes("/client/") || filename.startsWith("compiled/") || filename.startsWith("generated/") || filename.startsWith("build/") || filename.startsWith("indexes/") || filename.startsWith("server/") || filename.startsWith("client/")) || filename.endsWith("/") || filename.includes(".tmp.") || filename.endsWith(".tmp") || filename.endsWith("~") || filename.startsWith(".#");
2187
- var setupWatcher = (absolutePath, isStylesDir, state, onFileChange) => {
2188
- const watcher = watch(absolutePath, { recursive: true }, (event, filename) => {
2189
- if (!filename) {
2190
- return;
2191
- }
2192
- if (shouldSkipFilename(filename, isStylesDir)) {
2193
- return;
2194
- }
2195
- const fullPath = join3(absolutePath, filename).replace(/\\/g, "/");
2196
- if (shouldIgnorePath(fullPath, state.resolvedPaths)) {
2197
- return;
2198
- }
2199
- if (event === "rename" && !existsSync6(fullPath)) {
2200
- safeRemoveFromGraph(state.dependencyGraph, fullPath);
2201
- onFileChange(fullPath);
2202
- return;
2203
- }
2204
- if (existsSync6(fullPath)) {
2205
- onFileChange(fullPath);
2206
- safeAddToGraph(state.dependencyGraph, fullPath);
2207
- }
2208
- });
2209
- state.watchers.push(watcher);
2210
- };
2211
- var addFileWatchers = (state, paths, onFileChange) => {
2212
- const stylesDir = state.resolvedPaths?.stylesDir;
2213
- paths.forEach((path) => {
2214
- const absolutePath = resolve6(path).replace(/\\/g, "/");
2215
- if (!existsSync6(absolutePath)) {
2216
- return;
2217
- }
2218
- const isStylesDir = Boolean(stylesDir && absolutePath.startsWith(stylesDir));
2219
- setupWatcher(absolutePath, isStylesDir, state, onFileChange);
2220
- });
2221
- };
2222
- var startFileWatching = (state, config, onFileChange) => {
2223
- const watchPaths = getWatchPaths(config, state.resolvedPaths);
2224
- const stylesDir = state.resolvedPaths?.stylesDir;
2225
- watchPaths.forEach((path) => {
2226
- const absolutePath = resolve6(path).replace(/\\/g, "/");
2227
- if (!existsSync6(absolutePath)) {
2228
- return;
2229
- }
2230
- const isStylesDir = Boolean(stylesDir && absolutePath.startsWith(stylesDir));
2231
- setupWatcher(absolutePath, isStylesDir, state, onFileChange);
2232
- });
2233
- };
2234
-
2235
- // src/dev/rebuildTrigger.ts
2236
- import { existsSync as existsSync7 } from "fs";
2237
- import { basename as basename4, dirname as dirname2, relative as relative2, resolve as resolve9 } from "path";
2238
-
2239
- // src/dev/fileHashTracker.ts
2240
- import { readFileSync as readFileSync3 } from "fs";
2241
- var computeFileHash = (filePath) => {
2242
- try {
2243
- const fileContent = readFileSync3(filePath);
2244
- return Number(Bun.hash(fileContent));
2245
- } catch {
2246
- return UNFOUND_INDEX;
2247
- }
2248
- };
2249
- var hasFileChanged = (filePath, currentHash, previousHashes) => {
2250
- const normalizedPath = normalizePath(filePath);
2251
- const previousHash = previousHashes.get(normalizedPath);
2252
- if (previousHash === undefined) {
2253
- return true;
2254
- }
2255
- return previousHash !== currentHash;
2256
- };
2257
-
2258
- // src/dev/moduleMapper.ts
2259
- import { basename as basename3, resolve as resolve8 } from "path";
2260
-
2261
- // src/dev/reactComponentClassifier.ts
2262
- import { resolve as resolve7 } from "path";
2263
- var classifyComponent = (filePath) => {
2264
- const normalizedPath = resolve7(filePath);
2265
- if (normalizedPath.includes("/react/pages/")) {
2266
- return "server";
2267
- }
2268
- if (normalizedPath.includes("/react/components/") || normalizedPath.includes("/react/composables/")) {
2269
- return "client";
2270
- }
2271
- return "client";
2272
- };
2273
-
2274
- // src/dev/moduleMapper.ts
2275
- var buildModulePaths = (moduleKeys, manifest) => {
2276
- const modulePaths = {};
2277
- moduleKeys.forEach((key) => {
2278
- if (manifest[key]) {
2279
- modulePaths[key] = manifest[key];
2280
- }
2281
- });
2282
- return modulePaths;
2283
- };
2284
- var processChangedFile = (sourceFile, framework, manifest, resolvedPaths, processedFiles) => {
2285
- const normalizedFile = resolve8(sourceFile);
2286
- const normalizedPath = normalizedFile.replace(/\\/g, "/");
2287
- if (processedFiles.has(normalizedFile)) {
2288
- return null;
2289
- }
2290
- processedFiles.add(normalizedFile);
2291
- const moduleKeys = mapSourceFileToManifestKeys(normalizedFile, framework, resolvedPaths);
2292
- const isReactPage = resolvedPaths?.reactDir ? normalizedPath.startsWith(`${resolvedPaths.reactDir.replace(/\\/g, "/")}/pages/`) : normalizedPath.includes("/react/pages/");
2293
- if (framework === "react" && !isReactPage) {
2294
- return null;
2295
- }
2296
- const modulePaths = buildModulePaths(moduleKeys, manifest);
2297
- if (Object.keys(modulePaths).length === 0) {
2298
- return null;
2299
- }
2300
- const componentType = framework === "react" ? classifyComponent(normalizedFile) : undefined;
2301
- return {
2302
- componentType,
2303
- framework,
2304
- moduleKeys: Object.keys(modulePaths),
2305
- modulePaths,
2306
- sourceFile: normalizedFile
2307
- };
2308
- };
2309
- var createModuleUpdates = (changedFiles, framework, manifest, resolvedPaths) => {
2310
- const processedFiles = new Set;
2311
- return changedFiles.map((sourceFile) => processChangedFile(sourceFile, framework, manifest, resolvedPaths, processedFiles)).filter((update) => update !== null);
2312
- };
2313
- var groupModuleUpdatesByFramework = (updates) => {
2314
- const grouped = new Map;
2315
- updates.forEach((update) => {
2316
- if (!grouped.has(update.framework)) {
2317
- grouped.set(update.framework, []);
2318
- }
2319
- grouped.get(update.framework)?.push(update);
2320
- });
2321
- return grouped;
2322
- };
2323
- var mapSourceFileToManifestKeys = (sourceFile, framework, resolvedPaths) => {
2324
- const normalizedFile = resolve8(sourceFile);
2325
- const fileName = basename3(normalizedFile);
2326
- const baseName = fileName.replace(/\.(tsx?|jsx?|vue|svelte|css|html)$/, "");
2327
- const pascalName = toPascal(baseName);
2328
- const keys = [];
2329
- const inSubdir = (dir, sub) => {
2330
- if (!dir)
2331
- return false;
2332
- const prefix = `${dir.replace(/\\/g, "/")}/${sub}/`;
2333
- return normalizedFile.startsWith(prefix);
2334
- };
2335
- switch (framework) {
2336
- case "react":
2337
- if (inSubdir(resolvedPaths?.reactDir, "pages") || normalizedFile.includes("/react/pages/")) {
2338
- keys.push(`${pascalName}Index`);
2339
- keys.push(`${pascalName}CSS`);
2340
- }
2341
- break;
2342
- case "svelte":
2343
- if (inSubdir(resolvedPaths?.svelteDir, "pages") || normalizedFile.includes("/svelte/pages/")) {
2344
- keys.push(pascalName);
2345
- keys.push(`${pascalName}Index`);
2346
- keys.push(`${pascalName}CSS`);
2347
- }
2348
- break;
2349
- case "vue":
2350
- if (inSubdir(resolvedPaths?.vueDir, "pages") || normalizedFile.includes("/vue/pages/")) {
2351
- keys.push(pascalName);
2352
- keys.push(`${pascalName}Index`);
2353
- keys.push(`${pascalName}CSS`);
2354
- }
2355
- break;
2356
- case "angular":
2357
- if (inSubdir(resolvedPaths?.angularDir, "pages") || normalizedFile.includes("/angular/pages/")) {
2358
- keys.push(pascalName);
2359
- keys.push(`${pascalName}Index`);
2360
- }
2361
- break;
2362
- case "html":
2363
- case "htmx":
2364
- break;
2365
- case "assets":
2366
- if (isStylePath(normalizedFile)) {
2367
- keys.push(`${pascalName}CSS`);
2368
- }
2369
- break;
2370
- }
2371
- return keys;
2372
- };
2373
-
2374
- // src/dev/rebuildTrigger.ts
2375
- var moduleServerPromise = import("./chunk-zrg9d4zw.js");
2376
- var getModuleServer = () => moduleServerPromise;
2377
- var runSequentially = (items, action) => items.reduce((chain, item) => chain.then(() => action(item)), Promise.resolve());
2378
- var getStyleTransformConfig = (config) => createStyleTransformConfig(config.stylePreprocessors, config.postcss);
2379
- var recompileTailwindForFastPath = async (state, config, files) => {
2380
- if (!config.tailwind)
2381
- return;
2382
- if (!files.some(isTailwindCandidate))
2383
- return;
2384
- try {
2385
- const { cssChanged } = await incrementalTailwindBuild(config.tailwind, state.resolvedPaths.buildDir, files, getStyleTransformConfig(config));
2386
- if (!cssChanged)
2387
- return;
2388
- broadcastToClients(state, {
2389
- data: { framework: "tailwind", manifest: state.manifest },
2390
- message: "Tailwind utilities recompiled",
2391
- type: "style-update"
2392
- });
2393
- } catch (err) {
2394
- sendTelemetryEvent("hmr:error", {
2395
- framework: "tailwind",
2396
- message: err instanceof Error ? err.message : String(err)
2397
- });
2398
- }
2399
- };
2400
- var parseErrorLocationFromMessage = (msg) => {
2401
- const pathLineCol = msg.match(/^([^\s:]+):(\d+)(?::(\d+))?/);
2402
- if (pathLineCol) {
2403
- const [, file, lineStr, colStr] = pathLineCol;
2404
- return {
2405
- column: colStr ? parseInt(colStr, 10) : undefined,
2406
- file,
2407
- line: lineStr ? parseInt(lineStr, 10) : undefined
2408
- };
2409
- }
2410
- const atMatch = msg.match(/(?:at|in)\s+([^(:\s]+)(?:\s*\([^)]*line\s*(\d+)[^)]*col(?:umn)?\s*(\d+)[^)]*\)|:(\d+):(\d+)?)/i);
2411
- if (atMatch) {
2412
- const [, file, line1, col1, line2, col2] = atMatch;
2413
- let parsedCol;
2414
- if (col1)
2415
- parsedCol = parseInt(col1, 10);
2416
- else if (col2)
2417
- parsedCol = parseInt(col2, 10);
2418
- let parsedLine;
2419
- if (line1)
2420
- parsedLine = parseInt(line1, 10);
2421
- else if (line2)
2422
- parsedLine = parseInt(line2, 10);
2423
- return {
2424
- column: parsedCol,
2425
- file: file?.trim(),
2426
- line: parsedLine
2427
- };
2428
- }
2429
- const parenMatch = msg.match(/([^\s(]+)\s*\([^)]*line\s*(\d+)[^)]*col(?:umn)?\s*(\d+)/i);
2430
- if (parenMatch) {
2431
- const [, file, lineStr, colStr] = parenMatch;
2432
- return {
2433
- column: colStr ? parseInt(colStr, 10) : undefined,
2434
- file: file ?? undefined,
2435
- line: lineStr ? parseInt(lineStr, 10) : undefined
2436
- };
2437
- }
2438
- return {};
2439
- };
2440
- var extractBuildErrorDetails = (error, affectedFrameworks, resolvedPaths) => {
2441
- const errorObj = error && typeof error === "object" ? error : undefined;
2442
- const rawLogs = errorObj && "logs" in errorObj && Array.isArray(errorObj.logs) ? errorObj.logs : undefined;
2443
- const logs = rawLogs ?? (error instanceof AggregateError && error.errors?.length ? error.errors : undefined);
2444
- if (logs && Array.isArray(logs) && logs.length > 0) {
2445
- const errLog = logs.find((l) => l.level === "error") ?? logs[0];
2446
- const pos = errLog?.position;
2447
- const file = pos?.file;
2448
- const line = pos?.line;
2449
- const column = pos?.column;
2450
- const lineText = pos?.lineText;
2451
- const framework = file && resolvedPaths ? detectFramework(file, resolvedPaths) : affectedFrameworks[0] ?? "unknown";
2452
- return {
2453
- column,
2454
- file,
2455
- framework: framework !== "ignored" ? framework : affectedFrameworks[0],
2456
- line,
2457
- lineText
2458
- };
2459
- }
2460
- const msg = error instanceof Error ? error.message : String(error);
2461
- const parsed = parseErrorLocationFromMessage(msg);
2462
- let [detectedFw] = affectedFrameworks;
2463
- if (parsed.file && resolvedPaths) {
2464
- const detected = detectFramework(parsed.file, resolvedPaths);
2465
- detectedFw = detected !== "ignored" ? detected : affectedFrameworks[0];
2466
- }
2467
- return { ...parsed, framework: detectedFw };
2468
- };
2469
- var isValidDeletedAffectedFile = (affectedFile, deletedPathResolved, processedFiles) => affectedFile !== deletedPathResolved && !processedFiles.has(affectedFile) && existsSync7(affectedFile);
2470
- var collectDeletedFileAffected = (state, filePathInSet, processedFiles, validFiles) => {
2471
- state.fileHashes.delete(filePathInSet);
2472
- try {
2473
- const affectedFiles = getAffectedFiles(state.dependencyGraph, filePathInSet);
2474
- const deletedPathResolved = resolve9(filePathInSet);
2475
- affectedFiles.forEach((affectedFile) => {
2476
- if (isValidDeletedAffectedFile(affectedFile, deletedPathResolved, processedFiles)) {
2477
- validFiles.push(affectedFile);
2478
- processedFiles.add(affectedFile);
2479
- }
2480
- });
2481
- } catch {}
2482
- };
2483
- var incrementDependentVersions = (state, normalizedFilePath) => {
2484
- try {
2485
- const dependents = state.dependencyGraph.dependents.get(normalizedFilePath);
2486
- if (!dependents || dependents.size === 0) {
2487
- return;
2488
- }
2489
- const dependentFiles = Array.from(dependents).filter((file) => existsSync7(file));
2490
- if (dependentFiles.length === 0) {
2491
- return;
2492
- }
2493
- incrementSourceFileVersions(state, dependentFiles);
2494
- } catch {}
2495
- };
2496
- var addUnprocessedFile = (normalizedFilePath, processedFiles, validFiles) => {
2497
- if (processedFiles.has(normalizedFilePath)) {
2498
- return;
2499
- }
2500
- validFiles.push(normalizedFilePath);
2501
- processedFiles.add(normalizedFilePath);
2502
- };
2503
- var collectChangedFileAffected = (state, normalizedFilePath, processedFiles, validFiles) => {
2504
- try {
2505
- const affectedFiles = getAffectedFiles(state.dependencyGraph, normalizedFilePath);
2506
- affectedFiles.forEach((affectedFile) => {
2507
- if (!processedFiles.has(affectedFile) && affectedFile !== normalizedFilePath && existsSync7(affectedFile)) {
2508
- validFiles.push(affectedFile);
2509
- processedFiles.add(affectedFile);
2510
- }
2511
- });
2512
- } catch {
2513
- addUnprocessedFile(normalizedFilePath, processedFiles, validFiles);
2514
- }
2515
- };
2516
- var processChangedFile2 = (state, filePathInSet, processedFiles, validFiles) => {
2517
- const fileHash = computeFileHash(filePathInSet);
2518
- const storedHash = state.fileHashes.get(filePathInSet);
2519
- if (storedHash !== undefined && storedHash === fileHash) {
2520
- return;
2521
- }
2522
- const normalizedFilePath = resolve9(filePathInSet);
2523
- if (!processedFiles.has(normalizedFilePath)) {
2524
- validFiles.push(normalizedFilePath);
2525
- processedFiles.add(normalizedFilePath);
2526
- }
2527
- state.fileHashes.set(normalizedFilePath, fileHash);
2528
- incrementSourceFileVersions(state, [normalizedFilePath]);
2529
- incrementDependentVersions(state, normalizedFilePath);
2530
- collectChangedFileAffected(state, normalizedFilePath, processedFiles, validFiles);
2531
- };
2532
- var processFilePathSet = (state, filePathSet, processedFiles, validFiles) => {
2533
- filePathSet.forEach((filePathInSet) => {
2534
- if (!existsSync7(filePathInSet)) {
2535
- collectDeletedFileAffected(state, filePathInSet, processedFiles, validFiles);
2536
- return;
2537
- }
2538
- processChangedFile2(state, filePathInSet, processedFiles, validFiles);
2539
- });
2540
- };
2541
- var detectFrameworkForValidFiles = (validFiles, state) => {
2542
- const [firstFile] = validFiles;
2543
- if (!firstFile) {
2544
- return;
2545
- }
2546
- return detectFramework(firstFile, state.resolvedPaths);
2547
- };
2548
- var buildFilesToProcess = (state) => {
2549
- const filesToProcess = new Map;
2550
- const uniqueFilesByFramework = new Map;
2551
- state.fileChangeQueue.forEach((filePaths, fwKey) => {
2552
- uniqueFilesByFramework.set(fwKey, new Set(filePaths));
2553
- });
2554
- uniqueFilesByFramework.forEach((filePathSet) => {
2555
- const validFiles = [];
2556
- const processedFiles = new Set;
2557
- processFilePathSet(state, filePathSet, processedFiles, validFiles);
2558
- if (validFiles.length === 0) {
2559
- return;
2560
- }
2561
- const detectedFramework = detectFrameworkForValidFiles(validFiles, state);
2562
- if (detectedFramework) {
2563
- filesToProcess.set(detectedFramework, validFiles);
2564
- }
2565
- });
2566
- return filesToProcess;
2567
- };
2568
- var STABILITY_CHECK_ROUNDS = 5;
2569
- var STABILITY_CHECK_DELAY_MS = 10;
2570
- var isFileStable = async (file) => {
2571
- const hash1 = computeFileHash(file);
2572
- await Bun.sleep(STABILITY_CHECK_DELAY_MS);
2573
- const hash2 = computeFileHash(file);
2574
- return hash1 === hash2;
2575
- };
2576
- var collectAllQueuedFiles = (fileChangeQueue) => {
2577
- const allFiles = [];
2578
- for (const files of fileChangeQueue.values()) {
2579
- allFiles.push(...files);
2580
- }
2581
- return allFiles;
2582
- };
2583
- var areAllQueuedFilesStable = async (fileChangeQueue) => {
2584
- const allFiles = collectAllQueuedFiles(fileChangeQueue);
2585
- const checkFile = async (files) => {
2586
- const [file, ...remaining] = files;
2587
- if (!file) {
2588
- return true;
2589
- }
2590
- const stable = await isFileStable(file);
2591
- if (!stable) {
2592
- return false;
2593
- }
2594
- return checkFile(remaining);
2595
- };
2596
- return checkFile(allFiles);
2597
- };
2598
- var waitForStableWrites = async (state) => {
2599
- const waitRound = async (round) => {
2600
- if (round >= STABILITY_CHECK_ROUNDS) {
2601
- return;
2602
- }
2603
- const stable = await areAllQueuedFilesStable(state.fileChangeQueue);
2604
- if (stable) {
2605
- return;
2606
- }
2607
- await waitRound(round + 1);
2608
- };
2609
- await waitRound(0);
2610
- };
2611
- var enqueueImporter = (state, importer) => {
2612
- const importerFramework = detectFramework(importer, state.resolvedPaths);
2613
- if (importerFramework === "ignored")
2614
- return;
2615
- if (!state.fileChangeQueue.has(importerFramework)) {
2616
- state.fileChangeQueue.set(importerFramework, []);
2617
- }
2618
- const importerQueue = state.fileChangeQueue.get(importerFramework);
2619
- if (importerQueue && !importerQueue.includes(importer)) {
2620
- importerQueue.push(importer);
2621
- }
2622
- };
2623
- var enqueueStyleImporters = (state, changedStylePath) => {
2624
- for (const importer of findStyleEntriesImporting(changedStylePath)) {
2625
- enqueueImporter(state, importer);
2626
- }
2627
- };
2628
- var queueFileChange = async (state, filePath, config, onRebuildComplete) => {
2629
- const framework = detectFramework(filePath, state.resolvedPaths);
2630
- if (framework === "ignored") {
2631
- return;
2632
- }
2633
- const currentHash = computeFileHash(filePath);
2634
- if (!hasFileChanged(filePath, currentHash, state.fileHashes)) {
2635
- return;
2636
- }
2637
- if (framework === "unknown") {
2638
- invalidate(resolve9(filePath));
2639
- const relPath = relative2(process.cwd(), filePath);
2640
- logHmrUpdate(relPath);
2641
- return;
2642
- }
2643
- if (!state.fileChangeQueue.has(framework)) {
2644
- state.fileChangeQueue.set(framework, []);
2645
- }
2646
- const queue = state.fileChangeQueue.get(framework);
2647
- if (queue && !queue.includes(filePath)) {
2648
- queue.push(filePath);
2649
- }
2650
- if (isStylePath(filePath)) {
2651
- enqueueStyleImporters(state, filePath);
2652
- }
2653
- if (state.isRebuilding) {
2654
- return;
2655
- }
2656
- if (state.rebuildTimeout) {
2657
- clearTimeout(state.rebuildTimeout);
2658
- }
2659
- const DEBOUNCE_MS = config.options?.hmr?.debounceMs ?? DEFAULT_DEBOUNCE_MS;
2660
- state.rebuildTimeout = setTimeout(async () => {
2661
- await waitForStableWrites(state);
2662
- const filesToProcess = buildFilesToProcess(state);
2663
- state.fileChangeQueue.clear();
2664
- if (filesToProcess.size === 0) {
2665
- return;
2666
- }
2667
- const affectedFrameworks = Array.from(filesToProcess.keys());
2668
- affectedFrameworks.forEach((frameworkKey) => {
2669
- state.rebuildQueue.add(frameworkKey);
2670
- });
2671
- const filesToRebuild = [];
2672
- filesToProcess.forEach((filePaths) => {
2673
- filesToRebuild.push(...filePaths);
2674
- });
2675
- triggerRebuild(state, config, onRebuildComplete, filesToRebuild);
2676
- }, DEBOUNCE_MS);
2677
- };
2678
- var resolveComponentLookupFile = (componentFile, graph) => {
2679
- if (!componentFile.endsWith(".html")) {
2680
- return componentFile;
2681
- }
2682
- const tsCounterpart = componentFile.replace(/\.html$/, ".ts");
2683
- if (existsSync7(tsCounterpart)) {
2684
- return tsCounterpart;
2685
- }
2686
- if (!graph)
2687
- return componentFile;
2688
- const dependents = graph.dependents.get(resolve9(componentFile));
2689
- if (!dependents)
2690
- return componentFile;
2691
- for (const dep of dependents) {
2692
- if (dep.endsWith(".ts"))
2693
- return dep;
2694
- }
2695
- return componentFile;
2696
- };
2697
- var resolveAngularPageEntries = (state, angularFiles, angularPagesPath) => {
2698
- const pageEntries = angularFiles.filter((file) => file.endsWith(".ts") && resolve9(file).startsWith(angularPagesPath));
2699
- if (pageEntries.length > 0 || !state.dependencyGraph) {
2700
- return pageEntries;
2701
- }
2702
- const resolvedPages = new Set;
2703
- angularFiles.forEach((componentFile) => {
2704
- const lookupFile = resolveComponentLookupFile(componentFile, state.dependencyGraph);
2705
- const affected = getAffectedFiles(state.dependencyGraph, lookupFile);
2706
- affected.forEach((file) => {
2707
- if (file.endsWith(".ts") && resolve9(file).startsWith(angularPagesPath)) {
2708
- resolvedPages.add(file);
2709
- }
2710
- });
2711
- });
2712
- return Array.from(resolvedPages);
2713
- };
2714
- var computeClientRoot = async (resolvedPaths) => {
2715
- const clientRoots = [
2716
- resolvedPaths.reactDir,
2717
- resolvedPaths.svelteDir,
2718
- resolvedPaths.htmlDir,
2719
- resolvedPaths.vueDir,
2720
- resolvedPaths.angularDir
2721
- ].filter((dir) => Boolean(dir));
2722
- const { commonAncestor: commonAncestor2 } = await import("./chunk-daqghmg8.js");
2723
- return clientRoots.length === 1 ? clientRoots[0] ?? process.cwd() : commonAncestor2(clientRoots, process.cwd());
2724
- };
2725
- var updateServerManifestEntry = (state, artifact) => {
2726
- const fileWithHash = basename4(artifact.path);
2727
- const [baseName] = fileWithHash.split(`.${artifact.hash}.`);
2728
- if (!baseName) {
2729
- return;
2730
- }
2731
- state.manifest[toPascal(baseName)] = artifact.path;
2732
- };
2733
- var bundleAngularClient = async (state, clientPaths, buildDir) => {
2734
- const { build: bunBuild3 } = await Promise.resolve(globalThis.Bun);
2735
- const { generateManifest: generateManifest2 } = await import("./chunk-41bf6aqt.js");
2736
- const { getAngularVendorPaths: getAngularVendorPaths2 } = await import("./chunk-vjhxm8n2.js");
2737
- const clientRoot = await computeClientRoot(state.resolvedPaths);
2738
- const depVendorPaths = globalThis.__depVendorPaths ?? {};
2739
- let angVendorPaths = getAngularVendorPaths2();
2740
- if (!angVendorPaths) {
2741
- const { computeAngularVendorPaths: computeAngularVendorPaths2 } = await import("./chunk-r6e8pytx.js");
2742
- const { setAngularVendorPaths: setAngularVendorPaths2 } = await import("./chunk-vjhxm8n2.js");
2743
- angVendorPaths = computeAngularVendorPaths2(globalThis.__angularVendorSpecifiers);
2744
- setAngularVendorPaths2(angVendorPaths);
2745
- }
2746
- const clientResult = await bunBuild3({
2747
- entrypoints: clientPaths,
2748
- ...Object.keys({
2749
- ...angVendorPaths ?? {},
2750
- ...depVendorPaths
2751
- }).length > 0 ? {
2752
- external: Object.keys({
2753
- ...angVendorPaths ?? {},
2754
- ...depVendorPaths
2755
- })
2756
- } : {},
2757
- format: "esm",
2758
- naming: "[dir]/[name].[hash].[ext]",
2759
- outdir: buildDir,
2760
- plugins: [
2761
- createStylePreprocessorPlugin(getStyleTransformConfig(state.config))
2762
- ],
2763
- root: clientRoot,
2764
- target: "browser",
2765
- throw: false
2766
- });
2767
- if (!clientResult.success) {
2768
- return;
2769
- }
2770
- if (angVendorPaths || Object.keys(depVendorPaths).length > 0) {
2771
- const { rewriteImports } = await import("./chunk-r7jmgqnw.js");
2772
- await rewriteImports(clientResult.outputs.map((artifact) => artifact.path), {
2773
- ...angVendorPaths ?? {},
2774
- ...depVendorPaths
2775
- });
2776
- }
2777
- const clientManifest = generateManifest2(clientResult.outputs, buildDir);
2778
- Object.assign(state.manifest, clientManifest);
2779
- await populateAssetStore(state.assetStore, clientManifest, buildDir);
2780
- };
2781
- var broadcastAngularPageUpdates = (state, pagesToUpdate, manifest, startTime) => {
2782
- pagesToUpdate.forEach((angularPagePath) => {
2783
- const fileName = basename4(angularPagePath);
2784
- const baseName = fileName.replace(/\.[tj]s$/, "");
2785
- const pascalName = toPascal(baseName);
2786
- const cssKey = `${pascalName}CSS`;
2787
- const cssUrl = manifest[cssKey] || null;
2788
- const duration = Date.now() - startTime;
2789
- logHmrUpdate(angularPagePath, "angular", duration);
2790
- broadcastToClients(state, {
2791
- data: {
2792
- cssBaseName: baseName,
2793
- cssUrl,
2794
- framework: "angular",
2795
- manifest,
2796
- sourceFile: angularPagePath,
2797
- updateType: "logic"
2798
- },
2799
- type: "angular-update"
2800
- });
2801
- });
2802
- };
2803
- var compileAndBundleAngular = async (state, pageEntries, angularDir) => {
2804
- const { compileAngular } = await import("./chunk-92fsjfpp.js");
2805
- const { clientPaths, serverPaths } = await compileAngular(pageEntries, angularDir, true, getStyleTransformConfig(state.config));
2806
- const { getAngularServerVendorPaths: getAngularServerVendorPaths2 } = await import("./chunk-vjhxm8n2.js");
2807
- const angServerVendorPaths = getAngularServerVendorPaths2();
2808
- if (serverPaths.length > 0 && angServerVendorPaths) {
2809
- const { rewriteImports } = await import("./chunk-r7jmgqnw.js");
2810
- await rewriteImports(serverPaths, angServerVendorPaths);
2811
- }
2812
- serverPaths.forEach((serverPath) => {
2813
- const fileBase = basename4(serverPath, ".js");
2814
- state.manifest[toPascal(fileBase)] = resolve9(serverPath);
2815
- });
2816
- if (clientPaths.length > 0) {
2817
- await bundleAngularClient(state, clientPaths, state.resolvedPaths.buildDir);
2818
- }
2819
- };
2820
- var handleAngularFastPath = async (state, config, filesToRebuild, startTime, onRebuildComplete) => {
2821
- const angularDir = config.angularDirectory ?? "";
2822
- const angularFiles = filesToRebuild.filter((file) => detectFramework(file, state.resolvedPaths) === "angular");
2823
- for (const file of angularFiles) {
2824
- state.fileHashes.set(resolve9(file), computeFileHash(file));
2825
- }
2826
- const angularPagesPath = resolve9(angularDir, "pages");
2827
- const pageEntries = resolveAngularPageEntries(state, angularFiles, angularPagesPath);
2828
- if (pageEntries.length > 0) {
2829
- await compileAndBundleAngular(state, pageEntries, angularDir);
2830
- markSsrCacheDirty("angular");
2831
- }
2832
- const { manifest } = state;
2833
- const angularHmrFiles = angularFiles.filter((file) => file.endsWith(".ts") || file.endsWith(".html"));
2834
- const angularPageFiles = angularHmrFiles.filter((file) => file.replace(/\\/g, "/").includes("/pages/"));
2835
- const pagesToUpdate = angularPageFiles.length > 0 ? angularPageFiles : pageEntries;
2836
- broadcastAngularPageUpdates(state, pagesToUpdate, manifest, startTime);
2837
- onRebuildComplete({ hmrState: state, manifest });
2838
- return manifest;
2839
- };
2840
- var resolveReactEntryForPageFile = (normalized, pagesPathResolved, reactIndexesPath) => {
2841
- const pageName = basename4(normalized, ".tsx");
2842
- const indexPath = resolve9(reactIndexesPath, `${pageName}.tsx`);
2843
- if (!existsSync7(indexPath)) {
2844
- return;
2845
- }
2846
- return indexPath;
2847
- };
2848
- var resolveReactEntriesFromDeps = (state, normalized, pagesPathResolved, reactIndexesPath, reactEntries) => {
2849
- const affected = getAffectedFiles(state.dependencyGraph, normalized);
2850
- affected.forEach((dep) => {
2851
- if (!dep.startsWith(pagesPathResolved)) {
2852
- return;
2853
- }
2854
- const pageName = basename4(dep, ".tsx");
2855
- const indexPath = resolve9(reactIndexesPath, `${pageName}.tsx`);
2856
- if (existsSync7(indexPath) && !reactEntries.includes(indexPath)) {
2857
- reactEntries.push(indexPath);
2858
- }
2859
- });
2860
- };
2861
- var resolveReactEntryForFile = (state, file, pagesPathResolved, reactIndexesPath, reactEntries) => {
2862
- const normalized = resolve9(file);
2863
- if (!normalized.startsWith(pagesPathResolved)) {
2864
- resolveReactEntriesFromDeps(state, normalized, pagesPathResolved, reactIndexesPath, reactEntries);
2865
- return;
2866
- }
2867
- const entry = resolveReactEntryForPageFile(normalized, pagesPathResolved, reactIndexesPath);
2868
- if (entry) {
2869
- reactEntries.push(entry);
2870
- }
2871
- };
2872
- var collectReactEntries = (state, filesToRebuild, reactPagesPath, reactIndexesPath) => {
2873
- const reactEntries = [];
2874
- const pagesPathResolved = resolve9(reactPagesPath);
2875
- filesToRebuild.forEach((file) => {
2876
- resolveReactEntryForFile(state, file, pagesPathResolved, reactIndexesPath, reactEntries);
2877
- });
2878
- return reactEntries;
2879
- };
2880
- var bundleReactClient = async (state, reactEntries, reactIndexesPath, buildDir) => {
2881
- const { build: bunBuild3 } = await Promise.resolve(globalThis.Bun);
2882
- const { generateManifest: generateManifest2 } = await import("./chunk-41bf6aqt.js");
2883
- const { getDevVendorPaths: getDevVendorPaths2 } = await import("./chunk-vjhxm8n2.js");
2884
- const { rewriteReactImports: rewriteReactImports2 } = await import("./chunk-6sccb4jr.js");
2885
- const clientRoot = await computeClientRoot(state.resolvedPaths);
2886
- const depVendorPaths = globalThis.__depVendorPaths ?? {};
2887
- const refreshEntry = resolve9(reactIndexesPath, "_refresh.tsx");
2888
- if (!reactEntries.includes(refreshEntry)) {
2889
- reactEntries.push(refreshEntry);
2890
- }
2891
- let vendorPaths = getDevVendorPaths2();
2892
- if (!vendorPaths) {
2893
- const { computeVendorPaths: computeVendorPaths2 } = await import("./chunk-z9nvhm6r.js");
2894
- const { setDevVendorPaths: setDevVendorPaths2 } = await import("./chunk-vjhxm8n2.js");
2895
- vendorPaths = computeVendorPaths2();
2896
- setDevVendorPaths2(vendorPaths);
2897
- }
2898
- const { rmSync: rmSync2 } = await import("fs");
2899
- rmSync2(resolve9(buildDir, "react", "generated", "indexes"), {
2900
- force: true,
2901
- recursive: true
2902
- });
2903
- const clientResult = await bunBuild3({
2904
- entrypoints: reactEntries,
2905
- format: "esm",
2906
- jsx: { development: true },
2907
- naming: "[dir]/[name].[hash].[ext]",
2908
- outdir: buildDir,
2909
- plugins: [
2910
- createStylePreprocessorPlugin(getStyleTransformConfig(state.config))
2911
- ],
2912
- reactFastRefresh: true,
2913
- root: clientRoot,
2914
- splitting: true,
2915
- target: "browser",
2916
- throw: false,
2917
- ...Object.keys({
2918
- ...vendorPaths ?? {},
2919
- ...depVendorPaths
2920
- }).length > 0 ? {
2921
- external: Object.keys({
2922
- ...vendorPaths ?? {},
2923
- ...depVendorPaths
2924
- })
2925
- } : {}
2926
- });
2927
- if (!clientResult.success) {
2928
- return;
2929
- }
2930
- if (vendorPaths || Object.keys(depVendorPaths).length > 0) {
2931
- await rewriteReactImports2(clientResult.outputs.map((art) => art.path), {
2932
- ...vendorPaths ?? {},
2933
- ...depVendorPaths
2934
- });
2935
- }
2936
- const clientManifest = generateManifest2(clientResult.outputs, buildDir);
2937
- Object.assign(state.manifest, clientManifest);
2938
- await populateAssetStore(state.assetStore, clientManifest, buildDir);
2939
- };
2940
- var getModuleUrl = async (pageFile) => {
2941
- const { invalidateModule, warmCache, SRC_URL_PREFIX } = await import("./chunk-zrg9d4zw.js");
2942
- invalidateModule(pageFile);
2943
- const rel = relative2(process.cwd(), pageFile).replace(/\\/g, "/");
2944
- const url = `${SRC_URL_PREFIX}${rel}`;
2945
- warmCache(url);
2946
- return url;
2947
- };
2948
- var getReactModuleUrl = getModuleUrl;
2949
- var resolveBroadcastTarget = async (primaryFile) => {
2950
- const isComponentFile = primaryFile.endsWith(".tsx") || primaryFile.endsWith(".jsx");
2951
- if (isComponentFile)
2952
- return primaryFile;
2953
- const { findNearestComponent } = await import("./chunk-xz1kdswj.js");
2954
- const nearest = findNearestComponent(resolve9(primaryFile));
2955
- return nearest ?? primaryFile;
2956
- };
2957
- var handleReactModuleServerPath = async (state, reactFiles, startTime, onRebuildComplete) => {
2958
- for (const file of reactFiles) {
2959
- state.fileHashes.set(resolve9(file), computeFileHash(file));
2960
- }
2961
- markSsrCacheDirty("react");
2962
- const primaryFile = reactFiles.find((file) => !file.replace(/\\/g, "/").includes("/pages/")) ?? reactFiles[0];
2963
- if (!primaryFile) {
2964
- onRebuildComplete({
2965
- hmrState: state,
2966
- manifest: state.manifest
2967
- });
2968
- return state.manifest;
2969
- }
2970
- const { invalidateModule } = await getModuleServer();
2971
- for (const file of reactFiles) {
2972
- invalidateModule(file);
2973
- }
2974
- const broadcastTarget = await resolveBroadcastTarget(primaryFile);
2975
- const pageModuleUrl = await getReactModuleUrl(broadcastTarget);
2976
- if (pageModuleUrl) {
2977
- const serverDuration = Date.now() - startTime;
2978
- state.lastHmrPath = relative2(process.cwd(), primaryFile).replace(/\\/g, "/");
2979
- state.lastHmrFramework = "react";
2980
- broadcastToClients(state, {
2981
- data: {
2982
- framework: "react",
2983
- hasComponentChanges: true,
2984
- hasCSSChanges: false,
2985
- manifest: state.manifest,
2986
- pageModuleUrl,
2987
- primarySource: primaryFile,
2988
- serverDuration,
2989
- sourceFiles: reactFiles
2990
- },
2991
- type: "react-update"
2992
- });
2993
- }
2994
- onRebuildComplete({
2995
- hmrState: state,
2996
- manifest: state.manifest
2997
- });
2998
- return state.manifest;
2999
- };
3000
- var handleReactFastPath = async (state, config, filesToRebuild, startTime, onRebuildComplete) => {
3001
- const reactDir = config.reactDirectory ?? "";
3002
- const reactPagesPath = resolve9(reactDir, "pages");
3003
- const reactIndexesPath = resolve9(reactDir, "generated", "indexes");
3004
- const { buildDir } = state.resolvedPaths;
3005
- const reactFiles = filesToRebuild.filter((file) => detectFramework(file, state.resolvedPaths) === "react");
3006
- if (reactFiles.length > 0) {
3007
- return handleReactModuleServerPath(state, reactFiles, startTime, onRebuildComplete);
3008
- }
3009
- const { generateReactIndexFiles: generateReactIndexFiles2 } = await import("./chunk-9xrsjeem.js");
3010
- await generateReactIndexFiles2(reactPagesPath, reactIndexesPath, true);
3011
- const reactEntries = collectReactEntries(state, filesToRebuild, reactPagesPath, reactIndexesPath);
3012
- if (reactEntries.length > 0) {
3013
- await bundleReactClient(state, reactEntries, reactIndexesPath, buildDir);
3014
- }
3015
- const { manifest } = state;
3016
- const duration = Date.now() - startTime;
3017
- const reactPageFiles = reactFiles.filter((file) => file.replace(/\\/g, "/").includes("/pages/"));
3018
- const sourceFiles = reactPageFiles.length > 0 ? reactPageFiles : reactFiles;
3019
- logHmrUpdate(sourceFiles[0] ?? reactFiles[0] ?? "", "react", duration);
3020
- broadcastToClients(state, {
3021
- data: {
3022
- framework: "react",
3023
- hasComponentChanges: true,
3024
- hasCSSChanges: false,
3025
- manifest,
3026
- primarySource: sourceFiles[0],
3027
- sourceFiles
3028
- },
3029
- type: "react-update"
3030
- });
3031
- onRebuildComplete({ hmrState: state, manifest });
3032
- return manifest;
3033
- };
3034
- var handleServerManifestUpdate = (state, serverResult) => {
3035
- if (!serverResult?.success) {
3036
- return;
3037
- }
3038
- serverResult.outputs.forEach((artifact) => {
3039
- updateServerManifestEntry(state, artifact);
3040
- });
3041
- };
3042
- var handleClientManifestUpdate = async (state, clientResult, buildDir) => {
3043
- if (!clientResult?.success) {
3044
- return;
3045
- }
3046
- const { generateManifest: generateManifest2 } = await import("./chunk-41bf6aqt.js");
3047
- const clientManifest = generateManifest2(clientResult.outputs, buildDir);
3048
- Object.assign(state.manifest, clientManifest);
3049
- await populateAssetStore(state.assetStore, clientManifest, buildDir);
3050
- };
3051
- var broadcastSvelteModuleUpdate = async (state, changedFile, svelteFiles, serverDuration) => {
3052
- const pageModuleUrl = await getModuleUrl(changedFile);
3053
- state.lastHmrPath = changedFile;
3054
- state.lastHmrFramework = "svelte";
3055
- broadcastToClients(state, {
3056
- data: {
3057
- framework: "svelte",
3058
- manifest: state.manifest,
3059
- pageModuleUrl,
3060
- serverDuration,
3061
- sourceFile: changedFile,
3062
- sourceFiles: svelteFiles,
3063
- updateType: "full"
3064
- },
3065
- type: "svelte-update"
3066
- });
3067
- };
3068
- var handleSvelteModuleServerPath = async (state, svelteFiles, startTime, onRebuildComplete) => {
3069
- for (const file of svelteFiles) {
3070
- state.fileHashes.set(resolve9(file), computeFileHash(file));
3071
- }
3072
- markSsrCacheDirty("svelte");
3073
- const serverDuration = Date.now() - startTime;
3074
- await runSequentially(svelteFiles, (changedFile) => broadcastSvelteModuleUpdate(state, changedFile, svelteFiles, serverDuration));
3075
- onRebuildComplete({
3076
- hmrState: state,
3077
- manifest: state.manifest
3078
- });
3079
- return state.manifest;
3080
- };
3081
- var handleSvelteFastPath = async (state, config, filesToRebuild, startTime, onRebuildComplete) => {
3082
- const svelteDir = config.svelteDirectory ?? "";
3083
- const svelteFiles = filesToRebuild.filter((file) => (file.endsWith(".svelte") || file.includes(".svelte.")) && detectFramework(file, state.resolvedPaths) === "svelte");
3084
- if (svelteFiles.length > 0) {
3085
- return handleSvelteModuleServerPath(state, svelteFiles, startTime, onRebuildComplete);
3086
- }
3087
- const { buildDir } = state.resolvedPaths;
3088
- if (svelteFiles.length > 0) {
3089
- const { compileSvelte } = await import("./chunk-x09cskqd.js");
3090
- const { build: bunBuild3 } = await Promise.resolve(globalThis.Bun);
3091
- const clientRoot = await computeClientRoot(state.resolvedPaths);
3092
- const { svelteServerPaths, svelteIndexPaths, svelteClientPaths } = await compileSvelte(svelteFiles, svelteDir, new Map, true, getStyleTransformConfig(state.config));
3093
- const serverEntries = [...svelteServerPaths];
3094
- const clientEntries = [...svelteIndexPaths, ...svelteClientPaths];
3095
- const serverRoot = resolve9(svelteDir, "generated", "server");
3096
- const serverOutDir = resolve9(buildDir, basename4(svelteDir));
3097
- const [serverResult, clientResult] = await Promise.all([
3098
- serverEntries.length > 0 ? bunBuild3({
3099
- entrypoints: serverEntries,
3100
- external: [
3101
- "react",
3102
- "react/*",
3103
- "react-dom",
3104
- "react-dom/*",
3105
- "svelte",
3106
- "svelte/*"
3107
- ],
3108
- format: "esm",
3109
- naming: "[dir]/[name].[hash].[ext]",
3110
- outdir: serverOutDir,
3111
- plugins: [
3112
- createStylePreprocessorPlugin(getStyleTransformConfig(state.config))
3113
- ],
3114
- root: serverRoot,
3115
- target: "bun",
3116
- throw: false
3117
- }) : undefined,
3118
- clientEntries.length > 0 ? bunBuild3({
3119
- entrypoints: clientEntries,
3120
- format: "esm",
3121
- naming: "[dir]/[name].[hash].[ext]",
3122
- outdir: buildDir,
3123
- plugins: [
3124
- createStylePreprocessorPlugin(getStyleTransformConfig(state.config))
3125
- ],
3126
- root: clientRoot,
3127
- target: "browser",
3128
- throw: false
3129
- }) : undefined
3130
- ]);
3131
- handleServerManifestUpdate(state, serverResult);
3132
- await handleClientManifestUpdate(state, clientResult, buildDir);
3133
- }
3134
- const { manifest } = state;
3135
- const duration = Date.now() - startTime;
3136
- const broadcastFiles = svelteFiles.length > 0 ? svelteFiles : filesToRebuild;
3137
- broadcastFiles.forEach((sveltePagePath) => {
3138
- const fileName = basename4(sveltePagePath);
3139
- const baseName = fileName.replace(/\.svelte$/, "");
3140
- const pascalName = toPascal(baseName);
3141
- const cssKey = `${pascalName}CSS`;
3142
- const cssUrl = manifest[cssKey] || null;
3143
- logHmrUpdate(sveltePagePath, "svelte", duration);
3144
- broadcastToClients(state, {
3145
- data: {
3146
- cssBaseName: baseName,
3147
- cssUrl,
3148
- framework: "svelte",
3149
- html: null,
3150
- manifest,
3151
- sourceFile: sveltePagePath,
3152
- updateType: "full"
3153
- },
3154
- type: "svelte-update"
3155
- });
3156
- });
3157
- onRebuildComplete({ hmrState: state, manifest });
3158
- return manifest;
3159
- };
3160
- var collectAffectedVueFiles = (state, nonVueFiles, vueFiles) => {
3161
- for (const tsFile of nonVueFiles) {
3162
- const affected = getAffectedFiles(state.dependencyGraph, tsFile);
3163
- const newVueDeps = affected.filter((dep) => dep.endsWith(".vue") && !vueFiles.includes(dep));
3164
- vueFiles.push(...newVueDeps);
3165
- }
3166
- };
3167
- var invalidateNonVueModules = async (nonVueFiles) => {
3168
- if (nonVueFiles.length === 0)
3169
- return;
3170
- const { invalidateModule } = await getModuleServer();
3171
- for (const file of nonVueFiles) {
3172
- invalidateModule(file);
3173
- }
3174
- };
3175
- var broadcastVueModuleUpdate = async (state, changedFile, vueFiles, nonVueFiles, forceReload, serverDuration) => {
3176
- const pageModuleUrl = await getModuleUrl(changedFile);
3177
- const [firstNonVue] = nonVueFiles;
3178
- state.lastHmrPath = nonVueFiles.length > 0 && firstNonVue ? firstNonVue : changedFile;
3179
- state.lastHmrFramework = "vue";
3180
- broadcastToClients(state, {
3181
- data: {
3182
- changeType: "full",
3183
- forceReload,
3184
- framework: "vue",
3185
- manifest: state.manifest,
3186
- pageModuleUrl,
3187
- serverDuration,
3188
- sourceFile: changedFile,
3189
- sourceFiles: vueFiles,
3190
- updateType: "full"
3191
- },
3192
- type: "vue-update"
3193
- });
3194
- };
3195
- var handleVueModuleServerPath = async (state, vueFiles, nonVueFiles, startTime, onRebuildComplete) => {
3196
- for (const file of [...vueFiles, ...nonVueFiles]) {
3197
- state.fileHashes.set(resolve9(file), computeFileHash(file));
3198
- }
3199
- markSsrCacheDirty("vue");
3200
- await invalidateNonVueModules(nonVueFiles);
3201
- const serverDuration = Date.now() - startTime;
3202
- const forceReload = nonVueFiles.length > 0;
3203
- await runSequentially(vueFiles, (changedFile) => broadcastVueModuleUpdate(state, changedFile, vueFiles, nonVueFiles, forceReload, serverDuration));
3204
- onRebuildComplete({
3205
- hmrState: state,
3206
- manifest: state.manifest
3207
- });
3208
- return state.manifest;
3209
- };
3210
- var handleVueFastPath = async (state, config, filesToRebuild, startTime, onRebuildComplete) => {
3211
- const vueFiles = filesToRebuild.filter((file) => file.endsWith(".vue") && detectFramework(file, state.resolvedPaths) === "vue");
3212
- const nonVueFiles = filesToRebuild.filter((file) => !file.endsWith(".vue") && detectFramework(file, state.resolvedPaths) === "vue");
3213
- collectAffectedVueFiles(state, nonVueFiles, vueFiles);
3214
- if (vueFiles.length > 0) {
3215
- return handleVueModuleServerPath(state, vueFiles, nonVueFiles, startTime, onRebuildComplete);
3216
- }
3217
- onRebuildComplete({ hmrState: state, manifest: state.manifest });
3218
- return state.manifest;
3219
- };
3220
- var collectModuleUpdatesForFramework = (framework, filesToRebuild, manifest, state) => {
3221
- const frameworkFiles = filesToRebuild.filter((file) => detectFramework(file, state.resolvedPaths) === framework);
3222
- if (frameworkFiles.length === 0) {
3223
- return [];
3224
- }
3225
- return createModuleUpdates(frameworkFiles, framework, manifest, state.resolvedPaths);
3226
- };
3227
- var collectAllModuleUpdates = (affectedFrameworks, filesToRebuild, manifest, state) => {
3228
- const allModuleUpdates = [];
3229
- affectedFrameworks.forEach((framework) => {
3230
- const moduleUpdates = collectModuleUpdatesForFramework(framework, filesToRebuild, manifest, state);
3231
- moduleUpdates.forEach((update) => {
3232
- if (update) {
3233
- allModuleUpdates.push(update);
3234
- }
3235
- });
3236
- });
3237
- return allModuleUpdates;
3238
- };
3239
- var handleReactHMR = (state, affectedFrameworks, filesToRebuild, manifest, duration) => {
3240
- if (!affectedFrameworks.includes("react") || !state.resolvedPaths.reactDir) {
3241
- return;
3242
- }
3243
- const reactFiles = filesToRebuild.filter((file) => detectFramework(file, state.resolvedPaths) === "react");
3244
- if (reactFiles.length === 0) {
3245
- return;
3246
- }
3247
- const reactPageFiles = reactFiles.filter((file) => file.replace(/\\/g, "/").includes("/pages/"));
3248
- const sourceFiles = reactPageFiles.length > 0 ? reactPageFiles : reactFiles;
3249
- const [primarySource] = sourceFiles;
3250
- try {
3251
- const hasComponentChanges = reactFiles.some((file) => file.endsWith(".tsx") || file.endsWith(".ts") || file.endsWith(".jsx"));
3252
- const hasCSSChanges = reactFiles.some(isStylePath);
3253
- logHmrUpdate(primarySource ?? reactFiles[0] ?? "", "react", duration);
3254
- broadcastToClients(state, {
3255
- data: {
3256
- framework: "react",
3257
- hasComponentChanges,
3258
- hasCSSChanges,
3259
- manifest,
3260
- primarySource,
3261
- sourceFiles
3262
- },
3263
- type: "react-update"
3264
- });
3265
- } catch (err) {
3266
- sendTelemetryEvent("hmr:error", {
3267
- framework: "react",
3268
- message: err instanceof Error ? err.message : String(err)
3269
- });
3270
- }
3271
- };
3272
- var handleScriptUpdate = (state, scriptFile, manifest, framework, duration) => {
3273
- const scriptBaseName = basename4(scriptFile).replace(/\.(ts|js|tsx|jsx)$/, "");
3274
- const pascalName = toPascal(scriptBaseName);
3275
- const scriptPath = manifest[pascalName] || null;
3276
- if (!scriptPath) {
3277
- logWarn(`Script not found in manifest: ${pascalName}`);
3278
- return;
3279
- }
3280
- logScriptUpdate(scriptFile, framework, duration);
3281
- broadcastToClients(state, {
3282
- data: {
3283
- framework,
3284
- manifest,
3285
- scriptPath,
3286
- sourceFile: scriptFile
3287
- },
3288
- type: "script-update"
3289
- });
3290
- };
3291
- var isScriptFile = (file) => (file.endsWith(".ts") || file.endsWith(".js") || file.endsWith(".tsx") || file.endsWith(".jsx")) && file.replace(/\\/g, "/").includes("/scripts/");
3292
- var resolveIslandDefinitionSource = (definition, buildInfo, islandFiles) => {
3293
- const { buildReference } = definition;
3294
- if (!buildReference?.source) {
3295
- return;
3296
- }
3297
- const sourcePath = buildReference.source.startsWith("file://") ? new URL(buildReference.source).pathname : resolve9(dirname2(buildInfo.resolvedRegistryPath), buildReference.source);
3298
- islandFiles.add(resolve9(sourcePath));
3299
- };
3300
- var resolveIslandSourceFiles = async (config) => {
3301
- const registryPath = config.islands?.registry;
3302
- if (!registryPath) {
3303
- return new Set;
3304
- }
3305
- const buildInfo = await loadIslandRegistryBuildInfo(registryPath);
3306
- const islandFiles = new Set([
3307
- resolve9(buildInfo.resolvedRegistryPath)
3308
- ]);
3309
- for (const definition of buildInfo.definitions) {
3310
- resolveIslandDefinitionSource(definition, buildInfo, islandFiles);
3311
- }
3312
- return islandFiles;
3313
- };
3314
- var didStaticPagesNeedIslandRefresh = async (config, filesToRebuild) => {
3315
- const islandFiles = await resolveIslandSourceFiles(config);
3316
- if (islandFiles.size === 0) {
3317
- return false;
3318
- }
3319
- return filesToRebuild.some((file) => islandFiles.has(resolve9(file)));
3320
- };
3321
- var handleIslandSourceReload = async (state, config, filesToRebuild, manifest) => {
3322
- const shouldReload = await didStaticPagesNeedIslandRefresh(config, filesToRebuild);
3323
- if (!shouldReload) {
3324
- return false;
3325
- }
3326
- setCurrentPageIslandMetadata(await loadPageIslandMetadata(config));
3327
- const affectedPages = filesToRebuild.flatMap((file) => getPagesUsingIslandSource(file));
3328
- broadcastToClients(state, {
3329
- data: {
3330
- affectedPages,
3331
- manifest
3332
- },
3333
- type: "full-reload"
3334
- });
3335
- return true;
3336
- };
3337
- var handleHTMLScriptHMR = (state, filesToRebuild, manifest, duration) => {
3338
- if (!state.resolvedPaths.htmlDir) {
3339
- return;
3340
- }
3341
- const htmlFrameworkFiles = filesToRebuild.filter((file) => detectFramework(file, state.resolvedPaths) === "html");
3342
- if (htmlFrameworkFiles.length === 0) {
3343
- return;
3344
- }
3345
- const scriptFiles = htmlFrameworkFiles.filter(isScriptFile);
3346
- const htmlPageFiles = htmlFrameworkFiles.filter((file) => file.endsWith(".html"));
3347
- if (scriptFiles.length === 0 || htmlPageFiles.length > 0) {
3348
- return;
3349
- }
3350
- scriptFiles.forEach((scriptFile) => {
3351
- handleScriptUpdate(state, scriptFile, manifest, "html", duration);
3352
- });
3353
- };
3354
- var computeOutputPagesDir = (state, config, framework) => {
3355
- const isSingle = !config.reactDirectory && !config.svelteDirectory && !config.vueDirectory && (framework === "html" ? !config.htmxDirectory : !config.htmlDirectory);
3356
- if (isSingle) {
3357
- return resolve9(state.resolvedPaths.buildDir, "pages");
3358
- }
3359
- const dirName = framework === "html" ? basename4(config.htmlDirectory ?? "html") : basename4(config.htmxDirectory ?? "htmx");
3360
- return resolve9(state.resolvedPaths.buildDir, dirName, "pages");
3361
- };
3362
- var processHtmlPageUpdate = async (state, pageFile, builtHtmlPagePath, manifest, duration) => {
3363
- try {
3364
- const { handleHTMLUpdate } = await import("./chunk-30yrw0f6.js");
3365
- const newHTML = await handleHTMLUpdate(builtHtmlPagePath);
3366
- if (!newHTML) {
3367
- return;
3368
- }
3369
- logHmrUpdate(pageFile, "html", duration);
3370
- broadcastToClients(state, {
3371
- data: {
3372
- framework: "html",
3373
- html: newHTML,
3374
- manifest,
3375
- sourceFile: builtHtmlPagePath
3376
- },
3377
- type: "html-update"
3378
- });
3379
- } catch (err) {
3380
- sendTelemetryEvent("hmr:error", {
3381
- framework: "html",
3382
- message: err instanceof Error ? err.message : String(err)
3383
- });
3384
- }
3385
- };
3386
- var handleHTMLPageHMR = async (state, config, filesToRebuild, manifest, duration) => {
3387
- if (!state.resolvedPaths.htmlDir) {
3388
- return;
3389
- }
3390
- const shouldRefreshFromIslandChange = await didStaticPagesNeedIslandRefresh(config, filesToRebuild);
3391
- const htmlFrameworkFiles = filesToRebuild.filter((file) => detectFramework(file, state.resolvedPaths) === "html");
3392
- if (htmlFrameworkFiles.length === 0 && !shouldRefreshFromIslandChange) {
3393
- return;
3394
- }
3395
- const htmlPageFiles = htmlFrameworkFiles.filter((file) => file.endsWith(".html"));
3396
- const outputHtmlPages = computeOutputPagesDir(state, config, "html");
3397
- const shouldRefreshAllPages = htmlPageFiles.length === 0 && shouldRefreshFromIslandChange;
3398
- const pageFilesToUpdate = shouldRefreshAllPages ? await scanEntryPoints(outputHtmlPages, "*.html") : htmlPageFiles;
3399
- await runSequentially(pageFilesToUpdate, async (pageFile) => {
3400
- const htmlPageName = basename4(pageFile);
3401
- const builtHtmlPagePath = resolve9(outputHtmlPages, htmlPageName);
3402
- await processHtmlPageUpdate(state, pageFile, builtHtmlPagePath, manifest, duration);
3403
- });
3404
- };
3405
- var handleVueCssOnlyUpdate = (state, vueCssFiles, manifest, duration) => {
3406
- const [cssFile] = vueCssFiles;
3407
- if (!cssFile) {
3408
- return;
3409
- }
3410
- const cssBaseName = basename4(getStyleBaseName(cssFile));
3411
- const cssPascalName = toPascal(cssBaseName);
3412
- const cssKey = `${cssPascalName}CSS`;
3413
- const cssUrl = manifest[cssKey] || null;
3414
- logCssUpdate(cssFile, "vue", duration);
3415
- broadcastToClients(state, {
3416
- data: {
3417
- cssBaseName,
3418
- cssUrl,
3419
- framework: "vue",
3420
- manifest,
3421
- sourceFile: cssFile,
3422
- updateType: "css-only"
3423
- },
3424
- type: "vue-update"
3425
- });
3426
- };
3427
- var broadcastVueStyleOnly = (state, vuePagePath, baseName, cssUrl, hmrId, manifest, duration) => {
3428
- logCssUpdate(vuePagePath, "vue", duration);
3429
- broadcastToClients(state, {
3430
- data: {
3431
- changeType: "style-only",
3432
- cssBaseName: baseName,
3433
- cssUrl,
3434
- framework: "vue",
3435
- hmrId,
3436
- manifest,
3437
- sourceFile: vuePagePath,
3438
- updateType: "css-only"
3439
- },
3440
- type: "vue-update"
3441
- });
3442
- };
3443
- var broadcastVueFullUpdate = (state, vuePagePath, changeType, cssUrl, hmrId, manifest, pascalName, duration) => {
3444
- const componentPath = manifest[`${pascalName}Client`] || null;
3445
- logHmrUpdate(vuePagePath, "vue", duration);
3446
- broadcastToClients(state, {
3447
- data: {
3448
- changeType,
3449
- componentPath,
3450
- cssUrl,
3451
- framework: "vue",
3452
- hmrId,
3453
- html: null,
3454
- manifest,
3455
- sourceFile: vuePagePath,
3456
- updateType: "full"
3457
- },
3458
- type: "vue-update"
3459
- });
3460
- };
3461
- var broadcastVuePageChange = async (state, config, vuePagePath, manifest, duration) => {
3462
- const fileName = basename4(vuePagePath);
3463
- const baseName = fileName.replace(/\.vue$/, "");
3464
- const pascalName = toPascal(baseName);
3465
- const vueRoot = config.vueDirectory;
3466
- const hmrId = vueRoot ? relative2(vueRoot, vuePagePath).replace(/\\/g, "/").replace(/\.vue$/, "") : baseName;
3467
- const cssKey = `${pascalName}CSS`;
3468
- const cssUrl = manifest[cssKey] || null;
3469
- const { vueHmrMetadata } = await import("./chunk-5f67rsed.js");
3470
- const hmrMeta = vueHmrMetadata.get(resolve9(vuePagePath));
3471
- const changeType = hmrMeta?.changeType ?? "full";
3472
- if (changeType === "style-only") {
3473
- broadcastVueStyleOnly(state, vuePagePath, baseName, cssUrl, hmrId, manifest, duration);
3474
- return;
3475
- }
3476
- broadcastVueFullUpdate(state, vuePagePath, changeType, cssUrl, hmrId, manifest, pascalName, duration);
3477
- };
3478
- var processVuePageUpdate = async (state, config, vuePagePath, manifest, duration) => {
3479
- try {
3480
- await broadcastVuePageChange(state, config, vuePagePath, manifest, duration);
3481
- } catch (err) {
3482
- sendTelemetryEvent("hmr:error", {
3483
- framework: "vue",
3484
- message: err instanceof Error ? err.message : String(err)
3485
- });
3486
- }
3487
- };
3488
- var handleVueHMR = async (state, config, filesToRebuild, manifest, duration) => {
3489
- if (!config.vueDirectory) {
3490
- return;
3491
- }
3492
- const vueFiles = filesToRebuild.filter((file) => detectFramework(file, state.resolvedPaths) === "vue");
3493
- if (vueFiles.length === 0) {
3494
- return;
3495
- }
3496
- const vueComponentFiles = vueFiles.filter((file) => file.endsWith(".vue"));
3497
- const vueCssFiles = vueFiles.filter(isStylePath);
3498
- const isCssOnlyChange = vueComponentFiles.length === 0 && vueCssFiles.length > 0;
3499
- const vuePageFiles = vueFiles.filter((file) => file.replace(/\\/g, "/").includes("/pages/"));
3500
- const pagesToUpdate = vuePageFiles.length > 0 ? vuePageFiles : vueComponentFiles;
3501
- if (isCssOnlyChange && vueCssFiles.length > 0) {
3502
- handleVueCssOnlyUpdate(state, vueCssFiles, manifest, duration);
3503
- }
3504
- await runSequentially(pagesToUpdate, (vuePagePath) => processVuePageUpdate(state, config, vuePagePath, manifest, duration));
3505
- };
3506
- var handleSvelteCssOnlyUpdate = (state, svelteCssFiles, manifest, duration) => {
3507
- const [cssFile] = svelteCssFiles;
3508
- if (!cssFile) {
3509
- return;
3510
- }
3511
- const cssBaseName = basename4(getStyleBaseName(cssFile));
3512
- const cssPascalName = toPascal(cssBaseName);
3513
- const cssKey = `${cssPascalName}CSS`;
3514
- const cssUrl = manifest[cssKey] || null;
3515
- logCssUpdate(cssFile, "svelte", duration);
3516
- broadcastToClients(state, {
3517
- data: {
3518
- cssBaseName,
3519
- cssUrl,
3520
- framework: "svelte",
3521
- manifest,
3522
- sourceFile: cssFile,
3523
- updateType: "css-only"
3524
- },
3525
- type: "svelte-update"
3526
- });
3527
- };
3528
- var broadcastSveltePageUpdate = (state, sveltePagePath, manifest, duration) => {
3529
- try {
3530
- const fileName = basename4(sveltePagePath);
3531
- const baseName = fileName.replace(/\.svelte$/, "");
3532
- const pascalName = toPascal(baseName);
3533
- const cssKey = `${pascalName}CSS`;
3534
- const cssUrl = manifest[cssKey] || null;
3535
- logHmrUpdate(sveltePagePath, "svelte", duration);
3536
- broadcastToClients(state, {
3537
- data: {
3538
- cssBaseName: baseName,
3539
- cssUrl,
3540
- framework: "svelte",
3541
- html: null,
3542
- manifest,
3543
- sourceFile: sveltePagePath,
3544
- updateType: "full"
3545
- },
3546
- type: "svelte-update"
3547
- });
3548
- } catch (err) {
3549
- sendTelemetryEvent("hmr:error", {
3550
- framework: "svelte",
3551
- message: err instanceof Error ? err.message : String(err)
3552
- });
3553
- }
3554
- };
3555
- var handleSvelteHMR = (state, config, filesToRebuild, manifest, duration) => {
3556
- if (!config.svelteDirectory) {
3557
- return;
3558
- }
3559
- const svelteFiles = filesToRebuild.filter((file) => detectFramework(file, state.resolvedPaths) === "svelte");
3560
- if (svelteFiles.length === 0) {
3561
- return;
3562
- }
3563
- const svelteComponentFiles = svelteFiles.filter((file) => file.endsWith(".svelte"));
3564
- const svelteCssFiles = svelteFiles.filter(isStylePath);
3565
- const isCssOnlyChange = svelteComponentFiles.length === 0 && svelteCssFiles.length > 0;
3566
- const sveltePageFiles = svelteFiles.filter((file) => file.replace(/\\/g, "/").includes("/pages/"));
3567
- const pagesToUpdate = sveltePageFiles.length > 0 ? sveltePageFiles : svelteComponentFiles;
3568
- if (isCssOnlyChange && svelteCssFiles.length > 0) {
3569
- handleSvelteCssOnlyUpdate(state, svelteCssFiles, manifest, duration);
3570
- }
3571
- pagesToUpdate.forEach((sveltePagePath) => {
3572
- broadcastSveltePageUpdate(state, sveltePagePath, manifest, duration);
3573
- });
3574
- };
3575
- var collectAngularAffectedPages = (affected, resolvedPages) => {
3576
- affected.forEach((file) => {
3577
- if (file.replace(/\\/g, "/").includes("/pages/") && file.endsWith(".ts")) {
3578
- resolvedPages.add(file);
3579
- }
3580
- });
3581
- };
3582
- var resolveAngularPagesFromDependencyGraph = (state, angularFiles) => {
3583
- const resolvedPages = new Set;
3584
- angularFiles.forEach((componentFile) => {
3585
- const lookupFile = resolveComponentLookupFile(componentFile, state.dependencyGraph);
3586
- const affected = getAffectedFiles(state.dependencyGraph, lookupFile);
3587
- collectAngularAffectedPages(affected, resolvedPages);
3588
- });
3589
- return Array.from(resolvedPages);
3590
- };
3591
- var handleAngularCssOnlyUpdate = (state, angularCssFiles, manifest, duration) => {
3592
- const [cssFile] = angularCssFiles;
3593
- if (!cssFile) {
3594
- return;
3595
- }
3596
- const cssBaseName = basename4(getStyleBaseName(cssFile));
3597
- const cssPascalName = toPascal(cssBaseName);
3598
- const cssKey = `${cssPascalName}CSS`;
3599
- const cssUrl = manifest[cssKey] || null;
3600
- logCssUpdate(cssFile, "angular", duration);
3601
- broadcastToClients(state, {
3602
- data: {
3603
- cssBaseName,
3604
- cssUrl,
3605
- framework: "angular",
3606
- manifest,
3607
- sourceFile: cssFile,
3608
- updateType: "style"
3609
- },
3610
- type: "angular-update"
3611
- });
3612
- };
3613
- var broadcastAngularPageHmrUpdate = (state, angularPagePath, manifest, duration) => {
3614
- try {
3615
- const fileName = basename4(angularPagePath);
3616
- const baseName = fileName.replace(/\.[tj]s$/, "");
3617
- const pascalName = toPascal(baseName);
3618
- const cssKey = `${pascalName}CSS`;
3619
- const cssUrl = manifest[cssKey] || null;
3620
- logHmrUpdate(angularPagePath, "angular", duration);
3621
- broadcastToClients(state, {
3622
- data: {
3623
- cssBaseName: baseName,
3624
- cssUrl,
3625
- framework: "angular",
3626
- manifest,
3627
- sourceFile: angularPagePath,
3628
- updateType: "logic"
3629
- },
3630
- type: "angular-update"
3631
- });
3632
- } catch (err) {
3633
- sendTelemetryEvent("hmr:error", {
3634
- framework: "angular",
3635
- message: err instanceof Error ? err.message : String(err)
3636
- });
3637
- }
3638
- };
3639
- var handleAngularHMR = (state, config, filesToRebuild, manifest, duration) => {
3640
- if (!config.angularDirectory) {
3641
- return;
3642
- }
3643
- const angularFiles = filesToRebuild.filter((file) => detectFramework(file, state.resolvedPaths) === "angular");
3644
- if (angularFiles.length === 0) {
3645
- return;
3646
- }
3647
- const angularCssFiles = angularFiles.filter(isStylePath);
3648
- const isCssOnlyChange = angularFiles.every(isStylePath) && angularCssFiles.length > 0;
3649
- const angularPageFiles = angularFiles.filter((file) => file.replace(/\\/g, "/").includes("/pages/"));
3650
- let pagesToUpdate = angularPageFiles;
3651
- if (pagesToUpdate.length === 0 && state.dependencyGraph) {
3652
- pagesToUpdate = resolveAngularPagesFromDependencyGraph(state, angularFiles);
3653
- }
3654
- if (isCssOnlyChange && angularCssFiles.length > 0) {
3655
- handleAngularCssOnlyUpdate(state, angularCssFiles, manifest, duration);
3656
- return;
3657
- }
3658
- pagesToUpdate.forEach((angularPagePath) => {
3659
- broadcastAngularPageHmrUpdate(state, angularPagePath, manifest, duration);
3660
- });
3661
- };
3662
- var handleHTMXScriptHMR = (state, filesToRebuild, manifest, duration) => {
3663
- if (!state.resolvedPaths.htmxDir) {
3664
- return;
3665
- }
3666
- const htmxFrameworkFiles = filesToRebuild.filter((file) => detectFramework(file, state.resolvedPaths) === "htmx");
3667
- if (htmxFrameworkFiles.length === 0) {
3668
- return;
3669
- }
3670
- const htmxScriptFiles = htmxFrameworkFiles.filter(isScriptFile);
3671
- const htmxHtmlFiles = htmxFrameworkFiles.filter((file) => file.endsWith(".html"));
3672
- if (htmxScriptFiles.length === 0 || htmxHtmlFiles.length > 0) {
3673
- return;
3674
- }
3675
- htmxScriptFiles.forEach((scriptFile) => {
3676
- handleScriptUpdate(state, scriptFile, manifest, "htmx", duration);
3677
- });
3678
- };
3679
- var processHtmxPageUpdate = async (state, htmxPageFile, builtHtmxPagePath, manifest, duration) => {
3680
- try {
3681
- const { handleHTMXUpdate } = await import("./chunk-tfe3sb44.js");
3682
- const newHTML = await handleHTMXUpdate(builtHtmxPagePath);
3683
- if (!newHTML) {
3684
- return;
3685
- }
3686
- logHmrUpdate(htmxPageFile, "htmx", duration);
3687
- broadcastToClients(state, {
3688
- data: {
3689
- framework: "htmx",
3690
- html: newHTML,
3691
- manifest,
3692
- sourceFile: builtHtmxPagePath
3693
- },
3694
- type: "htmx-update"
3695
- });
3696
- } catch (err) {
3697
- sendTelemetryEvent("hmr:error", {
3698
- framework: "htmx",
3699
- message: err instanceof Error ? err.message : String(err)
3700
- });
3701
- }
3702
- };
3703
- var handleHTMXPageHMR = async (state, config, filesToRebuild, manifest, duration) => {
3704
- if (!state.resolvedPaths.htmxDir) {
3705
- return;
3706
- }
3707
- const shouldRefreshFromIslandChange = await didStaticPagesNeedIslandRefresh(config, filesToRebuild);
3708
- const htmxFrameworkFiles = filesToRebuild.filter((file) => detectFramework(file, state.resolvedPaths) === "htmx");
3709
- if (htmxFrameworkFiles.length === 0 && !shouldRefreshFromIslandChange) {
3710
- return;
3711
- }
3712
- const htmxPageFiles = htmxFrameworkFiles.filter((file) => file.endsWith(".html"));
3713
- const outputHtmxPages = computeOutputPagesDir(state, config, "htmx");
3714
- const shouldRefreshAllPages = htmxPageFiles.length === 0 && shouldRefreshFromIslandChange;
3715
- const pageFilesToUpdate = shouldRefreshAllPages ? await scanEntryPoints(outputHtmxPages, "*.html") : htmxPageFiles;
3716
- await runSequentially(pageFilesToUpdate, async (htmxPageFile) => {
3717
- const htmxPageName = basename4(htmxPageFile);
3718
- const builtHtmxPagePath = resolve9(outputHtmxPages, htmxPageName);
3719
- await processHtmxPageUpdate(state, htmxPageFile, builtHtmxPagePath, manifest, duration);
3720
- });
3721
- };
3722
- var collectUpdatedModulePaths = (allModuleUpdates) => {
3723
- const paths = [];
3724
- allModuleUpdates.forEach((update) => {
3725
- paths.push(update.sourceFile);
3726
- Object.values(update.modulePaths).forEach((modulePath) => {
3727
- paths.push(modulePath);
3728
- });
3729
- });
3730
- return paths;
3731
- };
3732
- var buildModuleVersionsForUpdate = (update, moduleVersionsStore, moduleVersions) => {
3733
- const sourceVersion = moduleVersionsStore.get(update.sourceFile);
3734
- if (sourceVersion !== undefined) {
3735
- moduleVersions[update.sourceFile] = sourceVersion;
3736
- }
3737
- Object.values(update.modulePaths).forEach((path) => {
3738
- const pathVersion = moduleVersionsStore.get(path);
3739
- if (pathVersion !== undefined) {
3740
- moduleVersions[path] = pathVersion;
3741
- }
3742
- });
3743
- };
3744
- var handleModuleUpdates = (state, allModuleUpdates, manifest) => {
3745
- const updatedModulePaths = collectUpdatedModulePaths(allModuleUpdates);
3746
- if (updatedModulePaths.length > 0) {
3747
- incrementModuleVersions(state.moduleVersions, updatedModulePaths);
3748
- }
3749
- if (allModuleUpdates.length === 0) {
3750
- return;
3751
- }
3752
- const updatesByFramework = groupModuleUpdatesByFramework(allModuleUpdates);
3753
- const serverVersions = serializeModuleVersions(state.moduleVersions);
3754
- for (const [framework, updates] of updatesByFramework) {
3755
- const moduleVersions = {};
3756
- updates.forEach((update) => {
3757
- buildModuleVersionsForUpdate(update, state.moduleVersions, moduleVersions);
3758
- });
3759
- broadcastToClients(state, {
3760
- data: {
3761
- framework,
3762
- manifest,
3763
- modules: updates.map((update) => ({
3764
- componentType: update.componentType,
3765
- moduleKeys: update.moduleKeys,
3766
- modulePaths: update.modulePaths,
3767
- sourceFile: update.sourceFile,
3768
- version: state.moduleVersions.get(update.sourceFile)
3769
- })),
3770
- moduleVersions,
3771
- serverVersions
3772
- },
3773
- message: `${framework} modules updated`,
3774
- type: "module-update"
3775
- });
3776
- }
3777
- };
3778
- var handleFullBuildHMR = async (state, config, affectedFrameworks, filesToRebuild, manifest, duration) => {
3779
- const allModuleUpdates = collectAllModuleUpdates(affectedFrameworks, filesToRebuild, manifest, state);
3780
- handleReactHMR(state, affectedFrameworks, filesToRebuild, manifest, duration);
3781
- handleHTMLScriptHMR(state, filesToRebuild, manifest, duration);
3782
- await handleHTMLPageHMR(state, config, filesToRebuild, manifest, duration);
3783
- await handleVueHMR(state, config, filesToRebuild, manifest, duration);
3784
- handleSvelteHMR(state, config, filesToRebuild, manifest, duration);
3785
- handleAngularHMR(state, config, filesToRebuild, manifest, duration);
3786
- handleHTMXScriptHMR(state, filesToRebuild, manifest, duration);
3787
- await handleHTMXPageHMR(state, config, filesToRebuild, manifest, duration);
3788
- handleModuleUpdates(state, allModuleUpdates, manifest);
3789
- };
3790
- var logStyleUpdatesForFramework = (state, framework, filesToRebuild, startTime) => {
3791
- const dur = Date.now() - startTime;
3792
- filesToRebuild.forEach((file) => {
3793
- if (detectFramework(file, state.resolvedPaths) === framework) {
3794
- logCssUpdate(file, framework, dur);
3795
- }
3796
- });
3797
- };
3798
- var broadcastSingleFrameworkUpdate = (state, framework, filesToRebuild, manifest, startTime) => {
3799
- const type = framework === "styles" || framework === "assets" ? "style-update" : "framework-update";
3800
- if (type === "style-update" && filesToRebuild) {
3801
- logStyleUpdatesForFramework(state, framework, filesToRebuild, startTime);
3802
- }
3803
- broadcastToClients(state, {
3804
- data: {
3805
- framework,
3806
- manifest
3807
- },
3808
- message: `${framework} framework updated`,
3809
- type
3810
- });
3811
- };
3812
- var broadcastFrameworkUpdates = (state, affectedFrameworks, filesToRebuild, manifest, startTime) => {
3813
- affectedFrameworks.forEach((framework) => {
3814
- broadcastSingleFrameworkUpdate(state, framework, filesToRebuild, manifest, startTime);
3815
- });
3816
- };
3817
- var HMR_SCRIPT_PATTERN = /<script>window\.__HMR_FRAMEWORK__[\s\S]*?<\/script>\s*<script data-hmr-client>[\s\S]*?<\/script>/;
3818
- var extractHmrScript = (destPath, readFs) => {
3819
- try {
3820
- const existing = readFs(destPath, "utf-8");
3821
- const [matched] = existing.match(HMR_SCRIPT_PATTERN) ?? [];
3822
- return matched ?? "";
3823
- } catch {
3824
- return "";
3825
- }
3826
- };
3827
- var injectHmrScript = (destPath, hmrScript, readFs, writeFs) => {
3828
- if (!hmrScript)
3829
- return;
3830
- let html = readFs(destPath, "utf-8");
3831
- const bodyClose = /<\/body\s*>/i.exec(html);
3832
- if (!bodyClose)
3833
- return;
3834
- html = html.slice(0, bodyClose.index) + hmrScript + html.slice(bodyClose.index);
3835
- writeFs(destPath, html);
3836
- };
3837
- var processMarkupFileFastPath = async (state, sourceFile, outputDir, framework, startTime, updateAssetPaths2, handleUpdate, readFs, writeFs) => {
3838
- const destPath = resolve9(outputDir, basename4(sourceFile));
3839
- const hmrScript = extractHmrScript(destPath, readFs);
3840
- const source = await Bun.file(sourceFile).text();
3841
- await Bun.write(destPath, source);
3842
- await updateAssetPaths2(state.manifest, outputDir);
3843
- const { optimizeHtmlImages: optimizeHtmlImages2 } = await import("./chunk-ywjn0rad.js");
3844
- await optimizeHtmlImages2(outputDir);
3845
- injectHmrScript(destPath, hmrScript, readFs, writeFs);
3846
- const newHTML = await handleUpdate(destPath);
3847
- if (!newHTML)
3848
- return;
3849
- const dur = Date.now() - startTime;
3850
- logHmrUpdate(sourceFile, framework, dur);
3851
- broadcastToClients(state, {
3852
- data: {
3853
- framework,
3854
- html: newHTML,
3855
- manifest: state.manifest,
3856
- sourceFile
3857
- },
3858
- type: `${framework}-update`
3859
- });
3860
- };
3861
- var tryProcessMarkupFile = async (state, sourceFile, outputDir, framework, startTime, updateAssetPaths2, handleUpdate, readFs, writeFs) => {
3862
- try {
3863
- await processMarkupFileFastPath(state, sourceFile, outputDir, framework, startTime, updateAssetPaths2, handleUpdate, readFs, writeFs);
3864
- return true;
3865
- } catch {
3866
- return false;
3867
- }
3868
- };
3869
- var runMarkupFastPath = async (state, config, filesToRebuild, startTime, framework) => {
3870
- const markupFiles = (filesToRebuild ?? []).filter((file) => file.endsWith(".html"));
3871
- if (markupFiles.length === 0)
3872
- return;
3873
- const outputDir = computeOutputPagesDir(state, config, framework);
3874
- const { updateAssetPaths: updateAssetPaths2 } = await import("./chunk-jwxt8gnp.js");
3875
- const handleUpdate = framework === "html" ? (await import("./chunk-30yrw0f6.js")).handleHTMLUpdate : (await import("./chunk-tfe3sb44.js")).handleHTMXUpdate;
3876
- const { readFileSync: readFs, writeFileSync: writeFs } = await import("fs");
3877
- const processMarkupFiles = async (files) => {
3878
- const [markupFile, ...remaining] = files;
3879
- if (!markupFile) {
3880
- return;
3881
- }
3882
- const success = await tryProcessMarkupFile(state, markupFile, outputDir, framework, startTime, updateAssetPaths2, handleUpdate, readFs, writeFs);
3883
- if (!success) {
3884
- return;
3885
- }
3886
- await processMarkupFiles(remaining);
3887
- };
3888
- await processMarkupFiles(markupFiles);
3889
- };
3890
- var runHtmlFastPath = async (state, config, filesToRebuild, startTime) => runMarkupFastPath(state, config, filesToRebuild, startTime, "html");
3891
- var runHtmxFastPath = async (state, config, filesToRebuild, startTime) => runMarkupFastPath(state, config, filesToRebuild, startTime, "htmx");
3892
- var markHandledFiles = (files, framework, resolvedPaths, handled) => {
3893
- files.filter((f) => detectFramework(f, resolvedPaths) === framework).forEach((f) => handled.add(f));
3894
- };
3895
- var runFrameworkFastPaths = async (state, config, affectedFrameworks, files, startTime, onRebuildComplete) => {
3896
- const handled = new Set;
3897
- const fastPaths = [
3898
- {
3899
- directory: config.angularDirectory,
3900
- framework: "angular",
3901
- handler: handleAngularFastPath
3902
- },
3903
- {
3904
- directory: config.reactDirectory,
3905
- framework: "react",
3906
- handler: handleReactFastPath
3907
- },
3908
- {
3909
- directory: config.svelteDirectory,
3910
- framework: "svelte",
3911
- handler: handleSvelteFastPath
3912
- },
3913
- {
3914
- directory: config.vueDirectory,
3915
- framework: "vue",
3916
- handler: handleVueFastPath
3917
- }
3918
- ];
3919
- await runSequentially(fastPaths, async (fastPath) => {
3920
- if (!fastPath.directory || !affectedFrameworks.includes(fastPath.framework))
3921
- return;
3922
- await fastPath.handler(state, config, files, startTime, onRebuildComplete);
3923
- markHandledFiles(files, fastPath.framework, state.resolvedPaths, handled);
3924
- });
3925
- return files.every((f) => handled.has(f));
3926
- };
3927
- var performFullRebuild = async (state, config, affectedFrameworks, filesToRebuild, startTime, onRebuildComplete) => {
3928
- const hasManifest = Object.keys(state.manifest).length > 0;
3929
- const files = filesToRebuild ?? [];
3930
- let allHandled = files.length > 0 && hasManifest;
3931
- const hasIslandSourceChanges = files.length > 0 ? await didStaticPagesNeedIslandRefresh(config, files) : false;
3932
- if (allHandled && !hasIslandSourceChanges) {
3933
- allHandled = await runFrameworkFastPaths(state, config, affectedFrameworks, files, startTime, onRebuildComplete);
3934
- }
3935
- if (allHandled && config.htmlDirectory && affectedFrameworks.includes("html")) {
3936
- await runHtmlFastPath(state, config, filesToRebuild, startTime);
3937
- }
3938
- if (allHandled && config.htmxDirectory && affectedFrameworks.includes("htmx")) {
3939
- await runHtmxFastPath(state, config, filesToRebuild, startTime);
3940
- }
3941
- if (allHandled) {
3942
- await recompileTailwindForFastPath(state, config, files);
3943
- onRebuildComplete({
3944
- hmrState: state,
3945
- manifest: state.manifest
3946
- });
3947
- return state.manifest;
3948
- }
3949
- const buildConfig = {
3950
- ...config,
3951
- incrementalFiles: filesToRebuild && filesToRebuild.length > 0 ? filesToRebuild : undefined,
3952
- options: {
3953
- ...config.options,
3954
- baseManifest: state.manifest,
3955
- injectHMR: true,
3956
- throwOnError: true
3957
- }
3958
- };
3959
- const buildResult = await build(buildConfig);
3960
- if (!buildResult?.manifest) {
3961
- throw new Error("Build failed - no manifest generated");
3962
- }
3963
- const { manifest } = buildResult;
3964
- const duration = Date.now() - startTime;
3965
- sendTelemetryEvent("hmr:rebuild-complete", {
3966
- durationMs: duration,
3967
- fileCount: filesToRebuild?.length ?? 0,
3968
- framework: affectedFrameworks[0] ?? "unknown"
3969
- });
3970
- await populateAssetStore(state.assetStore, manifest, state.resolvedPaths.buildDir);
3971
- cleanStaleAssets(state.assetStore, manifest, state.resolvedPaths.buildDir);
3972
- broadcastToClients(state, {
3973
- data: {
3974
- affectedFrameworks,
3975
- manifest
3976
- },
3977
- message: "Rebuild completed successfully",
3978
- type: "rebuild-complete"
3979
- });
3980
- if (config.tailwind && filesToRebuild && filesToRebuild.some(isTailwindCandidate)) {
3981
- broadcastToClients(state, {
3982
- data: { framework: "tailwind", manifest },
3983
- message: "Tailwind utilities recompiled",
3984
- type: "style-update"
3985
- });
3986
- }
3987
- const hasFilesToRebuild = filesToRebuild && filesToRebuild.length > 0;
3988
- const didReloadForIslandChange = hasFilesToRebuild ? await handleIslandSourceReload(state, config, filesToRebuild, manifest) : false;
3989
- if (didReloadForIslandChange) {
3990
- onRebuildComplete({ hmrState: state, manifest });
3991
- return manifest;
3992
- }
3993
- if (hasFilesToRebuild) {
3994
- await handleFullBuildHMR(state, config, affectedFrameworks, filesToRebuild, manifest, duration);
3995
- }
3996
- broadcastFrameworkUpdates(state, affectedFrameworks, filesToRebuild, manifest, startTime);
3997
- if (affectedFrameworks.includes("angular")) {
3998
- markSsrCacheDirty("angular");
3999
- }
4000
- if (affectedFrameworks.includes("react")) {
4001
- markSsrCacheDirty("react");
4002
- }
4003
- if (affectedFrameworks.includes("svelte")) {
4004
- markSsrCacheDirty("svelte");
4005
- }
4006
- if (affectedFrameworks.includes("vue")) {
4007
- markSsrCacheDirty("vue");
4008
- }
4009
- onRebuildComplete({ hmrState: state, manifest });
4010
- return manifest;
4011
- };
4012
- var drainPendingQueue = (state, config, onRebuildComplete) => {
4013
- if (state.fileChangeQueue.size === 0) {
4014
- return;
4015
- }
4016
- const pending = Array.from(state.fileChangeQueue.keys());
4017
- const queuedFiles = [];
4018
- state.fileChangeQueue.forEach((filePaths) => {
4019
- queuedFiles.push(...filePaths);
4020
- });
4021
- state.fileChangeQueue.clear();
4022
- pending.forEach((file) => state.rebuildQueue.add(file));
4023
- if (state.rebuildTimeout)
4024
- clearTimeout(state.rebuildTimeout);
4025
- state.rebuildTimeout = setTimeout(() => {
4026
- triggerRebuild(state, config, onRebuildComplete, queuedFiles.length > 0 ? queuedFiles : undefined);
4027
- }, REBUILD_BATCH_DELAY_MS);
4028
- };
4029
- var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) => {
4030
- if (state.isRebuilding) {
4031
- return null;
4032
- }
4033
- state.isRebuilding = true;
4034
- const affectedFrameworks = Array.from(state.rebuildQueue);
4035
- state.rebuildQueue.clear();
4036
- const startTime = Date.now();
4037
- broadcastToClients(state, {
4038
- data: { affectedFrameworks },
4039
- message: "Rebuild started...",
4040
- type: "rebuild-start"
4041
- });
4042
- try {
4043
- return await performFullRebuild(state, config, affectedFrameworks, filesToRebuild, startTime, onRebuildComplete);
4044
- } catch (error) {
4045
- sendTelemetryEvent("hmr:rebuild-error", {
4046
- durationMs: Date.now() - startTime,
4047
- fileCount: filesToRebuild?.length ?? 0,
4048
- framework: affectedFrameworks[0] ?? "unknown",
4049
- frameworks: affectedFrameworks,
4050
- message: error instanceof Error ? error.message : String(error)
4051
- });
4052
- const errorData = extractBuildErrorDetails(error, affectedFrameworks, state.resolvedPaths);
4053
- broadcastToClients(state, {
4054
- data: {
4055
- affectedFrameworks,
4056
- error: error instanceof Error ? error.message : String(error),
4057
- ...errorData
4058
- },
4059
- message: "Rebuild failed",
4060
- type: "rebuild-error"
4061
- });
4062
- return null;
4063
- } finally {
4064
- state.isRebuilding = false;
4065
- drainPendingQueue(state, config, onRebuildComplete);
4066
- }
4067
- };
4068
-
4069
- // src/core/devBuild.ts
4070
- var FRAMEWORK_DIR_KEYS = [
4071
- "reactDirectory",
4072
- "svelteDirectory",
4073
- "vueDirectory",
4074
- "htmlDirectory",
4075
- "htmxDirectory",
4076
- "angularDirectory"
4077
- ];
4078
- var collectDepVendorSourceDirs = (config) => {
4079
- const configuredDirs = [
4080
- config.reactDirectory,
4081
- config.svelteDirectory,
4082
- config.vueDirectory,
4083
- config.angularDirectory,
4084
- config.htmlDirectory,
4085
- config.htmxDirectory
4086
- ].filter((dir) => Boolean(dir));
4087
- return Array.from(new Set(configuredDirs));
4088
- };
4089
- var parseDirectoryConfig = (source) => {
4090
- const config = {};
4091
- const dirPattern = /(\w+Directory)\s*:\s*['"]([^'"]+)['"]/g;
4092
- let match;
4093
- while ((match = dirPattern.exec(source)) !== null) {
4094
- const [, key, value] = match;
4095
- if (key && value)
4096
- Object.assign(config, { [key]: value });
4097
- }
4098
- return Object.keys(config).length > 0 ? config : null;
4099
- };
4100
- var reloadConfig = async () => {
4101
- try {
4102
- const configPath = resolve10(process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts");
4103
- const source = await Bun.file(configPath).text();
4104
- return parseDirectoryConfig(source);
4105
- } catch {
4106
- return null;
4107
- }
4108
- };
4109
- var detectConfigChanges = async (cached) => {
4110
- const newConfig = await reloadConfig();
4111
- if (!newConfig)
4112
- return;
4113
- const state = cached.hmrState;
4114
- const oldConfig = state.config;
4115
- const hasChanges = FRAMEWORK_DIR_KEYS.some((key) => newConfig[key] !== oldConfig[key]);
4116
- if (!hasChanges)
4117
- return;
4118
- const oldWatchPaths = new Set(getWatchPaths(oldConfig, state.resolvedPaths));
4119
- for (const key of FRAMEWORK_DIR_KEYS) {
4120
- state.config[key] = newConfig[key];
4121
- }
4122
- state.resolvedPaths = resolveBuildPaths(state.config);
4123
- if (!oldConfig.reactDirectory && Boolean(newConfig.reactDirectory)) {
4124
- setDevVendorPaths(computeVendorPaths());
4125
- }
4126
- if (!oldConfig.angularDirectory && Boolean(newConfig.angularDirectory)) {
4127
- setAngularVendorPaths(computeAngularVendorPaths());
4128
- }
4129
- if (!oldConfig.svelteDirectory && Boolean(newConfig.svelteDirectory)) {
4130
- setSvelteVendorPaths(computeSvelteVendorPaths());
4131
- }
4132
- if (!oldConfig.vueDirectory && Boolean(newConfig.vueDirectory)) {
4133
- setVueVendorPaths(computeVueVendorPaths());
4134
- }
4135
- const newWatchPaths = getWatchPaths(state.config, state.resolvedPaths);
4136
- const addedPaths = newWatchPaths.filter((path) => !oldWatchPaths.has(path));
4137
- if (addedPaths.length > 0) {
4138
- buildInitialDependencyGraph(state.dependencyGraph, addedPaths);
4139
- addFileWatchers(state, addedPaths, (filePath) => {
4140
- queueFileChange(state, filePath, state.config, (newBuildResult) => {
4141
- Object.assign(cached.manifest, newBuildResult.manifest);
4142
- state.manifest = cached.manifest;
4143
- });
4144
- });
4145
- }
4146
- };
4147
- var removeStaleKeys = (target, source) => {
4148
- for (const key of Object.keys(target)) {
4149
- if (!(key in source))
4150
- delete target[key];
4151
- }
4152
- };
4153
- var REBUILD_POLL_MS = 10;
4154
- var waitForRebuild = async (state) => {
4155
- if (!state.isRebuilding) {
4156
- return;
4157
- }
4158
- await Bun.sleep(REBUILD_POLL_MS);
4159
- await waitForRebuild(state);
4160
- };
4161
- var rebuildManifest = async (cached) => {
4162
- const state = cached.hmrState;
4163
- await waitForRebuild(state);
4164
- state.isRebuilding = true;
4165
- try {
4166
- const buildResult = await build({
4167
- ...state.config,
4168
- mode: "development",
4169
- options: {
4170
- ...state.config.options,
4171
- injectHMR: true,
4172
- throwOnError: true
4173
- }
4174
- });
4175
- if (!buildResult?.manifest)
4176
- return;
4177
- const newManifest = buildResult.manifest;
4178
- removeStaleKeys(cached.manifest, newManifest);
4179
- Object.assign(cached.manifest, newManifest);
4180
- state.manifest = cached.manifest;
4181
- await populateAssetStore(state.assetStore, cached.manifest, state.resolvedPaths.buildDir);
4182
- await cleanStaleAssets(state.assetStore, cached.manifest, state.resolvedPaths.buildDir);
4183
- } catch {} finally {
4184
- state.rebuildCount++;
4185
- state.isRebuilding = false;
4186
- state.fileChangeQueue.clear();
4187
- }
4188
- };
4189
- var handleCachedReload = async () => {
4190
- const serverMtime = statSync2(resolve10(Bun.main)).mtimeMs;
4191
- const lastMtime = globalThis.__hmrServerMtime;
4192
- globalThis.__hmrServerMtime = serverMtime;
4193
- const cached = globalThis.__hmrDevResult;
4194
- if (cached?.hmrState.config.reactDirectory) {
4195
- setDevVendorPaths(computeVendorPaths());
4196
- }
4197
- if (cached?.hmrState.config.angularDirectory) {
4198
- setAngularVendorPaths(computeAngularVendorPaths(globalThis.__angularVendorSpecifiers));
4199
- }
4200
- if (cached?.hmrState.config.svelteDirectory) {
4201
- setSvelteVendorPaths(computeSvelteVendorPaths());
4202
- }
4203
- if (cached?.hmrState.config.vueDirectory) {
4204
- setVueVendorPaths(computeVueVendorPaths());
4205
- }
4206
- if (serverMtime === lastMtime) {
4207
- globalThis.__hmrSkipServerRestart = true;
4208
- return;
4209
- }
4210
- logServerReload();
4211
- if (!cached)
4212
- return;
4213
- await detectConfigChanges(cached);
4214
- await rebuildManifest(cached);
4215
- };
4216
- var tryReadPackageVersion = async (path) => {
4217
- const pkg = await Bun.file(path).json().catch(() => null);
4218
- if (!pkg || pkg.name !== "@absolutejs/absolute") {
4219
- return false;
4220
- }
4221
- globalThis.__absoluteVersion = pkg.version;
4222
- return true;
4223
- };
4224
- var resolveAbsoluteVersion2 = async () => {
4225
- const candidates = [
4226
- resolve10(import.meta.dir, "..", "..", "package.json"),
4227
- resolve10(import.meta.dir, "..", "package.json")
4228
- ];
4229
- const [candidate, ...remaining] = candidates;
4230
- if (!candidate) {
4231
- return;
4232
- }
4233
- const found = await tryReadPackageVersion(candidate);
4234
- if (found) {
4235
- return;
4236
- }
4237
- await resolveAbsoluteVersionFromCandidates(remaining);
4238
- };
4239
- var resolveAbsoluteVersionFromCandidates = async (candidates) => {
4240
- const [candidate, ...remaining] = candidates;
4241
- if (!candidate) {
4242
- return;
4243
- }
4244
- const found = await tryReadPackageVersion(candidate);
4245
- if (found) {
4246
- return;
4247
- }
4248
- await resolveAbsoluteVersionFromCandidates(remaining);
4249
- };
4250
- var loadVendorFiles = async (assetStore, vendorDir, framework) => {
4251
- const emptyStringArray = [];
4252
- const entries = await readdir(vendorDir).catch(() => emptyStringArray);
4253
- await Promise.all(entries.filter((entry) => entry.endsWith(".js")).map(async (entry) => {
4254
- const webPath = `/${framework}/vendor/${entry}`;
4255
- const bytes = await Bun.file(resolve10(vendorDir, entry)).bytes();
4256
- assetStore.set(webPath, bytes);
4257
- }));
4258
- };
4259
- var devBuild = async (config) => {
4260
- const cached = globalThis.__hmrDevResult;
4261
- if (cached) {
4262
- await handleCachedReload();
4263
- return cached;
4264
- }
4265
- const startupSteps = [];
4266
- const recordStep = (label, startedAt) => {
4267
- const durationMs = performance.now() - startedAt;
4268
- startupSteps.push({
4269
- durationMs,
4270
- label
4271
- });
4272
- };
4273
- let stepStartedAt = performance.now();
4274
- const state = createHMRState(config);
4275
- process.env.ABSOLUTE_BUILD_DIR ??= state.resolvedPaths.buildDir;
4276
- recordStep("create HMR state", stepStartedAt);
4277
- stepStartedAt = performance.now();
4278
- const watchPaths = getWatchPaths(config, state.resolvedPaths);
4279
- buildInitialDependencyGraph(state.dependencyGraph, watchPaths);
4280
- recordStep("initialize dependency graph", stepStartedAt);
4281
- stepStartedAt = performance.now();
4282
- if (config.reactDirectory) {
4283
- setDevVendorPaths(computeVendorPaths());
4284
- }
4285
- if (config.svelteDirectory) {
4286
- setSvelteVendorPaths(computeSvelteVendorPaths());
4287
- }
4288
- if (config.vueDirectory) {
4289
- setVueVendorPaths(computeVueVendorPaths());
4290
- }
4291
- const sourceDirs = collectDepVendorSourceDirs(config);
4292
- if (config.angularDirectory) {
4293
- setAngularVendorPaths(await computeAngularVendorPathsAsync(sourceDirs));
4294
- setAngularServerVendorPaths(await computeAngularServerVendorPathsAsync(state.resolvedPaths.buildDir, sourceDirs));
4295
- }
4296
- const { computeDepVendorPaths } = await import("./chunk-gytkmthr.js");
4297
- globalThis.__depVendorPaths = await computeDepVendorPaths(sourceDirs);
4298
- recordStep("prepare vendor paths", stepStartedAt);
4299
- stepStartedAt = performance.now();
4300
- await resolveAbsoluteVersion2();
4301
- recordStep("resolve version", stepStartedAt);
4302
- const buildStart = performance.now();
4303
- const buildResult = await build({
4304
- ...config,
4305
- mode: "development",
4306
- options: {
4307
- ...config.options,
4308
- injectHMR: true
4309
- }
4310
- });
4311
- const manifest = buildResult.manifest ?? {};
4312
- const conventions = buildResult.conventions ?? {};
4313
- recordStep("initial build", buildStart);
4314
- if (Object.keys(manifest).length === 0) {
4315
- console.log("\u26A0\uFE0F Manifest is empty - this is OK for HTML/HTMX-only projects");
4316
- }
4317
- stepStartedAt = performance.now();
4318
- await populateAssetStore(state.assetStore, manifest, state.resolvedPaths.buildDir);
4319
- cleanStaleAssets(state.assetStore, manifest, state.resolvedPaths.buildDir);
4320
- recordStep("populate asset store", stepStartedAt);
4321
- stepStartedAt = performance.now();
4322
- const reactVendorDir = resolve10(state.resolvedPaths.buildDir, "react", "vendor");
4323
- const angularVendorDir = resolve10(state.resolvedPaths.buildDir, "angular", "vendor");
4324
- const svelteVendorDir = resolve10(state.resolvedPaths.buildDir, "svelte", "vendor");
4325
- const vueVendorDir = resolve10(state.resolvedPaths.buildDir, "vue", "vendor");
4326
- const depVendorDir = resolve10(state.resolvedPaths.buildDir, "vendor");
4327
- const { buildDepVendor } = await import("./chunk-gytkmthr.js");
4328
- const [, angularSpecs, angularServerSpecs, , , depPaths] = await Promise.all([
4329
- config.reactDirectory ? buildReactVendor(state.resolvedPaths.buildDir) : Promise.resolve(undefined),
4330
- config.angularDirectory ? buildAngularVendor(state.resolvedPaths.buildDir, sourceDirs, true, Object.keys(globalThis.__depVendorPaths ?? {})) : Promise.resolve(undefined),
4331
- config.angularDirectory ? buildAngularServerVendor(state.resolvedPaths.buildDir, sourceDirs, true) : Promise.resolve(undefined),
4332
- config.svelteDirectory ? buildSvelteVendor(state.resolvedPaths.buildDir) : Promise.resolve(undefined),
4333
- config.vueDirectory ? buildVueVendor(state.resolvedPaths.buildDir) : Promise.resolve(undefined),
4334
- buildDepVendor(state.resolvedPaths.buildDir, sourceDirs)
4335
- ]);
4336
- if (angularSpecs)
4337
- globalThis.__angularVendorSpecifiers = angularSpecs;
4338
- if (angularServerSpecs) {
4339
- setAngularServerVendorPaths(computeAngularServerVendorPaths(state.resolvedPaths.buildDir, angularServerSpecs));
4340
- }
4341
- globalThis.__depVendorPaths = depPaths;
4342
- recordStep("build vendor bundles", stepStartedAt);
4343
- stepStartedAt = performance.now();
4344
- const combinedVendorPaths = {
4345
- ...getDevVendorPaths() ?? {},
4346
- ...getAngularVendorPaths() ?? {},
4347
- ...getSvelteVendorPaths() ?? {},
4348
- ...getVueVendorPaths() ?? {},
4349
- ...depPaths
4350
- };
4351
- const activeVendorDirs = [
4352
- config.reactDirectory ? reactVendorDir : null,
4353
- config.angularDirectory ? angularVendorDir : null,
4354
- config.svelteDirectory ? svelteVendorDir : null,
4355
- config.vueDirectory ? vueVendorDir : null,
4356
- depVendorDir
4357
- ].filter((d) => d !== null);
4358
- const { rewriteVendorDirectories } = await import("./chunk-r7jmgqnw.js");
4359
- await rewriteVendorDirectories(activeVendorDirs, combinedVendorPaths);
4360
- recordStep("rewrite vendor cross-references", stepStartedAt);
4361
- stepStartedAt = performance.now();
4362
- await Promise.all([
4363
- config.reactDirectory ? loadVendorFiles(state.assetStore, reactVendorDir, "react") : Promise.resolve(),
4364
- config.angularDirectory ? loadVendorFiles(state.assetStore, angularVendorDir, "angular") : Promise.resolve(),
4365
- config.svelteDirectory ? loadVendorFiles(state.assetStore, svelteVendorDir, "svelte") : Promise.resolve(),
4366
- config.vueDirectory ? loadVendorFiles(state.assetStore, vueVendorDir, "vue") : Promise.resolve(),
4367
- loadVendorFiles(state.assetStore, depVendorDir, "vendor")
4368
- ]);
4369
- if (config.reactDirectory && !globalThis.__reactModuleRef) {
4370
- globalThis.__reactModuleRef = await import("react");
4371
- }
4372
- recordStep("load vendor files", stepStartedAt);
4373
- stepStartedAt = performance.now();
4374
- const { warmCompilers } = await import("./chunk-zrg9d4zw.js");
4375
- await warmCompilers({
4376
- svelte: Boolean(config.svelteDirectory),
4377
- vue: Boolean(config.vueDirectory)
4378
- });
4379
- recordStep("warm compilers", stepStartedAt);
4380
- if (config.tailwind) {
4381
- stepStartedAt = performance.now();
4382
- const { warmTailwindCompiler } = await import("./chunk-txhm2vb5.js");
4383
- await warmTailwindCompiler(config.tailwind);
4384
- recordStep("warm tailwind compiler", stepStartedAt);
4385
- }
4386
- state.manifest = manifest;
4387
- stepStartedAt = performance.now();
4388
- startFileWatching(state, config, (filePath) => {
4389
- queueFileChange(state, filePath, config, (newBuildResult) => {
4390
- Object.assign(manifest, newBuildResult.manifest);
4391
- state.manifest = manifest;
4392
- });
4393
- });
4394
- recordStep("start file watching", stepStartedAt);
4395
- globalThis.__hmrBuildDuration = performance.now() - buildStart;
4396
- logStartupTimingBlock("AbsoluteJS devBuild timing", startupSteps);
4397
- const result = {
4398
- conventions,
4399
- hmrState: state,
4400
- manifest
4401
- };
4402
- globalThis.__hmrDevResult = result;
4403
- globalThis.__hmrServerMtime = statSync2(resolve10(Bun.main)).mtimeMs;
4404
- return result;
4405
- };
4406
-
4407
- export { build, devBuild };
4408
-
4409
- //# debugId=0199D56F7B01E0F664756E2164756E21
4410
- //# sourceMappingURL=chunk-38jwhqcw.js.map