vite-plugin-react-server 1.1.12 → 1.1.14

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 (413) hide show
  1. package/dist/package.json +12 -8
  2. package/dist/plugin/components/css-collector-elements.d.ts +4 -2
  3. package/dist/plugin/components/css-collector-elements.d.ts.map +1 -1
  4. package/dist/plugin/components/css-collector-elements.js +21 -7
  5. package/dist/plugin/components/css-collector-elements.js.map +1 -1
  6. package/dist/plugin/components/css-collector.d.ts +4 -5
  7. package/dist/plugin/components/css-collector.d.ts.map +1 -1
  8. package/dist/plugin/components/css-collector.js +5 -9
  9. package/dist/plugin/components/css-collector.js.map +1 -1
  10. package/dist/plugin/components/html.d.ts +1 -1
  11. package/dist/plugin/components/html.d.ts.map +1 -1
  12. package/dist/plugin/components/html.js +14 -3
  13. package/dist/plugin/components/html.js.map +1 -1
  14. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts +4 -4
  15. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts.map +1 -1
  16. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js +14 -9
  17. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js.map +1 -1
  18. package/dist/plugin/config/defaults.d.ts +66 -12
  19. package/dist/plugin/config/defaults.d.ts.map +1 -1
  20. package/dist/plugin/config/defaults.js +69 -15
  21. package/dist/plugin/config/defaults.js.map +1 -1
  22. package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts +5 -0
  23. package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts.map +1 -0
  24. package/dist/plugin/config/resolveAutoDiscoverMatcher.js +25 -0
  25. package/dist/plugin/config/resolveAutoDiscoverMatcher.js.map +1 -0
  26. package/dist/plugin/config/resolveEnv.d.ts.map +1 -1
  27. package/dist/plugin/config/resolveEnv.js +16 -5
  28. package/dist/plugin/config/resolveEnv.js.map +1 -1
  29. package/dist/plugin/config/resolveOptions.d.ts +3 -3
  30. package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
  31. package/dist/plugin/config/resolveOptions.js +144 -135
  32. package/dist/plugin/config/resolveOptions.js.map +1 -1
  33. package/dist/plugin/config/resolveUserConfig.d.ts +4 -4
  34. package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
  35. package/dist/plugin/config/resolveUserConfig.js +8 -1
  36. package/dist/plugin/config/resolveUserConfig.js.map +1 -1
  37. package/dist/plugin/error/toError.d.ts +3 -0
  38. package/dist/plugin/error/toError.d.ts.map +1 -1
  39. package/dist/plugin/error/toError.js +32 -4
  40. package/dist/plugin/error/toError.js.map +1 -1
  41. package/dist/plugin/helpers/cleanObject.d.ts.map +1 -1
  42. package/dist/plugin/helpers/cleanObject.js +19 -5
  43. package/dist/plugin/helpers/cleanObject.js.map +1 -1
  44. package/dist/plugin/helpers/collectManifestCss.d.ts +1 -2
  45. package/dist/plugin/helpers/collectManifestCss.d.ts.map +1 -1
  46. package/dist/plugin/helpers/collectManifestCss.js +3 -5
  47. package/dist/plugin/helpers/collectManifestCss.js.map +1 -1
  48. package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +3 -3
  49. package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -1
  50. package/dist/plugin/helpers/collectViteModuleGraphCss.js +6 -2
  51. package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -1
  52. package/dist/plugin/helpers/createCssProps.d.ts +4 -3
  53. package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
  54. package/dist/plugin/helpers/createCssProps.js +11 -27
  55. package/dist/plugin/helpers/createCssProps.js.map +1 -1
  56. package/dist/plugin/helpers/createHandler.d.ts +4 -3
  57. package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
  58. package/dist/plugin/helpers/createHandler.js +1 -1
  59. package/dist/plugin/helpers/createHandler.js.map +1 -1
  60. package/dist/plugin/helpers/createRscStream.d.ts +2 -2
  61. package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
  62. package/dist/plugin/helpers/createRscStream.js +16 -5
  63. package/dist/plugin/helpers/createRscStream.js.map +1 -1
  64. package/dist/plugin/helpers/index.d.ts +2 -2
  65. package/dist/plugin/helpers/index.d.ts.map +1 -1
  66. package/dist/plugin/helpers/index.js +2 -2
  67. package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
  68. package/dist/plugin/helpers/inputNormalizer.js +4 -1
  69. package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
  70. package/dist/plugin/helpers/moduleResolver.d.ts +3 -0
  71. package/dist/plugin/helpers/moduleResolver.d.ts.map +1 -0
  72. package/dist/plugin/helpers/moduleResolver.js +25 -0
  73. package/dist/plugin/helpers/requestInfo.d.ts +18 -3
  74. package/dist/plugin/helpers/requestInfo.d.ts.map +1 -1
  75. package/dist/plugin/helpers/requestInfo.js +75 -11
  76. package/dist/plugin/helpers/requestInfo.js.map +1 -1
  77. package/dist/plugin/helpers/resolvePage.d.ts.map +1 -1
  78. package/dist/plugin/helpers/resolvePage.js +2 -3
  79. package/dist/plugin/helpers/resolvePage.js.map +1 -1
  80. package/dist/plugin/helpers/resolvePageAndProps.d.ts +4 -3
  81. package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -1
  82. package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -1
  83. package/dist/plugin/helpers/serializeUserOptions.d.ts +3 -2
  84. package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -1
  85. package/dist/plugin/helpers/serializeUserOptions.js +13 -1
  86. package/dist/plugin/helpers/serializeUserOptions.js.map +1 -1
  87. package/dist/plugin/helpers/sourceMap.d.ts +8 -0
  88. package/dist/plugin/helpers/sourceMap.d.ts.map +1 -0
  89. package/dist/plugin/helpers/sourceMap.js +136 -0
  90. package/dist/plugin/helpers.js +1 -1
  91. package/dist/plugin/loader/createDefaultLoader.d.ts +13 -0
  92. package/dist/plugin/loader/createDefaultLoader.d.ts.map +1 -0
  93. package/dist/plugin/loader/createDefaultLoader.js +111 -0
  94. package/dist/plugin/loader/css-loader.development.d.ts +3 -15
  95. package/dist/plugin/loader/css-loader.development.d.ts.map +1 -1
  96. package/dist/plugin/loader/css-loader.development.js +17 -16
  97. package/dist/plugin/loader/css-loader.development.js.map +1 -1
  98. package/dist/plugin/loader/css-loader.production.d.ts +1 -1
  99. package/dist/plugin/loader/css-loader.production.d.ts.map +1 -1
  100. package/dist/plugin/loader/css-loader.production.js +1 -1
  101. package/dist/plugin/loader/css-loader.production.js.map +1 -1
  102. package/dist/plugin/loader/env-loader.development.d.ts +1 -0
  103. package/dist/plugin/loader/env-loader.development.d.ts.map +1 -1
  104. package/dist/plugin/loader/env-loader.development.js +17 -9
  105. package/dist/plugin/loader/handleExports.d.ts +34 -0
  106. package/dist/plugin/loader/handleExports.d.ts.map +1 -0
  107. package/dist/plugin/loader/handleExports.js +193 -0
  108. package/dist/plugin/loader/handleExports.js.map +1 -0
  109. package/dist/plugin/loader/index.d.ts +1 -1
  110. package/dist/plugin/loader/index.d.ts.map +1 -1
  111. package/dist/plugin/loader/index.js +4 -1
  112. package/dist/plugin/loader/parse.d.ts +6 -0
  113. package/dist/plugin/loader/parse.d.ts.map +1 -0
  114. package/dist/plugin/loader/parse.js +23 -0
  115. package/dist/plugin/loader/parse.js.map +1 -0
  116. package/dist/plugin/loader/react-loader.client.d.ts +2 -0
  117. package/dist/plugin/loader/react-loader.client.d.ts.map +1 -0
  118. package/dist/plugin/loader/react-loader.client.js +2 -0
  119. package/dist/plugin/loader/react-loader.d.ts +1 -12
  120. package/dist/plugin/loader/react-loader.d.ts.map +1 -1
  121. package/dist/plugin/loader/react-loader.js +5 -687
  122. package/dist/plugin/loader/react-loader.js.map +1 -1
  123. package/dist/plugin/loader/react-loader.server.d.ts +21 -0
  124. package/dist/plugin/loader/react-loader.server.d.ts.map +1 -0
  125. package/dist/plugin/loader/react-loader.server.js +131 -0
  126. package/dist/plugin/loader/sourceMap.d.ts +35 -0
  127. package/dist/plugin/loader/sourceMap.d.ts.map +1 -0
  128. package/dist/plugin/loader/sourceMap.js +105 -0
  129. package/dist/plugin/loader/transformModuleIfNeeded.d.ts +2 -0
  130. package/dist/plugin/loader/transformModuleIfNeeded.d.ts.map +1 -0
  131. package/dist/plugin/loader/transformModuleIfNeeded.js +27 -0
  132. package/dist/plugin/loader/transformModuleIfNeeded.js.map +1 -0
  133. package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts +27 -0
  134. package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts.map +1 -0
  135. package/dist/plugin/loader/transformModuleWithPreservedFunctions.js +125 -0
  136. package/dist/plugin/loader/transformModuleWithPreservedFunctions.js.map +1 -0
  137. package/dist/plugin/loader/types.d.ts +8 -0
  138. package/dist/plugin/loader/types.d.ts.map +1 -0
  139. package/dist/plugin/loader/types.js +1 -0
  140. package/dist/plugin/plugin.client.d.ts +2 -2
  141. package/dist/plugin/plugin.client.d.ts.map +1 -1
  142. package/dist/plugin/plugin.client.js +1 -3
  143. package/dist/plugin/plugin.client.js.map +1 -1
  144. package/dist/plugin/plugin.server.d.ts +2 -2
  145. package/dist/plugin/plugin.server.d.ts.map +1 -1
  146. package/dist/plugin/plugin.server.js +2 -2
  147. package/dist/plugin/plugin.server.js.map +1 -1
  148. package/dist/plugin/preserver/plugin.d.ts +2 -2
  149. package/dist/plugin/preserver/plugin.d.ts.map +1 -1
  150. package/dist/plugin/preserver/plugin.js +6 -2
  151. package/dist/plugin/preserver/plugin.js.map +1 -1
  152. package/dist/plugin/react-client/{server.d.ts → configureWorkerRequestHandler.d.ts} +4 -4
  153. package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts.map +1 -0
  154. package/dist/plugin/react-client/{server.js → configureWorkerRequestHandler.js} +96 -14
  155. package/dist/plugin/react-client/configureWorkerRequestHandler.js.map +1 -0
  156. package/dist/plugin/react-client/createMessageHandlers.d.ts +1 -1
  157. package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -1
  158. package/dist/plugin/react-client/createMessageHandlers.js +21 -11
  159. package/dist/plugin/react-client/createMessageHandlers.js.map +1 -1
  160. package/dist/plugin/react-client/createWorkerStream.d.ts +5 -3
  161. package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
  162. package/dist/plugin/react-client/createWorkerStream.js +72 -27
  163. package/dist/plugin/react-client/createWorkerStream.js.map +1 -1
  164. package/dist/plugin/react-client/handleWorkerRscStream.d.ts +1 -1
  165. package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -1
  166. package/dist/plugin/react-client/handleWorkerRscStream.js +21 -4
  167. package/dist/plugin/react-client/handleWorkerRscStream.js.map +1 -1
  168. package/dist/plugin/react-client/plugin.d.ts +2 -2
  169. package/dist/plugin/react-client/plugin.d.ts.map +1 -1
  170. package/dist/plugin/react-client/plugin.js +7 -8
  171. package/dist/plugin/react-client/plugin.js.map +1 -1
  172. package/dist/plugin/react-client/restartWorker.d.ts +1 -1
  173. package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
  174. package/dist/plugin/react-client/restartWorker.js +11 -4
  175. package/dist/plugin/react-client/restartWorker.js.map +1 -1
  176. package/dist/plugin/react-server/configureReactServer.d.ts +9 -0
  177. package/dist/plugin/react-server/configureReactServer.d.ts.map +1 -0
  178. package/dist/plugin/react-server/{server.js → configureReactServer.js} +27 -10
  179. package/dist/plugin/react-server/configureReactServer.js.map +1 -0
  180. package/dist/plugin/react-server/handleServerAction.d.ts +5 -0
  181. package/dist/plugin/react-server/handleServerAction.d.ts.map +1 -0
  182. package/dist/plugin/react-server/handleServerAction.js +129 -0
  183. package/dist/plugin/react-server/handleServerAction.js.map +1 -0
  184. package/dist/plugin/react-server/plugin.d.ts +2 -2
  185. package/dist/plugin/react-server/plugin.d.ts.map +1 -1
  186. package/dist/plugin/react-server/plugin.js +1 -1
  187. package/dist/plugin/react-server/plugin.js.map +1 -1
  188. package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +2 -2
  189. package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -1
  190. package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -1
  191. package/dist/plugin/react-static/collectRscContent.d.ts +2 -2
  192. package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -1
  193. package/dist/plugin/react-static/collectRscContent.js.map +1 -1
  194. package/dist/plugin/react-static/configurePreviewServer.d.ts +3 -3
  195. package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -1
  196. package/dist/plugin/react-static/configurePreviewServer.js +18 -7
  197. package/dist/plugin/react-static/configurePreviewServer.js.map +1 -1
  198. package/dist/plugin/react-static/createBuildLoader.d.ts +20 -0
  199. package/dist/plugin/react-static/createBuildLoader.d.ts.map +1 -0
  200. package/dist/plugin/react-static/createBuildLoader.js +135 -0
  201. package/dist/plugin/react-static/createBuildLoader.js.map +1 -0
  202. package/dist/plugin/react-static/plugin.d.ts +2 -2
  203. package/dist/plugin/react-static/plugin.d.ts.map +1 -1
  204. package/dist/plugin/react-static/plugin.js +36 -23
  205. package/dist/plugin/react-static/plugin.js.map +1 -1
  206. package/dist/plugin/react-static/renderPage.d.ts +2 -2
  207. package/dist/plugin/react-static/renderPage.d.ts.map +1 -1
  208. package/dist/plugin/react-static/renderPage.js.map +1 -1
  209. package/dist/plugin/react-static/renderPages.d.ts +2 -2
  210. package/dist/plugin/react-static/renderPages.d.ts.map +1 -1
  211. package/dist/plugin/react-static/renderPages.js.map +1 -1
  212. package/dist/plugin/react-static/renderStreams.d.ts +2 -2
  213. package/dist/plugin/react-static/renderStreams.d.ts.map +1 -1
  214. package/dist/plugin/react-static/renderStreams.js +4 -4
  215. package/dist/plugin/react-static/renderStreams.js.map +1 -1
  216. package/dist/plugin/react-static/temporaryReferences.d.ts +2 -0
  217. package/dist/plugin/react-static/temporaryReferences.d.ts.map +1 -0
  218. package/dist/plugin/react-static/temporaryReferences.js.map +1 -0
  219. package/dist/plugin/source-map/createMappingsSerializer.d.ts +2 -0
  220. package/dist/plugin/source-map/createMappingsSerializer.d.ts.map +1 -0
  221. package/dist/plugin/source-map/createMappingsSerializer.js +159 -0
  222. package/dist/plugin/source-map/readMappings.d.ts +2 -0
  223. package/dist/plugin/source-map/readMappings.d.ts.map +1 -0
  224. package/dist/plugin/source-map/readMappings.js +201 -0
  225. package/dist/plugin/transformer/index.d.ts +0 -1
  226. package/dist/plugin/transformer/index.d.ts.map +1 -1
  227. package/dist/plugin/transformer/index.js +0 -1
  228. package/dist/plugin/transformer/plugin.client.d.ts +1 -3
  229. package/dist/plugin/transformer/plugin.client.d.ts.map +1 -1
  230. package/dist/plugin/transformer/plugin.client.js +1 -84
  231. package/dist/plugin/transformer/plugin.server.d.ts +2 -2
  232. package/dist/plugin/transformer/plugin.server.d.ts.map +1 -1
  233. package/dist/plugin/transformer/plugin.server.js +52 -20
  234. package/dist/plugin/transformer/plugin.server.js.map +1 -1
  235. package/dist/plugin/types.d.ts +100 -119
  236. package/dist/plugin/types.d.ts.map +1 -1
  237. package/dist/plugin/utils/callServer.d.ts +1 -1
  238. package/dist/plugin/utils/callServer.d.ts.map +1 -1
  239. package/dist/plugin/utils/createCallServer.d.ts +1 -1
  240. package/dist/plugin/utils/createCallServer.d.ts.map +1 -1
  241. package/dist/plugin/utils/createCallServer.js +13 -4
  242. package/dist/plugin/utils/createCallServer.js.map +1 -1
  243. package/dist/plugin/utils/index.d.ts +1 -0
  244. package/dist/plugin/utils/index.d.ts.map +1 -1
  245. package/dist/plugin/utils/index.js +1 -0
  246. package/dist/plugin/utils.js +1 -0
  247. package/dist/plugin/utils.js.map +1 -1
  248. package/dist/plugin/vendor/vendor.client.d.ts +2 -1
  249. package/dist/plugin/vendor/vendor.client.d.ts.map +1 -1
  250. package/dist/plugin/vendor/vendor.client.js +2 -1
  251. package/dist/plugin/vendor/vendor.client.js.map +1 -1
  252. package/dist/plugin/vendor/vendor.server.d.ts.map +1 -1
  253. package/dist/plugin/vendor/vendor.server.js +1 -1
  254. package/dist/plugin/vendor/vendor.server.js.map +1 -1
  255. package/dist/plugin/worker/createWorker.d.ts.map +1 -1
  256. package/dist/plugin/worker/createWorker.js +17 -22
  257. package/dist/plugin/worker/createWorker.js.map +1 -1
  258. package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -1
  259. package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +25 -4
  260. package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -1
  261. package/dist/plugin/worker/html/html-worker.development.js +15 -13
  262. package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
  263. package/dist/plugin/worker/html/html-worker.production.js +2 -12
  264. package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
  265. package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
  266. package/dist/plugin/worker/html/messageHandler.js +2 -2
  267. package/dist/plugin/worker/html/messageHandler.js.map +1 -1
  268. package/dist/plugin/worker/rsc/handleRender.d.ts +2 -1
  269. package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
  270. package/dist/plugin/worker/rsc/handleRender.js +9 -8
  271. package/dist/plugin/worker/rsc/handleRender.js.map +1 -1
  272. package/dist/plugin/worker/rsc/handlers.d.ts +3 -0
  273. package/dist/plugin/worker/rsc/handlers.d.ts.map +1 -0
  274. package/dist/plugin/worker/rsc/handlers.js +223 -0
  275. package/dist/plugin/worker/rsc/handlers.js.map +1 -0
  276. package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
  277. package/dist/plugin/worker/rsc/messageHandler.js +64 -110
  278. package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
  279. package/dist/plugin/worker/rsc/rsc-worker.development.js +110 -53
  280. package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
  281. package/dist/plugin/worker/rsc/rsc-worker.production.js +1 -1
  282. package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
  283. package/dist/plugin/worker/rsc/state.d.ts +6 -66
  284. package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
  285. package/dist/plugin/worker/rsc/state.js +6 -3
  286. package/dist/plugin/worker/rsc/state.js.map +1 -1
  287. package/dist/plugin/worker/rsc/userOptions.d.ts +2 -0
  288. package/dist/plugin/worker/rsc/userOptions.d.ts.map +1 -0
  289. package/dist/plugin/worker/rsc/userOptions.js +17 -0
  290. package/dist/plugin/worker/rsc/userOptions.js.map +1 -0
  291. package/dist/plugin/worker/sendMessage.d.ts +2 -0
  292. package/dist/plugin/worker/sendMessage.d.ts.map +1 -1
  293. package/dist/plugin/worker/sendMessage.js +2 -1
  294. package/dist/plugin/worker/sendMessage.js.map +1 -1
  295. package/dist/plugin/worker/types.d.ts +53 -53
  296. package/dist/plugin/worker/types.d.ts.map +1 -1
  297. package/dist/tsconfig.tsbuildinfo +1 -1
  298. package/package.json +14 -8
  299. package/plugin/components/css-collector-elements.tsx +30 -9
  300. package/plugin/components/css-collector.tsx +13 -22
  301. package/plugin/components/html.tsx +12 -5
  302. package/plugin/config/autoDiscover/resolveAutoDiscover.ts +31 -13
  303. package/plugin/config/defaults.tsx +75 -16
  304. package/plugin/config/resolveAutoDiscoverMatcher.ts +23 -0
  305. package/plugin/config/resolveEnv.ts +20 -12
  306. package/plugin/config/resolveOptions.ts +238 -207
  307. package/plugin/config/resolveUserConfig.ts +20 -5
  308. package/plugin/error/toError.ts +33 -1
  309. package/plugin/helpers/cleanObject.ts +79 -15
  310. package/plugin/helpers/collectManifestCss.ts +2 -6
  311. package/plugin/helpers/collectViteModuleGraphCss.ts +10 -3
  312. package/plugin/helpers/createCssProps.tsx +26 -38
  313. package/plugin/helpers/createHandler.ts +7 -4
  314. package/plugin/helpers/createRscStream.tsx +21 -14
  315. package/plugin/helpers/index.ts +2 -2
  316. package/plugin/helpers/inputNormalizer.ts +4 -2
  317. package/plugin/helpers/moduleResolver.ts +36 -0
  318. package/plugin/helpers/requestInfo.ts +117 -23
  319. package/plugin/helpers/resolvePage.ts +2 -3
  320. package/plugin/helpers/resolvePageAndProps.ts +7 -6
  321. package/plugin/helpers/serializeUserOptions.ts +20 -2
  322. package/plugin/helpers/sourceMap.ts +182 -0
  323. package/plugin/loader/createDefaultLoader.ts +138 -0
  324. package/plugin/loader/css-loader.development.ts +19 -35
  325. package/plugin/loader/css-loader.production.ts +2 -4
  326. package/plugin/loader/env-loader.development.ts +38 -15
  327. package/plugin/loader/handleExports.ts +299 -0
  328. package/plugin/loader/index.ts +6 -1
  329. package/plugin/loader/parse.ts +22 -0
  330. package/plugin/loader/react-loader.client.ts +1 -0
  331. package/plugin/loader/react-loader.server.ts +185 -0
  332. package/plugin/loader/react-loader.ts +4 -1002
  333. package/plugin/loader/sourceMap.ts +118 -0
  334. package/plugin/loader/transformModuleIfNeeded.ts +33 -0
  335. package/plugin/loader/transformModuleWithPreservedFunctions.ts +226 -0
  336. package/plugin/loader/types.ts +10 -0
  337. package/plugin/plugin.client.ts +16 -11
  338. package/plugin/plugin.server.ts +6 -3
  339. package/plugin/preserver/plugin.ts +37 -17
  340. package/plugin/react-client/{server.ts → configureWorkerRequestHandler.ts} +128 -15
  341. package/plugin/react-client/createMessageHandlers.ts +24 -13
  342. package/plugin/react-client/createWorkerStream.ts +85 -33
  343. package/plugin/react-client/handleWorkerRscStream.ts +24 -5
  344. package/plugin/react-client/plugin.ts +18 -13
  345. package/plugin/react-client/restartWorker.ts +18 -5
  346. package/plugin/react-server/{server.ts → configureReactServer.ts} +41 -11
  347. package/plugin/react-server/handleServerAction.ts +159 -0
  348. package/plugin/react-server/plugin.ts +8 -3
  349. package/plugin/react-static/collectHtmlWorkerContent.ts +11 -3
  350. package/plugin/react-static/collectRscContent.ts +17 -9
  351. package/plugin/react-static/configurePreviewServer.ts +37 -17
  352. package/plugin/react-static/createBuildLoader.ts +194 -0
  353. package/plugin/react-static/plugin.ts +53 -33
  354. package/plugin/react-static/renderPage.ts +12 -6
  355. package/plugin/react-static/renderPages.ts +15 -4
  356. package/plugin/react-static/renderStreams.ts +13 -12
  357. package/plugin/source-map/createMappingsSerializer.ts +182 -0
  358. package/plugin/source-map/readMappings.ts +195 -0
  359. package/plugin/transformer/README.md +295 -29
  360. package/plugin/transformer/index.ts +0 -1
  361. package/plugin/transformer/plugin.client.ts +0 -111
  362. package/plugin/transformer/plugin.server.ts +94 -25
  363. package/plugin/types/react-server-dom-esm.d.ts +183 -24
  364. package/plugin/types/sourceMap.d.ts +2 -0
  365. package/plugin/types/webpack-sources.d.ts +24 -0
  366. package/plugin/types.ts +192 -132
  367. package/plugin/utils/createCallServer.ts +21 -6
  368. package/plugin/utils/index.ts +2 -1
  369. package/plugin/vendor/vendor.client.ts +2 -1
  370. package/plugin/vendor/vendor.server.ts +1 -1
  371. package/plugin/worker/createWorker.ts +21 -24
  372. package/plugin/worker/html/createHtmlWorkerRenderState.tsx +31 -7
  373. package/plugin/worker/html/html-worker.development.tsx +16 -16
  374. package/plugin/worker/html/html-worker.production.tsx +3 -19
  375. package/plugin/worker/html/messageHandler.tsx +2 -4
  376. package/plugin/worker/rsc/handleRender.ts +16 -12
  377. package/plugin/worker/rsc/handlers.ts +243 -0
  378. package/plugin/worker/rsc/messageHandler.tsx +79 -122
  379. package/plugin/worker/rsc/rsc-worker.development.ts +145 -77
  380. package/plugin/worker/rsc/rsc-worker.production.ts +1 -1
  381. package/plugin/worker/rsc/state.ts +12 -6
  382. package/plugin/worker/rsc/userOptions.ts +8 -0
  383. package/plugin/worker/sendMessage.ts +32 -14
  384. package/plugin/worker/types.ts +101 -64
  385. package/dist/plugin/loader/createBuildLoader.d.ts +0 -35
  386. package/dist/plugin/loader/createBuildLoader.d.ts.map +0 -1
  387. package/dist/plugin/loader/createBuildLoader.js +0 -121
  388. package/dist/plugin/loader/createBuildLoader.js.map +0 -1
  389. package/dist/plugin/loader/plugin.d.ts +0 -22
  390. package/dist/plugin/loader/plugin.d.ts.map +0 -1
  391. package/dist/plugin/loader/plugin.js +0 -27
  392. package/dist/plugin/loader/temporaryReferences.d.ts +0 -2
  393. package/dist/plugin/loader/temporaryReferences.d.ts.map +0 -1
  394. package/dist/plugin/loader/temporaryReferences.js.map +0 -1
  395. package/dist/plugin/react-client/server.d.ts.map +0 -1
  396. package/dist/plugin/react-client/server.js.map +0 -1
  397. package/dist/plugin/react-server/server.d.ts +0 -9
  398. package/dist/plugin/react-server/server.d.ts.map +0 -1
  399. package/dist/plugin/react-server/server.js.map +0 -1
  400. package/dist/plugin/transformer/plugin.client.js.map +0 -1
  401. package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +0 -2
  402. package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +0 -1
  403. package/dist/plugin/transformer/upgradeCssModuleCode.js +0 -40
  404. package/dist/plugin/worker/loader.d.ts +0 -5
  405. package/dist/plugin/worker/loader.d.ts.map +0 -1
  406. package/dist/plugin/worker/loader.js +0 -11
  407. package/dist/plugin/worker/loader.js.map +0 -1
  408. package/plugin/loader/createBuildLoader.ts +0 -174
  409. package/plugin/loader/plugin.ts +0 -33
  410. package/plugin/transformer/upgradeCssModuleCode.ts +0 -42
  411. package/plugin/worker/loader.ts +0 -7
  412. /package/dist/plugin/{loader → react-static}/temporaryReferences.js +0 -0
  413. /package/plugin/{loader → react-static}/temporaryReferences.ts +0 -0
@@ -3,6 +3,8 @@ import type {
3
3
  ResolvedUserConfig,
4
4
  ResolvedUserOptions,
5
5
  AutoDiscoveredFiles,
6
+ PagePropOpt,
7
+ InlineCssOpt,
6
8
  } from "../types.js";
7
9
  import { join } from "node:path";
8
10
  import type { OutputOptions, PreRenderedAsset, PreRenderedChunk } from "rollup";
@@ -10,11 +12,14 @@ import { DEFAULT_CONFIG } from "./defaults.js";
10
12
 
11
13
  let stashedUserConfig: Record<string, ResolvedUserConfig | null> = {};
12
14
 
13
- export type ResolveUserConfigProps = {
15
+ export type ResolveUserConfigProps<
16
+ T extends PagePropOpt = PagePropOpt,
17
+ InlineCSS extends InlineCssOpt = InlineCssOpt
18
+ > = {
14
19
  condition: "react-client" | "react-server";
15
20
  config: UserConfig;
16
21
  configEnv: ConfigEnv;
17
- userOptions: ResolvedUserOptions;
22
+ userOptions: ResolvedUserOptions<T, InlineCSS>;
18
23
  autoDiscoveredFiles: Pick<AutoDiscoveredFiles, "inputs" | "staticManifest">;
19
24
  };
20
25
 
@@ -22,13 +27,16 @@ export type ResolveUserConfigReturn =
22
27
  | { type: "success"; userConfig: ResolvedUserConfig }
23
28
  | { type: "error"; error: Error };
24
29
 
25
- export function resolveUserConfig({
30
+ export function resolveUserConfig<
31
+ T extends PagePropOpt = PagePropOpt,
32
+ InlineCSS extends InlineCssOpt = InlineCssOpt
33
+ >({
26
34
  condition,
27
35
  config,
28
36
  configEnv,
29
37
  userOptions,
30
38
  autoDiscoveredFiles,
31
- }: ResolveUserConfigProps): ResolveUserConfigReturn {
39
+ }: ResolveUserConfigProps<T, InlineCSS>): ResolveUserConfigReturn {
32
40
  const ssr =
33
41
  typeof config.build?.ssr === "boolean"
34
42
  ? config.build?.ssr
@@ -62,6 +70,9 @@ export function resolveUserConfig({
62
70
  fallback: (info: T, ssr: boolean) => string,
63
71
  ssr: boolean
64
72
  ) => {
73
+ if ("source" in info && info.source === "") {
74
+ return "";
75
+ }
65
76
  if (!ssr || !input) {
66
77
  return fallback(info, false);
67
78
  }
@@ -234,6 +245,7 @@ export function resolveUserConfig({
234
245
  // client build options
235
246
  build: {
236
247
  ...config.build,
248
+ modulePreload: config.build?.modulePreload ?? false,
237
249
  emptyOutDir: config.build?.emptyOutDir ?? true,
238
250
  outDir: config.build?.outDir ?? join(userOptions.build.outDir, envDir),
239
251
  assetsDir: config.build?.assetsDir ?? userOptions.build.assetsDir,
@@ -246,7 +258,9 @@ export function resolveUserConfig({
246
258
  minify: minify,
247
259
  rollupOptions: {
248
260
  ...config.build?.rollupOptions,
249
- input: autoDiscoveredFiles.inputs,
261
+ input: {
262
+ ...autoDiscoveredFiles.inputs,
263
+ },
250
264
  output: newOutput,
251
265
  preserveEntrySignatures:
252
266
  config.build?.rollupOptions?.preserveEntrySignatures ??
@@ -285,6 +299,7 @@ export function resolveUserConfig({
285
299
  // server build options
286
300
  build: {
287
301
  ...config.build,
302
+ modulePreload: config.build?.modulePreload ?? false,
288
303
  emptyOutDir: config.build?.emptyOutDir ?? true,
289
304
  outDir: config.build?.outDir ?? join(userOptions.build.outDir, envDir),
290
305
  target: config.build?.target ?? "node18",
@@ -1,19 +1,51 @@
1
+ import type { Logger } from "vite";
2
+
1
3
  export function toError(error: unknown): {
2
4
  name: string;
3
5
  message: string;
4
6
  stack?: string;
7
+ cause?: unknown;
5
8
  } {
9
+ if(typeof error === "string") {
10
+ return {
11
+ name: "Error",
12
+ message: error,
13
+ stack: undefined,
14
+ cause: undefined,
15
+ };
16
+ }
6
17
  return error instanceof Error
7
18
  ? error
8
19
  : typeof error === "object" && error !== null
9
20
  ? {
10
21
  name: "name" in error ? String(error.name) : "Unknown Error",
11
- message: "message" in error ? String(error.message) : "Unknown Error",
22
+ message: "message" in error ? typeof error.message === "string" ? error.message : JSON.stringify(error.message) : "Unknown Error",
12
23
  stack: "stack" in error ? String(error.stack) : undefined,
24
+ cause: "cause" in error ? toError(error.cause) : error,
13
25
  }
14
26
  : {
15
27
  name: "Unknown Error",
16
28
  message: typeof error === "string" ? error : "Unknown Error",
17
29
  stack: undefined,
30
+ cause: error,
18
31
  };
19
32
  }
33
+
34
+ export function logError(error: unknown, logger: Logger | Console = console) {
35
+ const err = toError(error);
36
+ if (process.env["NODE_ENV"] !== "production") {
37
+ if (err.stack && err.stack.includes(err.message)) {
38
+ logger.error(err.stack);
39
+ } else if (err.stack) {
40
+ logger.error(err.message + "\n" + err.stack, {
41
+ error: err,
42
+ });
43
+ } else {
44
+ logger.error(err.message, {
45
+ error: err,
46
+ });
47
+ }
48
+ } else {
49
+ logger.error(err.message);
50
+ }
51
+ }
@@ -1,44 +1,105 @@
1
1
  import type { SerializableRecord } from "../types.js";
2
2
 
3
3
  // Helper function to serialize RegExp objects
4
- function serializeRegExp(regex: RegExp): { source: string; flags: string; __isRegExp: boolean } {
4
+ function serializeRegExp(regex: RegExp): {
5
+ source: string;
6
+ flags: string;
7
+ __isRegExp: boolean;
8
+ } {
5
9
  return {
6
10
  source: regex.source,
7
11
  flags: regex.flags,
8
- __isRegExp: true
12
+ __isRegExp: true,
9
13
  };
10
14
  }
11
15
 
12
- export function cleanObject<T>(obj: T, knownNonSerializableFunctions: Set<string> = new Set(), currentPath: string = ''): SerializableRecord & T {
13
- if (obj === null || obj === undefined) return obj as Extract<SerializableRecord, T>;
14
- if (typeof obj !== 'object') return obj as Extract<SerializableRecord, T>;
15
- if (obj instanceof RegExp) return serializeRegExp(obj) as unknown as Extract<SerializableRecord, T>;
16
+ const isSerializable = (
17
+ x: unknown
18
+ ): x is
19
+ | number
20
+ | bigint
21
+ | boolean
22
+ | string
23
+ | undefined
24
+ | null
25
+ | Uint8Array
26
+ | Uint16Array
27
+ | Uint32Array
28
+ | Int8Array
29
+ | Int16Array
30
+ | Int32Array => {
31
+ return (
32
+ typeof x === "number" ||
33
+ typeof x === "bigint" ||
34
+ typeof x === "boolean" ||
35
+ typeof x === "string" ||
36
+ x instanceof Buffer ||
37
+ (Array.isArray(x) &&
38
+ (!x.length ||
39
+ x instanceof Uint8Array ||
40
+ x instanceof Uint16Array ||
41
+ x instanceof Uint32Array ||
42
+ x instanceof Int8Array ||
43
+ x instanceof Int16Array ||
44
+ x instanceof Int32Array))
45
+ );
46
+ };
47
+
48
+ export function cleanObject<T>(
49
+ obj: T,
50
+ knownNonSerializableFunctions: Set<string> = new Set(),
51
+ currentPath: string = ""
52
+ ): SerializableRecord & T {
53
+ if (typeof obj !== "object" || obj == null) return obj as Extract<SerializableRecord, T>;
54
+ if (isSerializable(obj)) return obj as Extract<SerializableRecord, T>;
55
+
16
56
  if (Array.isArray(obj)) {
17
- return obj.map((x, i) => cleanObject(x, knownNonSerializableFunctions, `${currentPath}[${i}]`)).filter(x => x !== undefined) as Extract<SerializableRecord, T>;
57
+ return obj
58
+ .map((x, i) =>
59
+ cleanObject(x, knownNonSerializableFunctions, `${currentPath}[${i}]`)
60
+ )
61
+ .filter((x) => x !== undefined) as Extract<SerializableRecord, T>;
18
62
  }
19
-
63
+ if (obj instanceof RegExp)
64
+ return serializeRegExp(obj) as unknown as Extract<SerializableRecord, T>;
65
+
20
66
  const result: Record<string, any> = {};
21
67
  for (const [key, value] of Object.entries(obj)) {
22
68
  const fullPath = currentPath ? `${currentPath}.${key}` : key;
23
- const normalizedPath = fullPath.replace(/\[\d+\]/g, '[]');
69
+ const normalizedPath = fullPath.replace(/\[\d+\]/g, "[]");
24
70
  // Skip if it's a function or known non-serializable property
25
- if (typeof value === 'function' || knownNonSerializableFunctions.has(normalizedPath) || knownNonSerializableFunctions.has(key)) {
71
+ if(isSerializable(value)) {
72
+ result[key] = value;
73
+ continue;
74
+ }
75
+ if (
76
+ typeof value === "function" ||
77
+ knownNonSerializableFunctions.has(normalizedPath) ||
78
+ knownNonSerializableFunctions.has(key)
79
+ ) {
26
80
  continue;
27
81
  }
28
82
 
29
83
  // Handle nested objects
30
- if (typeof value === 'object' && value !== null) {
84
+ if (typeof value === "object" && value !== null) {
31
85
  // Check if the object has any functions
32
86
  const hasFunctions = Object.entries(value).some(([k, v]) => {
33
87
  const nestedPath = `${normalizedPath}.${k}`;
34
- return typeof v === 'function' || knownNonSerializableFunctions.has(nestedPath);
88
+ return (
89
+ typeof v === "function" ||
90
+ knownNonSerializableFunctions.has(nestedPath)
91
+ );
35
92
  });
36
93
 
37
94
  if (hasFunctions) {
38
95
  continue;
39
96
  }
40
97
 
41
- const cleaned = cleanObject(value, knownNonSerializableFunctions, `${normalizedPath}.${key}`);
98
+ const cleaned = cleanObject(
99
+ value,
100
+ knownNonSerializableFunctions,
101
+ `${normalizedPath}.${key}`
102
+ );
42
103
  if (cleaned !== undefined && Object.keys(cleaned).length > 0) {
43
104
  result[key] = cleaned;
44
105
  }
@@ -46,5 +107,8 @@ export function cleanObject<T>(obj: T, knownNonSerializableFunctions: Set<string
46
107
  result[key] = value;
47
108
  }
48
109
  }
49
- return (Object.keys(result).length > 0 ? result : {}) as Extract<SerializableRecord, T>;
50
- }
110
+ return (Object.keys(result).length > 0 ? result : {}) as Extract<
111
+ SerializableRecord,
112
+ T
113
+ >;
114
+ }
@@ -1,5 +1,4 @@
1
1
  import type { Manifest } from "vite";
2
- import type { ResolvedUserOptions } from "../types.js";
3
2
 
4
3
  /**
5
4
  * Collects CSS file paths from a manifest by walking through imports starting from a given file
@@ -7,7 +6,6 @@ import type { ResolvedUserOptions } from "../types.js";
7
6
  export function collectManifestCss(
8
7
  manifest: Manifest,
9
8
  startFile: string | string[],
10
- userOptions: Pick<ResolvedUserOptions, "normalizer">
11
9
  ): Record<string, string> {
12
10
  const cssInputs: Record<string, string> = {};
13
11
  const visited = new Set<string>();
@@ -29,8 +27,7 @@ export function collectManifestCss(
29
27
  // Add CSS files from the css property
30
28
  if (fileInfo.css) {
31
29
  for (const cssFile of fileInfo.css) {
32
- const [keyNormalized, valueNormalized] = userOptions.normalizer(cssFile);
33
- cssInputs[keyNormalized] = valueNormalized;
30
+ cssInputs[cssFile] = cssFile + '.css';
34
31
  }
35
32
  }
36
33
 
@@ -49,8 +46,7 @@ export function collectManifestCss(
49
46
  const importedFile = manifest[importPath];
50
47
  if (importedFile?.css) {
51
48
  for (const cssFile of importedFile.css) {
52
- const [keyNormalized, valueNormalized] = userOptions.normalizer(cssFile);
53
- cssInputs[keyNormalized] = valueNormalized;
49
+ cssInputs[cssFile] = cssFile + '.css';
54
50
  }
55
51
  }
56
52
  }
@@ -1,5 +1,5 @@
1
1
  import type { EnvironmentModuleGraph, ModuleGraph } from "vite";
2
- import type { CreateHandlerOptions, CssContent } from "../types.js";
2
+ import type { CreateHandlerOptions, CssContent, InlineCssOpt, PagePropOpt } from "../types.js";
3
3
  import { createCssProps } from "./createCssProps.js";
4
4
 
5
5
  type CollectViteModuleGraphCssResult =
@@ -29,7 +29,8 @@ type CollectViteModuleGraphCssResult =
29
29
  };
30
30
 
31
31
  export async function collectViteModuleGraphCss<
32
- InlineCSS extends boolean | undefined = undefined
32
+ T extends PagePropOpt = PagePropOpt,
33
+ InlineCSS extends InlineCssOpt = InlineCssOpt
33
34
  >({
34
35
  moduleGraph,
35
36
  onCss,
@@ -40,7 +41,7 @@ export async function collectViteModuleGraphCss<
40
41
  onCss?: (cssContent: CssContent, parentUrl: string) => void;
41
42
  parentUrl?: string;
42
43
  handlerOptions: Pick<
43
- CreateHandlerOptions<InlineCSS>,
44
+ CreateHandlerOptions<T, InlineCSS>,
44
45
  | "pagePath"
45
46
  | "moduleBaseURL"
46
47
  | "moduleBasePath"
@@ -48,6 +49,8 @@ export async function collectViteModuleGraphCss<
48
49
  | "projectRoot"
49
50
  | "css"
50
51
  | "loader"
52
+ | "normalizer"
53
+ | "moduleID"
51
54
  >;
52
55
  }): Promise<CollectViteModuleGraphCssResult> {
53
56
  const {
@@ -58,6 +61,8 @@ export async function collectViteModuleGraphCss<
58
61
  projectRoot,
59
62
  css,
60
63
  loader,
64
+ normalizer,
65
+ moduleID,
61
66
  } = handlerOptions;
62
67
  if (!pagePath) return { type: "skip" };
63
68
 
@@ -106,6 +111,8 @@ export async function collectViteModuleGraphCss<
106
111
  moduleRootPath: moduleRootPath,
107
112
  projectRoot: projectRoot,
108
113
  css: css,
114
+ normalizer: normalizer,
115
+ moduleID: moduleID,
109
116
  },
110
117
  });
111
118
  cssFiles.set(mod?.url, cssContent);
@@ -1,5 +1,6 @@
1
1
  import type { ResolvedUserOptions, CssContent } from "../types.js";
2
- import { join, relative } from "node:path";
2
+ import type { InlineCssOpt, PagePropOpt } from "../../server.js";
3
+ import { join } from "node:path";
3
4
  import { deserializeRegExp } from "./serializeUserOptions.js";
4
5
 
5
6
  /**
@@ -21,7 +22,10 @@ import { deserializeRegExp } from "./serializeUserOptions.js";
21
22
  * @param css - The css options
22
23
  * @returns A CssContent object
23
24
  */
24
- export const createCssProps = ({
25
+ export const createCssProps = <
26
+ T extends PagePropOpt = PagePropOpt,
27
+ InlineCSS extends InlineCssOpt = InlineCssOpt
28
+ >({
25
29
  id,
26
30
  code,
27
31
  userOptions,
@@ -29,29 +33,26 @@ export const createCssProps = ({
29
33
  id: string;
30
34
  code: string;
31
35
  userOptions: Pick<
32
- ResolvedUserOptions,
36
+ ResolvedUserOptions<T, InlineCSS>,
33
37
  | "css"
34
38
  | "moduleBaseURL"
35
39
  | "moduleBasePath"
36
40
  | "moduleRootPath"
37
41
  | "projectRoot"
42
+ | "normalizer"
43
+ | "moduleID"
38
44
  >;
39
- }): CssContent => {
40
- const { css, moduleBaseURL, moduleBasePath, moduleRootPath, projectRoot } =
41
- userOptions;
45
+ }): CssContent<InlineCSS> => {
46
+ const { css, moduleRootPath } = userOptions;
42
47
  // If we don't have a bundle entry, create a linked CSS file
43
48
  let inline = typeof code === "string" && code.length > css.inlineThreshold;
44
49
  // Normalize the ID to be relative to src/
45
- const normalizedId = id.startsWith(projectRoot)
46
- ? relative(projectRoot, id)
47
- : id;
48
-
50
+ const [, value] = userOptions.normalizer(id);
51
+ const moduleID = userOptions.moduleID(value);
49
52
  if (css.inlinePatterns?.length) {
50
53
  // Deserialize RegExp patterns if they exist
51
- const inlinePatterns = css.inlinePatterns?.map((pattern) =>
52
- typeof pattern === "string" ? deserializeRegExp(pattern) : pattern
53
- );
54
- if (inlinePatterns.some((pattern) => pattern.test?.(normalizedId))) {
54
+ const inlinePatterns = css.inlinePatterns;
55
+ if (inlinePatterns.some((pattern) => pattern.test?.(id))) {
55
56
  inline = true;
56
57
  }
57
58
  }
@@ -59,46 +60,33 @@ export const createCssProps = ({
59
60
  const linkPatterns = css.linkPatterns?.map((pattern) =>
60
61
  typeof pattern === "string" ? deserializeRegExp(pattern) : pattern
61
62
  );
62
- if (linkPatterns.some((pattern) => pattern.test?.(normalizedId))) {
63
+ if (linkPatterns.some((pattern) => pattern.test?.(id))) {
63
64
  inline = false;
64
65
  }
65
66
  }
66
67
  if (inline) {
67
68
  return {
68
69
  type: "text/css",
69
- id: normalizedId,
70
+ id: moduleID,
70
71
  as: "style",
71
72
  children: code.trim(),
72
73
  ...(process.env["NODE_ENV"] !== "production"
73
74
  ? {
74
- "data-vite-dev-id": join(projectRoot, moduleRootPath, normalizedId),
75
+ "data-vite-dev-id": join(moduleRootPath, moduleID),
75
76
  }
76
77
  : {}),
77
- } as CssContent<true>;
78
+ } as CssContent<InlineCSS>;
78
79
  }
79
- const joined = normalizedId.startsWith(moduleBasePath) ? normalizedId : join(moduleBasePath, normalizedId);
80
- const moduleBaseHasTrailingSlash = moduleBaseURL.endsWith("/");
81
- const joinedHasLeadingSlash = joined.startsWith("/");
82
- const safeParseURL = (() => {
83
- if(joined.startsWith(moduleBaseHasTrailingSlash ? moduleBaseURL.slice(0, -1) : moduleBaseURL)) {
84
- return joined;
85
- }
86
- try {
87
- if (moduleBaseURL.includes("//")) {
88
- // relative to moduleBaseURL
89
- return new URL(joinedHasLeadingSlash ? joined.slice(1) : joined, moduleBaseURL).href;
90
- }
91
- } catch (error) {}
92
- // if the url is not valid, we return the moduleBaseURL + the normalizedId
93
- // dont make it a argument of join or it will mangle something like http:// into http:/
94
- return moduleBaseURL + (!moduleBaseHasTrailingSlash && !joinedHasLeadingSlash ? "/" : "") + (moduleBaseHasTrailingSlash ? joined.slice(1) : joined);
95
- })();
96
80
  // Default case
97
81
  return {
98
- id: normalizedId,
82
+ id: moduleID,
99
83
  as: "link",
100
84
  rel: "stylesheet",
101
- href: safeParseURL,
85
+ href:
86
+ typeof process.env.VITE_PUBLIC_ORIGIN === "string" &&
87
+ process.env.VITE_PUBLIC_ORIGIN !== ""
88
+ ? new URL(moduleID, process.env.VITE_PUBLIC_ORIGIN).href
89
+ : moduleID,
102
90
  precedence: "high",
103
- } as CssContent<false>;
91
+ } as CssContent<InlineCSS>;
104
92
  };
@@ -1,9 +1,12 @@
1
- import type { CreateHandlerOptions } from "../types.js";
1
+ import type { CreateHandlerOptions, InlineCssOpt } from "../types.js";
2
+ import type { PagePropOpt } from "../../server.js";
2
3
  import { createRscStream } from "./createRscStream.js";
3
4
 
4
-
5
- export async function createHandler(handlerOptions: CreateHandlerOptions) {
6
- if(!handlerOptions.PageComponent) {
5
+ export function createHandler<
6
+ T extends PagePropOpt = PagePropOpt,
7
+ InlineCSS extends InlineCssOpt = InlineCssOpt
8
+ >(handlerOptions: CreateHandlerOptions<T, InlineCSS>) {
9
+ if (!handlerOptions.PageComponent) {
7
10
  throw new Error("PageComponent is required");
8
11
  }
9
12
  try {
@@ -1,11 +1,12 @@
1
1
  import { React, ReactDOMServer } from "../vendor/vendor.server.js";
2
- import type { CreateHandlerOptions, StreamMetrics } from "../types.js";
2
+ import type {
3
+ CreateHandlerOptions,
4
+ StreamMetrics,
5
+ PagePropOpt,
6
+ } from "../types.js";
3
7
  import { performance } from "node:perf_hooks";
4
- export function createRscStream<
5
- T,
6
- C extends React.ComponentType<T>,
7
- InlineCSS extends boolean = true
8
- >({
8
+
9
+ export function createRscStream<T extends PagePropOpt = PagePropOpt>({
9
10
  Html = React.Fragment,
10
11
  PageComponent,
11
12
  pageProps,
@@ -22,7 +23,7 @@ export function createRscStream<
22
23
  onEvent,
23
24
  projectRoot,
24
25
  }: Pick<
25
- CreateHandlerOptions<T, C, InlineCSS>,
26
+ CreateHandlerOptions<T>,
26
27
  | "Html"
27
28
  | "PageComponent"
28
29
  | "pageProps"
@@ -46,7 +47,7 @@ export function createRscStream<
46
47
  let streamError: Error | null = null;
47
48
  const startTime = performance.now();
48
49
  try {
49
- const htmlIsFragment = Html == React.Fragment;
50
+ const htmlIsFragment = Html === React.Fragment;
50
51
  const url = route.startsWith(moduleBaseURL) ? route : moduleBaseURL + route;
51
52
 
52
53
  if (!PageComponent) {
@@ -64,10 +65,15 @@ export function createRscStream<
64
65
  },
65
66
  };
66
67
  }
68
+
67
69
  const elements = htmlIsFragment ? (
68
- <CssCollector cssFiles={cssFiles}>
69
- <PageComponent {...(pageProps as any)} />
70
- </CssCollector>
70
+ <CssCollector
71
+ key={route}
72
+ as={React.Fragment}
73
+ cssFiles={cssFiles}
74
+ pageProps={pageProps}
75
+ Page={PageComponent}
76
+ />
71
77
  ) : (
72
78
  <Html
73
79
  moduleBase={moduleBase}
@@ -82,15 +88,16 @@ export function createRscStream<
82
88
  globalCss={globalCss}
83
89
  CssCollector={CssCollector}
84
90
  manifest={manifest}
85
- >
86
- <PageComponent {...(pageProps as any)} />
87
- </Html>
91
+ Page={PageComponent}
92
+ as={"div"}
93
+ />
88
94
  );
89
95
  const stream = ReactDOMServer.renderToPipeableStream(
90
96
  elements,
91
97
  moduleBasePath,
92
98
  {
93
99
  ...pipeableStreamOptions,
100
+ moduleBaseURL: moduleBaseURL,
94
101
  onError(error: Error, errorInfo: any) {
95
102
  const err = error instanceof Error ? error : new Error(String(error));
96
103
  streamError = err;
@@ -15,10 +15,10 @@ export * from "./inputNormalizer.js";
15
15
  export * from "./collectBundleManifestCss.js";
16
16
  export * from "./collectManifestCss.js";
17
17
  export * from "./collectViteModuleGraphCss.js";
18
- export * from "./createCssProps.jsx";
18
+ export * from "./createCssProps.js";
19
19
 
20
20
  // Stream and handler creation
21
- export * from "./createRscStream.jsx";
21
+ export * from "./createRscStream.js";
22
22
  export * from "./createHandler.js";
23
23
  export * from "./createEventHandler.js";
24
24
 
@@ -180,7 +180,7 @@ export function createInputNormalizer({
180
180
  root,
181
181
  moduleBasePath,
182
182
  preserveModulesRoot = undefined,
183
- removeExtension = DEFAULT_CONFIG.MODULE_EXTENSION,
183
+ removeExtension = DEFAULT_CONFIG.AUTO_DISCOVER.moduleExtension,
184
184
  }: CreateInputNormalizerProps): InputNormalizer {
185
185
  if (stashedNormalizer) {
186
186
  return stashedNormalizer;
@@ -246,7 +246,9 @@ export function createInputNormalizer({
246
246
  ? virtualPrefix[0] + normalizedPath
247
247
  : normalizedPath
248
248
  : normalizedPath;
249
-
249
+ if(virtualPrefix){
250
+ return ['', ''];
251
+ }
250
252
  return [key, finalPath];
251
253
  };
252
254
  return stashedNormalizer;
@@ -0,0 +1,36 @@
1
+ let stashedResolve: any = null;
2
+
3
+ export function setStashedResolve(resolve: any) {
4
+ stashedResolve = resolve;
5
+ }
6
+
7
+ export async function resolveClientImport(specifier: string, parentURL: string) {
8
+ const conditions = ["node", "import"];
9
+
10
+ if (stashedResolve === null) {
11
+ throw new Error(
12
+ "Expected resolve to have been called before transformSource"
13
+ );
14
+ }
15
+
16
+ try {
17
+ const result = await stashedResolve(
18
+ specifier,
19
+ {
20
+ conditions,
21
+ parentURL,
22
+ },
23
+ stashedResolve
24
+ );
25
+
26
+ if (!result) {
27
+ console.warn(`Failed to resolve import: ${specifier}`);
28
+ return null;
29
+ }
30
+
31
+ return result;
32
+ } catch (error) {
33
+ console.error(`Error resolving import ${specifier}:`, error);
34
+ return null;
35
+ }
36
+ }