vite-plugin-react-server 1.1.9 → 1.1.11

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 (415) hide show
  1. package/README.md +208 -27
  2. package/dist/index.js.map +1 -1
  3. package/dist/package.json +34 -14
  4. package/dist/plugin/{css-collector-elements.d.ts → components/css-collector-elements.d.ts} +1 -1
  5. package/dist/plugin/components/css-collector-elements.d.ts.map +1 -0
  6. package/dist/plugin/components/css-collector-elements.js.map +1 -0
  7. package/dist/plugin/{css-collector.d.ts → components/css-collector.d.ts} +1 -1
  8. package/dist/plugin/components/css-collector.d.ts.map +1 -0
  9. package/dist/plugin/components/css-collector.js.map +1 -0
  10. package/dist/plugin/components/html.d.ts +4 -0
  11. package/dist/plugin/components/html.d.ts.map +1 -0
  12. package/dist/plugin/components/html.js +17 -0
  13. package/dist/plugin/components/html.js.map +1 -0
  14. package/dist/plugin/components/index.d.ts +5 -0
  15. package/dist/plugin/components/index.d.ts.map +1 -0
  16. package/dist/plugin/components.js +9 -3
  17. package/dist/plugin/components.js.map +1 -0
  18. package/dist/plugin/config/autoDiscover/index.d.ts +6 -0
  19. package/dist/plugin/config/autoDiscover/index.d.ts.map +1 -0
  20. package/dist/plugin/config/autoDiscover/index.js +8 -0
  21. package/dist/plugin/config/{resolveAutoDiscover.d.ts → autoDiscover/resolveAutoDiscover.d.ts} +1 -1
  22. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts.map +1 -0
  23. package/dist/plugin/config/{resolveAutoDiscover.js → autoDiscover/resolveAutoDiscover.js} +10 -9
  24. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js.map +1 -0
  25. package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts.map +1 -1
  26. package/dist/plugin/config/autoDiscover/resolveBuildPages.js +10 -10
  27. package/dist/plugin/config/autoDiscover/resolveBuildPages.js.map +1 -1
  28. package/dist/plugin/config/defaults.d.ts +6 -4
  29. package/dist/plugin/config/defaults.d.ts.map +1 -1
  30. package/dist/plugin/config/defaults.js +8 -4
  31. package/dist/plugin/config/defaults.js.map +1 -1
  32. package/dist/plugin/config/index.d.ts +1 -0
  33. package/dist/plugin/config/index.d.ts.map +1 -1
  34. package/dist/plugin/config/index.js +1 -0
  35. package/dist/plugin/config/resolveDevServerConfig.d.ts +2 -0
  36. package/dist/plugin/config/resolveDevServerConfig.d.ts.map +1 -0
  37. package/dist/plugin/config/resolveEnv.d.ts +13 -0
  38. package/dist/plugin/config/resolveEnv.d.ts.map +1 -0
  39. package/dist/plugin/config/resolveEnv.js +120 -0
  40. package/dist/plugin/config/resolveEnv.js.map +1 -0
  41. package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
  42. package/dist/plugin/config/resolveOptions.js +34 -11
  43. package/dist/plugin/config/resolveOptions.js.map +1 -1
  44. package/dist/plugin/config/resolveUrlOption.d.ts +1 -1
  45. package/dist/plugin/config/resolveUrlOption.d.ts.map +1 -1
  46. package/dist/plugin/config/resolveUrlOption.js +1 -2
  47. package/dist/plugin/config/resolveUrlOption.js.map +1 -1
  48. package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
  49. package/dist/plugin/config/resolveUserConfig.js +80 -69
  50. package/dist/plugin/config/resolveUserConfig.js.map +1 -1
  51. package/dist/plugin/config.js +17 -0
  52. package/dist/plugin/config.js.map +1 -0
  53. package/dist/plugin/env/index.d.ts +2 -0
  54. package/dist/plugin/env/index.d.ts.map +1 -0
  55. package/dist/plugin/env/index.js +1 -0
  56. package/dist/plugin/env/plugin.d.ts +30 -0
  57. package/dist/plugin/env/plugin.d.ts.map +1 -0
  58. package/dist/plugin/env/plugin.js +64 -0
  59. package/dist/plugin/env.js +45 -0
  60. package/dist/plugin/env.js.map +1 -0
  61. package/dist/plugin/error/toError.d.ts +6 -0
  62. package/dist/plugin/error/toError.d.ts.map +1 -0
  63. package/dist/plugin/error/toError.js +19 -0
  64. package/dist/plugin/error/toError.js.map +1 -0
  65. package/dist/plugin/file-preserver/plugin.d.ts +19 -0
  66. package/dist/plugin/file-preserver/plugin.d.ts.map +1 -0
  67. package/dist/plugin/file-preserver/plugin.js +108 -0
  68. package/dist/plugin/file-preserver.js +96 -0
  69. package/dist/plugin/file-preserver.js.map +1 -0
  70. package/dist/plugin/helpers/collectManifestCss.js.map +1 -1
  71. package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
  72. package/dist/plugin/helpers/createCssProps.js +10 -2
  73. package/dist/plugin/helpers/createCssProps.js.map +1 -1
  74. package/dist/plugin/helpers/createEventHandler.d.ts +1 -1
  75. package/dist/plugin/helpers/createRscStream.js +1 -1
  76. package/dist/plugin/helpers/createRscStream.js.map +1 -1
  77. package/dist/plugin/helpers/formatMetrics.d.ts +3 -1
  78. package/dist/plugin/helpers/formatMetrics.d.ts.map +1 -1
  79. package/dist/plugin/helpers/formatMetrics.js +22 -7
  80. package/dist/plugin/helpers/formatMetrics.js.map +1 -0
  81. package/dist/plugin/helpers/getRouteFiles.d.ts +1 -1
  82. package/dist/plugin/helpers/getRouteFiles.d.ts.map +1 -1
  83. package/dist/plugin/helpers/getRouteFiles.js +2 -0
  84. package/dist/plugin/helpers/getRouteFiles.js.map +1 -1
  85. package/dist/plugin/helpers/index.d.ts +24 -0
  86. package/dist/plugin/helpers/index.d.ts.map +1 -0
  87. package/dist/plugin/helpers/index.js +31 -0
  88. package/dist/plugin/helpers/inputNormalizer.d.ts +2 -1
  89. package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
  90. package/dist/plugin/helpers/inputNormalizer.js +34 -9
  91. package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
  92. package/dist/plugin/helpers/metrics.js +26 -2
  93. package/dist/plugin/helpers/metrics.js.map +1 -1
  94. package/dist/plugin/helpers/moduleRefs.d.ts.map +1 -0
  95. package/dist/plugin/helpers/moduleRefs.js.map +1 -0
  96. package/dist/plugin/helpers/requestInfo.d.ts +26 -0
  97. package/dist/plugin/helpers/requestInfo.d.ts.map +1 -0
  98. package/dist/plugin/helpers/requestInfo.js +66 -0
  99. package/dist/plugin/helpers/requestInfo.js.map +1 -0
  100. package/dist/plugin/helpers/requestToRoute.js.map +1 -1
  101. package/dist/plugin/helpers/resolvePage.d.ts.map +1 -0
  102. package/dist/plugin/{resolvePage.js → helpers/resolvePage.js} +19 -3
  103. package/dist/plugin/helpers/resolvePage.js.map +1 -0
  104. package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -1
  105. package/dist/plugin/helpers/resolvePageAndProps.js +7 -4
  106. package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -1
  107. package/dist/plugin/helpers/resolveProps.d.ts.map +1 -0
  108. package/dist/plugin/{resolveProps.js → helpers/resolveProps.js} +9 -6
  109. package/dist/plugin/helpers/resolveProps.js.map +1 -0
  110. package/dist/plugin/helpers/serializeUserOptions.js +1 -1
  111. package/dist/plugin/helpers/serializeUserOptions.js.map +1 -1
  112. package/dist/plugin/helpers/stashReturnValue.js +19 -13
  113. package/dist/plugin/helpers/stashReturnValue.js.map +1 -0
  114. package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
  115. package/dist/plugin/helpers/tryManifest.js +0 -1
  116. package/dist/plugin/helpers/tryManifest.js.map +1 -1
  117. package/dist/plugin/helpers.js +27 -0
  118. package/dist/plugin/helpers.js.map +1 -0
  119. package/dist/plugin/loader/createBuildLoader.js +1 -1
  120. package/dist/plugin/loader/createBuildLoader.js.map +1 -1
  121. package/dist/plugin/loader/css-loader.development.d.ts.map +1 -1
  122. package/dist/plugin/loader/css-loader.development.js +1 -7
  123. package/dist/plugin/loader/css-loader.development.js.map +1 -1
  124. package/dist/plugin/loader/css-loader.production.js.map +1 -1
  125. package/dist/plugin/loader/env-loader.development.d.ts +12 -0
  126. package/dist/plugin/loader/env-loader.development.d.ts.map +1 -0
  127. package/dist/plugin/loader/env-loader.development.js +60 -0
  128. package/dist/plugin/loader/react-loader.d.ts.map +1 -1
  129. package/dist/plugin/loader/react-loader.js +1 -8
  130. package/dist/plugin/loader/react-loader.js.map +1 -1
  131. package/dist/plugin/metrics/formatMetrics.d.ts +6 -1
  132. package/dist/plugin/metrics/formatMetrics.d.ts.map +1 -1
  133. package/dist/plugin/metrics/formatMetrics.js +21 -3
  134. package/dist/plugin/metrics/formatMetrics.js.map +1 -1
  135. package/dist/plugin/metrics.js +1 -1
  136. package/dist/plugin/plugin.client.d.ts.map +1 -1
  137. package/dist/plugin/plugin.client.js +2 -0
  138. package/dist/plugin/plugin.client.js.map +1 -1
  139. package/dist/plugin/plugin.d.ts.map +1 -1
  140. package/dist/plugin/plugin.js +1 -2
  141. package/dist/plugin/plugin.server.d.ts.map +1 -1
  142. package/dist/plugin/plugin.server.js +3 -0
  143. package/dist/plugin/plugin.server.js.map +1 -1
  144. package/dist/plugin/preserver/plugin.js.map +1 -1
  145. package/dist/plugin/process-env.d.ts +14 -0
  146. package/dist/plugin/process-env.d.ts.map +1 -0
  147. package/dist/plugin/process-env.js +1 -0
  148. package/dist/plugin/react-client/createMessageHandlers.d.ts +11 -0
  149. package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -0
  150. package/dist/plugin/react-client/createMessageHandlers.js +47 -0
  151. package/dist/plugin/react-client/createMessageHandlers.js.map +1 -0
  152. package/dist/plugin/react-client/createWorkerStream.d.ts +9 -3
  153. package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
  154. package/dist/plugin/react-client/createWorkerStream.js +102 -70
  155. package/dist/plugin/react-client/createWorkerStream.js.map +1 -1
  156. package/dist/plugin/react-client/handleWorkerRscStream.d.ts +19 -0
  157. package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -0
  158. package/dist/plugin/react-client/handleWorkerRscStream.js +47 -0
  159. package/dist/plugin/react-client/handleWorkerRscStream.js.map +1 -0
  160. package/dist/plugin/react-client/plugin.d.ts.map +1 -1
  161. package/dist/plugin/react-client/plugin.js +19 -5
  162. package/dist/plugin/react-client/plugin.js.map +1 -1
  163. package/dist/plugin/react-client/restartWorker.d.ts +6 -1
  164. package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
  165. package/dist/plugin/react-client/restartWorker.js +13 -5
  166. package/dist/plugin/react-client/restartWorker.js.map +1 -1
  167. package/dist/plugin/react-client/server.d.ts +2 -13
  168. package/dist/plugin/react-client/server.d.ts.map +1 -1
  169. package/dist/plugin/react-client/server.js +123 -121
  170. package/dist/plugin/react-client/server.js.map +1 -1
  171. package/dist/plugin/react-server/plugin.d.ts.map +1 -1
  172. package/dist/plugin/react-server/plugin.js +18 -8
  173. package/dist/plugin/react-server/plugin.js.map +1 -1
  174. package/dist/plugin/react-server/server.d.ts.map +1 -1
  175. package/dist/plugin/react-server/server.js +37 -23
  176. package/dist/plugin/react-server/server.js.map +1 -1
  177. package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -1
  178. package/dist/plugin/react-static/collectHtmlWorkerContent.js +9 -0
  179. package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -1
  180. package/dist/plugin/react-static/collectRscContent.js.map +1 -1
  181. package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -1
  182. package/dist/plugin/react-static/configurePreviewServer.js +58 -54
  183. package/dist/plugin/react-static/configurePreviewServer.js.map +1 -1
  184. package/dist/plugin/react-static/fileWriter.d.ts +1 -1
  185. package/dist/plugin/react-static/fileWriter.d.ts.map +1 -1
  186. package/dist/plugin/react-static/fileWriter.js.map +1 -1
  187. package/dist/plugin/react-static/plugin.d.ts.map +1 -1
  188. package/dist/plugin/react-static/plugin.js +21 -23
  189. package/dist/plugin/react-static/plugin.js.map +1 -1
  190. package/dist/plugin/react-static/renderPages.js.map +1 -1
  191. package/dist/plugin/root.d.ts +1 -0
  192. package/dist/plugin/root.d.ts.map +1 -1
  193. package/dist/plugin/root.js +3 -2
  194. package/dist/plugin/root.js.map +1 -1
  195. package/dist/plugin/transformer/plugin.client.d.ts.map +1 -1
  196. package/dist/plugin/transformer/plugin.client.js +3 -12
  197. package/dist/plugin/transformer/plugin.client.js.map +1 -1
  198. package/dist/plugin/transformer/plugin.js.map +1 -1
  199. package/dist/plugin/transformer/plugin.server.d.ts.map +1 -1
  200. package/dist/plugin/transformer/plugin.server.js +17 -24
  201. package/dist/plugin/transformer/plugin.server.js.map +1 -1
  202. package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +1 -10
  203. package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +1 -1
  204. package/dist/plugin/transformer/upgradeCssModuleCode.js +40 -38
  205. package/dist/plugin/types.d.ts +60 -15
  206. package/dist/plugin/types.d.ts.map +1 -1
  207. package/dist/plugin/types.js +1 -1
  208. package/dist/plugin/utils/callServer.d.ts +1 -1
  209. package/dist/plugin/utils/callServer.d.ts.map +1 -1
  210. package/dist/plugin/utils/callServer.js +3 -17
  211. package/dist/plugin/utils/callServer.js.map +1 -1
  212. package/dist/plugin/utils/createCallServer.d.ts +2 -0
  213. package/dist/plugin/utils/createCallServer.d.ts.map +1 -0
  214. package/dist/plugin/utils/createCallServer.js +28 -0
  215. package/dist/plugin/utils/createCallServer.js.map +1 -0
  216. package/dist/plugin/utils/createReactFetcher.d.ts +3 -1
  217. package/dist/plugin/utils/createReactFetcher.d.ts.map +1 -1
  218. package/dist/plugin/utils/createReactFetcher.js +11 -11
  219. package/dist/plugin/utils/createReactFetcher.js.map +1 -1
  220. package/dist/plugin/utils/env.d.ts +2 -0
  221. package/dist/plugin/utils/env.d.ts.map +1 -0
  222. package/dist/plugin/utils/env.js +9 -0
  223. package/dist/plugin/utils/env.js.map +1 -0
  224. package/dist/plugin/utils/envUrls.d.ts +9 -0
  225. package/dist/plugin/utils/envUrls.d.ts.map +1 -0
  226. package/dist/plugin/utils/envUrls.js +7 -0
  227. package/dist/plugin/utils/envUrls.node.d.ts +7 -0
  228. package/dist/plugin/utils/envUrls.node.d.ts.map +1 -0
  229. package/dist/plugin/utils/envUrls.node.js +11 -0
  230. package/dist/plugin/utils/envUrls.node.js.map +1 -0
  231. package/dist/plugin/utils/index.d.ts +2 -1
  232. package/dist/plugin/utils/index.d.ts.map +1 -1
  233. package/dist/plugin/utils/index.js +2 -1
  234. package/dist/plugin/utils/moduleBaseURL.d.ts +3 -0
  235. package/dist/plugin/utils/moduleBaseURL.d.ts.map +1 -0
  236. package/dist/plugin/utils/moduleBaseURL.js +4 -0
  237. package/dist/plugin/utils/urls.d.ts +130 -0
  238. package/dist/plugin/utils/urls.d.ts.map +1 -0
  239. package/dist/plugin/utils/urls.js +87 -0
  240. package/dist/plugin/utils/urls.js.map +1 -0
  241. package/dist/plugin/utils.js +2 -1
  242. package/dist/plugin/utils.js.map +1 -1
  243. package/dist/plugin/vendor/index.d.ts +2 -0
  244. package/dist/plugin/vendor/index.d.ts.map +1 -0
  245. package/dist/plugin/vendor/index.js +1 -0
  246. package/dist/plugin/vendor/vendor.client.d.ts.map +1 -0
  247. package/dist/plugin/vendor/vendor.client.js.map +1 -0
  248. package/dist/plugin/vendor/vendor.d.ts +2 -0
  249. package/dist/plugin/vendor/vendor.d.ts.map +1 -0
  250. package/dist/plugin/vendor/vendor.js +15 -0
  251. package/dist/plugin/vendor/vendor.js.map +1 -0
  252. package/dist/plugin/vendor/vendor.server.d.ts.map +1 -0
  253. package/dist/plugin/vendor/vendor.server.js.map +1 -0
  254. package/dist/plugin/vendor.js +7 -0
  255. package/dist/plugin/vendor.js.map +1 -0
  256. package/dist/plugin/worker/createWorker.d.ts +3 -0
  257. package/dist/plugin/worker/createWorker.d.ts.map +1 -1
  258. package/dist/plugin/worker/createWorker.js +37 -23
  259. package/dist/plugin/worker/createWorker.js.map +1 -1
  260. package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -1
  261. package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +4 -1
  262. package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -1
  263. package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
  264. package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
  265. package/dist/plugin/worker/rsc/handleRender.d.ts +2 -7
  266. package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
  267. package/dist/plugin/worker/rsc/handleRender.js +4 -4
  268. package/dist/plugin/worker/rsc/handleRender.js.map +1 -1
  269. package/dist/plugin/worker/rsc/messageHandler.d.ts +2 -1
  270. package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
  271. package/dist/plugin/worker/rsc/messageHandler.js +42 -16
  272. package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
  273. package/dist/plugin/worker/rsc/rsc-worker.development.js +16 -5
  274. package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
  275. package/dist/plugin/worker/rsc/rsc-worker.production.js +16 -5
  276. package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
  277. package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
  278. package/dist/plugin/worker/rsc/state.js.map +1 -1
  279. package/dist/plugin/worker/sendMessage.js +45 -43
  280. package/dist/plugin/worker/sendMessage.js.map +1 -0
  281. package/dist/plugin/worker/types.d.ts +32 -4
  282. package/dist/plugin/worker/types.d.ts.map +1 -1
  283. package/dist/server.js +1 -1
  284. package/dist/server.js.map +1 -1
  285. package/dist/tsconfig.tsbuildinfo +1 -1
  286. package/package.json +34 -14
  287. package/plugin/{css-collector-elements.tsx → components/css-collector-elements.tsx} +1 -1
  288. package/plugin/{css-collector.tsx → components/css-collector.tsx} +1 -1
  289. package/plugin/{html.tsx → components/html.tsx} +1 -3
  290. package/{dist/plugin/components.d.ts → plugin/components/index.ts} +1 -1
  291. package/plugin/config/autoDiscover/index.ts +10 -0
  292. package/plugin/config/{resolveAutoDiscover.ts → autoDiscover/resolveAutoDiscover.ts} +16 -12
  293. package/plugin/config/autoDiscover/resolveBuildPages.ts +10 -11
  294. package/plugin/config/defaults.tsx +6 -4
  295. package/plugin/config/index.ts +1 -1
  296. package/plugin/config/resolveEnv.ts +187 -0
  297. package/plugin/config/resolveOptions.ts +60 -27
  298. package/plugin/config/resolveUrlOption.ts +2 -7
  299. package/plugin/config/resolveUserConfig.ts +145 -98
  300. package/plugin/env/index.ts +1 -0
  301. package/plugin/env/plugin.ts +78 -0
  302. package/plugin/error/toError.ts +19 -0
  303. package/plugin/file-preserver/plugin.ts +117 -0
  304. package/plugin/helpers/createCssProps.tsx +14 -6
  305. package/plugin/helpers/createRscStream.tsx +1 -1
  306. package/plugin/helpers/formatMetrics.ts +2 -2
  307. package/plugin/helpers/getRouteFiles.ts +3 -1
  308. package/plugin/helpers/index.ts +38 -0
  309. package/plugin/helpers/inputNormalizer.ts +66 -17
  310. package/plugin/helpers/requestInfo.ts +91 -0
  311. package/plugin/{resolvePage.ts → helpers/resolvePage.ts} +19 -4
  312. package/plugin/helpers/resolvePageAndProps.ts +7 -4
  313. package/plugin/{resolveProps.ts → helpers/resolveProps.ts} +8 -6
  314. package/plugin/helpers/serializeUserOptions.ts +1 -1
  315. package/plugin/helpers/tryManifest.ts +0 -1
  316. package/plugin/loader/createBuildLoader.ts +1 -1
  317. package/plugin/loader/css-loader.development.ts +2 -8
  318. package/plugin/loader/env-loader.development.ts +84 -0
  319. package/plugin/loader/react-loader.ts +1 -10
  320. package/plugin/metrics/formatMetrics.ts +29 -4
  321. package/plugin/plugin.client.ts +2 -0
  322. package/plugin/plugin.server.ts +3 -0
  323. package/plugin/plugin.ts +1 -3
  324. package/plugin/preserver/plugin.ts +1 -0
  325. package/plugin/process-env.ts +13 -0
  326. package/plugin/react-client/createMessageHandlers.ts +49 -0
  327. package/plugin/react-client/createWorkerStream.ts +130 -83
  328. package/plugin/react-client/handleWorkerRscStream.ts +57 -0
  329. package/plugin/react-client/plugin.ts +30 -17
  330. package/plugin/react-client/restartWorker.ts +15 -7
  331. package/plugin/react-client/server.ts +129 -164
  332. package/plugin/react-server/plugin.ts +26 -13
  333. package/plugin/react-server/server.ts +40 -35
  334. package/plugin/react-static/collectHtmlWorkerContent.ts +13 -1
  335. package/plugin/react-static/configurePreviewServer.ts +75 -62
  336. package/plugin/react-static/fileWriter.ts +1 -1
  337. package/plugin/react-static/plugin.ts +23 -30
  338. package/plugin/root.ts +7 -1
  339. package/plugin/transformer/plugin.client.ts +4 -12
  340. package/plugin/transformer/plugin.server.ts +18 -25
  341. package/plugin/transformer/upgradeCssModuleCode.ts +39 -39
  342. package/plugin/types/env.d.ts +7 -0
  343. package/plugin/types.ts +80 -29
  344. package/plugin/utils/callServer.ts +3 -24
  345. package/plugin/utils/createCallServer.ts +26 -0
  346. package/plugin/utils/createReactFetcher.ts +14 -12
  347. package/plugin/utils/env.ts +1 -0
  348. package/plugin/utils/envUrls.node.ts +19 -0
  349. package/plugin/utils/envUrls.ts +8 -0
  350. package/plugin/utils/index.ts +2 -1
  351. package/plugin/utils/moduleBaseURL.ts +7 -0
  352. package/plugin/utils/urls.ts +217 -0
  353. package/plugin/vendor/index.ts +1 -0
  354. package/plugin/vendor/vendor.ts +6 -0
  355. package/plugin/worker/createWorker.ts +41 -30
  356. package/plugin/worker/html/createHtmlWorkerRenderState.tsx +4 -1
  357. package/plugin/worker/html/html-worker.development.tsx +2 -1
  358. package/plugin/worker/html/html-worker.production.tsx +2 -1
  359. package/plugin/worker/rsc/handleRender.ts +6 -12
  360. package/plugin/worker/rsc/messageHandler.tsx +53 -20
  361. package/plugin/worker/rsc/rsc-worker.development.ts +23 -9
  362. package/plugin/worker/rsc/rsc-worker.production.ts +23 -7
  363. package/plugin/worker/types.ts +35 -4
  364. package/dist/plugin/components.d.ts.map +0 -1
  365. package/dist/plugin/config/resolveAutoDiscover.d.ts.map +0 -1
  366. package/dist/plugin/config/resolveAutoDiscover.js.map +0 -1
  367. package/dist/plugin/copy.d.ts +0 -7
  368. package/dist/plugin/copy.d.ts.map +0 -1
  369. package/dist/plugin/copy.js +0 -30
  370. package/dist/plugin/css-collector-elements.d.ts.map +0 -1
  371. package/dist/plugin/css-collector-elements.js.map +0 -1
  372. package/dist/plugin/css-collector.d.ts.map +0 -1
  373. package/dist/plugin/css-collector.js.map +0 -1
  374. package/dist/plugin/getCondition.d.ts +0 -2
  375. package/dist/plugin/getCondition.d.ts.map +0 -1
  376. package/dist/plugin/html.d.ts +0 -4
  377. package/dist/plugin/html.d.ts.map +0 -1
  378. package/dist/plugin/html.js +0 -18
  379. package/dist/plugin/html.js.map +0 -1
  380. package/dist/plugin/manifest.d.ts +0 -6
  381. package/dist/plugin/manifest.d.ts.map +0 -1
  382. package/dist/plugin/manifest.js +0 -13
  383. package/dist/plugin/moduleRefs.d.ts.map +0 -1
  384. package/dist/plugin/moduleRefs.js.map +0 -1
  385. package/dist/plugin/resolvePage.d.ts.map +0 -1
  386. package/dist/plugin/resolvePage.js.map +0 -1
  387. package/dist/plugin/resolveProps.d.ts.map +0 -1
  388. package/dist/plugin/resolveProps.js.map +0 -1
  389. package/dist/plugin/utils/pageURL.d.ts +0 -2
  390. package/dist/plugin/utils/pageURL.d.ts.map +0 -1
  391. package/dist/plugin/utils/pageURL.js +0 -21
  392. package/dist/plugin/utils/pageURL.js.map +0 -1
  393. package/dist/plugin/vendor.client.d.ts.map +0 -1
  394. package/dist/plugin/vendor.client.js.map +0 -1
  395. package/dist/plugin/vendor.server.d.ts.map +0 -1
  396. package/dist/plugin/vendor.server.js.map +0 -1
  397. package/plugin/copy.ts +0 -39
  398. package/plugin/manifest.ts +0 -24
  399. package/plugin/utils/pageURL.ts +0 -28
  400. /package/dist/plugin/{css-collector-elements.js → components/css-collector-elements.js} +0 -0
  401. /package/dist/plugin/{css-collector.js → components/css-collector.js} +0 -0
  402. /package/{plugin/components.ts → dist/plugin/components/index.js} +0 -0
  403. /package/dist/plugin/{getCondition.js → config/resolveDevServerConfig.js} +0 -0
  404. /package/dist/plugin/{moduleRefs.d.ts → helpers/moduleRefs.d.ts} +0 -0
  405. /package/dist/plugin/{moduleRefs.js → helpers/moduleRefs.js} +0 -0
  406. /package/dist/plugin/{resolvePage.d.ts → helpers/resolvePage.d.ts} +0 -0
  407. /package/dist/plugin/{resolveProps.d.ts → helpers/resolveProps.d.ts} +0 -0
  408. /package/dist/plugin/{vendor.client.d.ts → vendor/vendor.client.d.ts} +0 -0
  409. /package/dist/plugin/{vendor.client.js → vendor/vendor.client.js} +0 -0
  410. /package/dist/plugin/{vendor.server.d.ts → vendor/vendor.server.d.ts} +0 -0
  411. /package/dist/plugin/{vendor.server.js → vendor/vendor.server.js} +0 -0
  412. /package/plugin/{getCondition.ts → config/resolveDevServerConfig.tsx} +0 -0
  413. /package/plugin/{moduleRefs.ts → helpers/moduleRefs.ts} +0 -0
  414. /package/plugin/{vendor.client.ts → vendor/vendor.client.ts} +0 -0
  415. /package/plugin/{vendor.server.ts → vendor/vendor.server.ts} +0 -0
@@ -1,10 +1,14 @@
1
1
  import type { PreviewServer } from "vite";
2
- import { MIME_TYPES } from "../config/mimeTypes.js";
3
2
  import type { ResolvedUserOptions } from "../types.js";
4
3
  import { join } from "node:path";
5
4
  import { createReadStream } from "node:fs";
6
5
  import { stat } from "node:fs/promises";
7
6
  import { pipeline } from "node:stream/promises";
7
+ import { requestInfo } from "../helpers/requestInfo.js";
8
+
9
+ interface StreamError extends Error {
10
+ code?: string;
11
+ }
8
12
 
9
13
  export async function configurePreviewServer({
10
14
  server,
@@ -13,77 +17,86 @@ export async function configurePreviewServer({
13
17
  server: PreviewServer;
14
18
  userOptions: ResolvedUserOptions;
15
19
  }) {
16
- const staticHostDir = join(userOptions.projectRoot, userOptions.build.outDir, userOptions.build.static);
20
+ const staticHostDir = join(
21
+ userOptions.projectRoot,
22
+ userOptions.build.outDir,
23
+ userOptions.build.static
24
+ );
17
25
  server.middlewares.use(async (req, res, next) => {
18
- if(!req.url) {
19
- console.log("no url")
26
+ if (!req.url) {
20
27
  return next();
21
28
  }
22
- const [withoutQuery] = req.url.split("?");
23
- const [, value] = userOptions.normalizer(withoutQuery);
24
- const ext = value.slice(value.lastIndexOf("."));
25
- // handle index.html
26
- const isHtml = userOptions.autoDiscover.htmlPattern(value)
27
- if (isHtml || (req.headers.accept?.includes("text/html"))) {
28
- const indexHtml = isHtml ? join(staticHostDir, value) : join(staticHostDir, value, userOptions.build.htmlOutputPath);
29
- try {
30
- const stats = await stat(indexHtml);
31
- if (stats.isFile()) {
32
- res.setHeader("Content-Type", "text/html; charset=utf-8");
33
- await pipeline(createReadStream(indexHtml), res);
34
- return;
35
- }
36
- } catch {
37
- // File doesn't exist, continue to next middleware
38
- }
39
- }
40
- const isRsc = userOptions.autoDiscover.rscPattern(value)
41
- if (isRsc || (req.headers.accept?.includes("text/x-component"))) {
42
- const rsc = isRsc ? join(staticHostDir, value) : join(staticHostDir, value, userOptions.build.rscOutputPath);
43
- try {
44
- const stats = await stat(rsc);
45
- if (stats.isFile()) {
46
- res.setHeader("Content-Type", "text/x-component; charset=utf-8");
47
- await pipeline(createReadStream(rsc), res);
48
- return;
49
- }
50
- } catch {
51
- // File doesn't exist, continue to next middleware
52
- }
53
- }
54
- const isCss = userOptions.autoDiscover.cssPattern(value)
55
- if (isCss || (req.headers.accept?.includes("text/css") && (ext === ""))) {
56
- const css = isCss ? join(staticHostDir, value) : join(staticHostDir, value);
57
- try {
58
- const stats = await stat(css);
59
- if (stats.isFile()) {
60
- res.setHeader("Content-Type", "text/css; charset=utf-8");
61
- await pipeline(createReadStream(css), res);
62
- return;
63
- }
64
- } catch {
65
- // File doesn't exist, continue to next middleware
66
- }
67
- }
29
+ const { contentType, filePath } = requestInfo(req, userOptions, staticHostDir);
30
+
68
31
  // Handle static files including CSS
69
- if (ext) {
70
- const filePath = join(staticHostDir, value);
32
+ if (filePath) {
71
33
  try {
72
34
  const stats = await stat(filePath);
73
35
  if (stats.isFile()) {
74
- // Set proper MIME type based on file extension
75
- const contentType = MIME_TYPES[ext];
76
- // Ensure CSS files are served with the correct MIME type
77
- if (contentType) {
78
- res.setHeader("Content-Type", `${contentType}; charset=utf-8`);
79
- } else {
80
- res.setHeader("Content-Type", "application/octet-stream");
36
+ res.setHeader("Content-Type", contentType);
37
+
38
+ // Create abort controller for the stream
39
+ const controller = new AbortController();
40
+ const { signal } = controller;
41
+
42
+ // Check if response is still writable before streaming
43
+ if (!res.writable) {
44
+ res.statusCode = 499;
45
+ res.end("Client closed request");
46
+ return;
47
+ }
48
+
49
+ try {
50
+ const readStream = createReadStream(filePath);
51
+ readStream.on('error', () => {
52
+ if (!res.writable) {
53
+ controller.abort();
54
+ }
55
+ });
56
+ await pipeline(readStream, res, { signal });
57
+ } catch (error) {
58
+ const streamError = error as StreamError;
59
+ // Handle different error cases
60
+ if (streamError.code === 'ERR_STREAM_PREMATURE_CLOSE' ||
61
+ streamError.name === 'AbortError') {
62
+ // Client closed the connection
63
+ if (res.writable) {
64
+ res.statusCode = 499;
65
+ res.end("Client closed request");
66
+ }
67
+ } else if (streamError.code === 'ENOENT') {
68
+ // File not found
69
+ res.statusCode = 404;
70
+ server.config.logger.error(`File not found: ${filePath}. ${streamError.message}`, {
71
+ error: streamError,
72
+ });
73
+ res.end("File not found");
74
+ } else {
75
+ // Server error
76
+ server.config.logger.error(`Error loading file: ${filePath}. ${streamError.message}`, {
77
+ error: streamError,
78
+ });
79
+ res.statusCode = 500;
80
+ res.end("Internal server error");
81
+ }
82
+ return;
81
83
  }
82
- await pipeline(createReadStream(filePath), res);
83
84
  return;
84
85
  }
85
- } catch {
86
- // File doesn't exist, continue to next middleware
86
+ } catch (error) {
87
+ const err = error as Error;
88
+ // Handle file system errors
89
+ if ((err as NodeJS.ErrnoException).code === 'ENOENT') {
90
+ res.statusCode = 404;
91
+ res.end("File not found");
92
+ } else {
93
+ server.config.logger.error(`Error loading file: ${filePath}.`, {
94
+ error: err,
95
+ });
96
+ res.statusCode = 500;
97
+ res.end("Internal server error");
98
+ }
99
+ return;
87
100
  }
88
101
  }
89
102
  next();
@@ -13,7 +13,7 @@ import type { FileWriterOptions } from "../types.js";
13
13
  import { join } from "node:path";
14
14
  import { createWriteStream } from "node:fs";
15
15
  import { mkdir } from "node:fs/promises";
16
- import { Readable, Transform } from "node:stream";
16
+ import { type Readable, Transform } from "node:stream";
17
17
 
18
18
  /**
19
19
  * Writes HTML and RSC files for a route using streams
@@ -39,7 +39,7 @@ import { type StreamPluginOptions } from "../types.js";
39
39
  import { renderPages } from "./renderPages.js";
40
40
  import { getBundleManifest } from "../helpers/getBundleManifest.js";
41
41
  import { createWorker } from "../worker/createWorker.js";
42
- import { resolveAutoDiscover } from "../config/resolveAutoDiscover.js";
42
+ import { resolveAutoDiscover } from "../config/autoDiscover/resolveAutoDiscover.js";
43
43
  import { getCondition } from "../config/getCondition.js";
44
44
  import {
45
45
  serializedOptions,
@@ -49,6 +49,8 @@ import { collectManifestCss } from "../helpers/collectManifestCss.js";
49
49
  import { createCssProps } from "../helpers/createCssProps.js";
50
50
  import { tryManifest } from "../helpers/tryManifest.js";
51
51
  import { performance } from "node:perf_hooks";
52
+ import { DEFAULT_CONFIG } from "../config/defaults.js";
53
+ import { baseURL } from "../utils/envUrls.node.js";
52
54
 
53
55
  if (getCondition() !== "react-server") {
54
56
  throw new Error(
@@ -64,7 +66,6 @@ let userOptions: ResolvedUserOptions;
64
66
  let autoDiscoveredFiles: AutoDiscoveredFiles | null = null;
65
67
  let serverManifest: Manifest | undefined = undefined;
66
68
  let buildLoader: Awaited<ReturnType<typeof createBuildLoader>> | undefined;
67
-
68
69
  export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
69
70
  meta: ReactStreamPluginMeta;
70
71
  }> {
@@ -92,7 +93,6 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
92
93
  if (config.root && config.root !== userOptions.projectRoot) {
93
94
  userOptions.projectRoot = config.root;
94
95
  }
95
-
96
96
  const autoDiscoverResult = await resolveAutoDiscover({
97
97
  config,
98
98
  configEnv,
@@ -103,7 +103,6 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
103
103
  throw autoDiscoverResult.error;
104
104
  }
105
105
  autoDiscoveredFiles = autoDiscoverResult.autoDiscoveredFiles;
106
-
107
106
  const resolvedConfig = resolveUserConfig({
108
107
  condition: "react-server",
109
108
  config,
@@ -121,7 +120,6 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
121
120
  configResolved(config) {
122
121
  resolvedConfig = config;
123
122
  },
124
-
125
123
  async buildStart() {
126
124
  timing.buildStart = Date.now();
127
125
  if (userOptions.onEvent && autoDiscoveredFiles) {
@@ -136,10 +134,21 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
136
134
  },
137
135
 
138
136
  async renderStart() {
137
+
139
138
  timing.renderStart = Date.now();
140
139
  },
141
140
 
142
141
  async writeBundle(options, bundle) {
142
+ if (userOptions.onEvent) {
143
+ userOptions.onEvent({
144
+ type: "build.writeBundle.static-server",
145
+ data: {
146
+ pages: Array.from(autoDiscoveredFiles?.urlMap.keys() ?? []),
147
+ options,
148
+ bundle,
149
+ },
150
+ });
151
+ }
143
152
  try {
144
153
  const bundleManifest = getBundleManifest<false>({
145
154
  bundle,
@@ -166,7 +175,7 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
166
175
  throw clientManifestResult.error;
167
176
  }
168
177
  const clientManifest = clientManifestResult.manifest;
169
-
178
+
170
179
  buildLoader = await createBuildLoader(
171
180
  {
172
181
  userConfig,
@@ -266,34 +275,12 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
266
275
  cssFilesByPage.set(url, pageCssMap);
267
276
  }
268
277
 
269
- if (userOptions.onEvent) {
270
- userOptions.onEvent({
271
- type: "build.writeBundle",
272
- data: {
273
- pages: Array.from(autoDiscoveredFiles?.urlMap.keys() ?? []),
274
- options,
275
- bundle,
276
- manifest: serverManifest,
277
- },
278
- });
279
- }
280
278
  const staticManifest = autoDiscoveredFiles?.staticManifest ?? {};
281
279
  const indexHtml = staticManifest?.["index.html"]?.file;
282
- const safeParseURL = (() => {
283
- try {
284
- return new URL(join(userOptions.moduleBasePath, indexHtml), userOptions.moduleBaseURL).href;
285
- } catch (error) {
286
- return userOptions.moduleBaseURL + join(userOptions.moduleBasePath, indexHtml);
287
- }
288
- })();
289
280
  const pipeableStreamOptions = {
290
281
  ...userOptions.pipeableStreamOptions,
291
282
  bootstrapModules: [
292
- ...(safeParseURL
293
- ? [
294
- safeParseURL,
295
- ]
296
- : []),
283
+ ...(indexHtml ? [baseURL(indexHtml)] : []),
297
284
  ...(userOptions.pipeableStreamOptions?.bootstrapModules ?? []),
298
285
  ],
299
286
  };
@@ -309,7 +296,7 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
309
296
  ? resolvedConfig.envPrefix
310
297
  : Array.isArray(resolvedConfig.envPrefix)
311
298
  ? resolvedConfig.envPrefix[0]
312
- : "VITE_";
299
+ : DEFAULT_CONFIG.ENV_PREFIX;
313
300
  const routeCount = autoDiscoveredFiles?.urlMap.size ?? 0;
314
301
  const maxListeners = routeCount + 1;
315
302
  const workerResult = await createWorker({
@@ -319,6 +306,7 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
319
306
  reverseCondition: "react-client",
320
307
  maxListeners: maxListeners,
321
308
  envPrefix: viteEnvPrefix,
309
+ logger: this.environment.logger,
322
310
  workerData: {
323
311
  resolvedConfig: serializeResolvedConfig(resolvedConfig),
324
312
  userOptions: {
@@ -390,6 +378,11 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
390
378
  this.environment.logger.info(
391
379
  `Rendered ${finalResult.completedRoutes.size} unique routes in ${finalResult.streamMetrics.duration}ms`
392
380
  );
381
+ if(process.env['NODE_ENV'] !== 'production') {
382
+ this.environment.logger.warn(
383
+ `THIS IS BUILD IS NOT INTENDED FOR PRODUCTION (${process.env['NODE_ENV']})`
384
+ );
385
+ }
393
386
 
394
387
  // Update timing
395
388
  timing.render = Date.now() - (timing.renderStart ?? timing.start);
package/plugin/root.ts CHANGED
@@ -1,4 +1,10 @@
1
1
  import { dirname } from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
3
  export const pluginRoot = dirname(fileURLToPath(import.meta.url));
4
- export const isLinked = !import.meta.url.startsWith(process.cwd());
4
+ export const userProjectRoot =
5
+ process.argv
6
+ .find((arg) => arg.includes("node_modules"))
7
+ ?.match(/^(.+?)\/node_modules\/.+$/)?.[1] ||
8
+ process.env["npm_config_local_prefix"] ||
9
+ process.cwd();
10
+ export const isLinked = !pluginRoot.startsWith(userProjectRoot);
@@ -37,15 +37,7 @@ export function reactTransformPlugin(options: StreamPluginOptions): Plugin {
37
37
  if (resolvedOptionsResult.type === "error") throw resolvedOptionsResult.error;
38
38
  userOptions = resolvedOptionsResult.userOptions;
39
39
  let staticManifest: Manifest;
40
- const getID = (id: string) => {
41
- if(userOptions.moduleBasePath !== '' && !id.startsWith(userOptions.moduleBasePath)) {
42
- id = join(userOptions.moduleBasePath, id);
43
- }
44
- if(!id.startsWith('/')) {
45
- id = '/' + id;
46
- }
47
- return id;
48
- }
40
+
49
41
  return {
50
42
  name: "vite:react-server-action-transform",
51
43
  enforce: "pre",
@@ -80,11 +72,11 @@ export function reactTransformPlugin(options: StreamPluginOptions): Plugin {
80
72
  if (isClient) {
81
73
  return null;
82
74
  }
75
+ const [key, value] = userOptions.normalizer(id);
83
76
  if (isServer && isBuild) {
84
- const [key] = userOptions.normalizer(id);
85
77
  id = key + ".js";
86
78
  }
87
- const finalID = getID(id);
79
+ const finalID = userOptions.moduleID(value);
88
80
  const transformed = await transformModuleIfNeeded(code, finalID, null);
89
81
  if (!transformed) return null;
90
82
  return {
@@ -98,7 +90,7 @@ export function reactTransformPlugin(options: StreamPluginOptions): Plugin {
98
90
  if (!chunk.fileName.includes(".client")) return null;
99
91
 
100
92
  // Get the original file name without extension
101
- const originalName = chunk.fileName.replace(".js", "");
93
+ const originalName = chunk.fileName.replace(userOptions.autoDiscover.moduleExtension, "");
102
94
 
103
95
  // Find matching entry in static manifest
104
96
  const manifestEntry = Object.entries(staticManifest).find(([_, info]) =>
@@ -38,42 +38,34 @@ export function reactTransformPlugin(options: StreamPluginOptions): Plugin {
38
38
 
39
39
  let staticManifest: Manifest;
40
40
 
41
- const getID = (id: string) => {
42
- if(userOptions.moduleBasePath !== '' && !id.startsWith(userOptions.moduleBasePath)) {
43
- id = join(userOptions.moduleBasePath, id);
44
- }
45
- if(!id.startsWith('/')) {
46
- id = '/' + id;
47
- }
48
- return id;
49
- }
50
41
  return {
51
42
  name: "vite:react-server-transform",
52
43
  enforce: "pre", // Run before Vite's transforms
53
- async config(_, configEnv) {
44
+ async config(_config, configEnv) {
54
45
  isBuild = configEnv.command !== "serve";
55
- const staticManifestResult = await tryManifest({
56
- root: userOptions.projectRoot,
57
- ssrManifest: false,
58
- outDir: join(userOptions.build.outDir, userOptions.build.static),
59
- });
60
- if (staticManifestResult.type === "error") {
61
- console.error(staticManifestResult.error);
62
- throw staticManifestResult.error;
46
+ if (isBuild) {
47
+ const staticManifestResult = await tryManifest({
48
+ root: userOptions.projectRoot,
49
+ ssrManifest: false,
50
+ outDir: join(userOptions.build.outDir, userOptions.build.static),
51
+ });
52
+ if (staticManifestResult.type === "error") {
53
+ throw staticManifestResult.error;
54
+ }
55
+ staticManifest = staticManifestResult.manifest;
63
56
  }
64
- staticManifest = staticManifestResult.manifest;
65
57
  },
66
58
  async transform(code, id, options) {
67
59
  const ssr = options?.ssr;
68
60
  if (!ssr) return null;
69
61
  if (!userOptions.autoDiscover.modulePattern(id)) return null;
70
62
  if (!code.match('"use client"')) return null;
71
-
63
+
64
+ const [key, value] = userOptions.normalizer(id);
72
65
  if (isBuild) {
73
- const [key, value] = userOptions.normalizer(id);
74
66
  if (staticManifest) {
75
67
  if (value in staticManifest) {
76
- id = staticManifest[value].file
68
+ id = userOptions.moduleID(staticManifest[value].file);
77
69
  } else {
78
70
  const hash = this.emitFile({
79
71
  id,
@@ -84,16 +76,17 @@ export function reactTransformPlugin(options: StreamPluginOptions): Plugin {
84
76
  // get fileName from hash
85
77
 
86
78
  const fileName = this.getFileName(hash);
87
- id = fileName;
79
+ id = userOptions.moduleID(fileName);
88
80
  }
89
81
  } else {
90
82
  throw new Error(`Client manifest not found.`);
91
83
  }
84
+ } else {
85
+ id = join(userOptions.moduleBasePath, value);
92
86
  }
93
- const finalID = getID(id);
94
87
  const transformed = await transformModuleIfNeeded(
95
88
  code,
96
- finalID,
89
+ id,
97
90
  // Pass null for nextLoad since we don't need module loading in the plugin
98
91
  null
99
92
  );
@@ -1,42 +1,42 @@
1
- /**
2
- * Upgrades CSS module code to track class usage.
3
- *
4
- * This function modifies the CSS module exports to track which classes are actually used.
5
- * It adds a proxy around the exports that records class usage in a global Set.
6
- *
7
- * @param code The original CSS module code from Vite
8
- * @returns The upgraded CSS module code with tracking
9
- */
10
- export function upgradeCssModuleCode(code: string): string {
11
- // Check if this is a CSS module export
12
- if (code.includes('export default')) {
13
- // Add tracking code to the CSS module exports
14
- return code.replace(
15
- /export default ({[\s\S]*?})/,
16
- (_match: string, exports: string) => {
17
- return `
18
- const originalExports = ${exports};
19
- const trackedExports = {};
1
+ // /**
2
+ // * Upgrades CSS module code to track class usage.
3
+ // *
4
+ // * This function modifies the CSS module exports to track which classes are actually used.
5
+ // * It adds a proxy around the exports that records class usage in a global Set.
6
+ // *
7
+ // * @param code The original CSS module code from Vite
8
+ // * @returns The upgraded CSS module code with tracking
9
+ // */
10
+ // export function upgradeCssModuleCode(code: string): string {
11
+ // // Check if this is a CSS module export
12
+ // if (code.includes('export default')) {
13
+ // // Add tracking code to the CSS module exports
14
+ // return code.replace(
15
+ // /export default ({[\s\S]*?})/,
16
+ // (_match: string, exports: string) => {
17
+ // return `
18
+ // const originalExports = ${exports};
19
+ // const trackedExports = {};
20
20
 
21
- // Create a proxy to track class usage
22
- Object.keys(originalExports).forEach(key => {
23
- Object.defineProperty(trackedExports, key, {
24
- get: function() {
25
- // Track that this class was used
26
- if (typeof window !== 'undefined') {
27
- window.__cssModuleClassesUsed = window.__cssModuleClassesUsed || new Set();
28
- window.__cssModuleClassesUsed.add(key);
29
- }
30
- return originalExports[key];
31
- }
32
- });
33
- });
21
+ // // Create a proxy to track class usage
22
+ // Object.keys(originalExports).forEach(key => {
23
+ // Object.defineProperty(trackedExports, key, {
24
+ // get: function() {
25
+ // // Track that this class was used
26
+ // if (typeof window !== 'undefined') {
27
+ // window.__cssModuleClassesUsed = window.__cssModuleClassesUsed || new Set();
28
+ // window.__cssModuleClassesUsed.add(key);
29
+ // }
30
+ // return originalExports[key];
31
+ // }
32
+ // });
33
+ // });
34
34
 
35
- export default trackedExports;
36
- `;
37
- }
38
- );
39
- }
35
+ // export default trackedExports;
36
+ // `;
37
+ // }
38
+ // );
39
+ // }
40
40
 
41
- return code;
42
- }
41
+ // return code;
42
+ // }
@@ -0,0 +1,7 @@
1
+ declare global {
2
+ interface ImportMetaEnv {
3
+ readonly PUBLIC_ORIGIN: string;
4
+ }
5
+ }
6
+
7
+ export {};