vite-plugin-react-server 0.3.10 → 0.3.12

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 (318) hide show
  1. package/dist/client.d.ts +1 -1
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +1 -1
  4. package/dist/index.d.ts +3 -6
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +2 -2
  7. package/dist/index.js.map +1 -1
  8. package/dist/package.json +16 -14
  9. package/dist/plugin/assertServerCondition.d.ts +5 -1
  10. package/dist/plugin/assertServerCondition.d.ts.map +1 -1
  11. package/dist/plugin/assertServerCondition.js +1 -3
  12. package/dist/plugin/checkFilesExist.d.ts +2 -2
  13. package/dist/plugin/checkFilesExist.d.ts.map +1 -1
  14. package/dist/plugin/checkFilesExist.js +43 -58
  15. package/dist/plugin/checkFilesExist.js.map +1 -1
  16. package/dist/plugin/collect-css-manifest.d.ts.map +1 -1
  17. package/dist/plugin/collect-css-manifest.js +5 -0
  18. package/dist/plugin/collect-css-manifest.js.map +1 -1
  19. package/dist/plugin/components.js +10 -15
  20. package/dist/plugin/config/createModuleIdGenerator.d.ts +11 -0
  21. package/dist/plugin/config/createModuleIdGenerator.d.ts.map +1 -0
  22. package/dist/plugin/config/createModuleIdGenerator.js +44 -0
  23. package/dist/plugin/config/createModuleIdGenerator.js.map +1 -0
  24. package/dist/plugin/config/defaults.d.ts +27 -24
  25. package/dist/plugin/config/defaults.d.ts.map +1 -1
  26. package/dist/plugin/config/defaults.js +26 -31
  27. package/dist/plugin/config/defaults.js.map +1 -1
  28. package/dist/plugin/config/getPaths.js +1 -1
  29. package/dist/plugin/config/resolveOptions.d.ts +1 -1
  30. package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
  31. package/dist/plugin/config/resolveOptions.js +223 -16
  32. package/dist/plugin/config/resolveOptions.js.map +1 -1
  33. package/dist/plugin/config/resolvePages.d.ts +2 -0
  34. package/dist/plugin/config/resolvePages.d.ts.map +1 -1
  35. package/dist/plugin/config/resolvePages.js.map +1 -1
  36. package/dist/plugin/config/resolveUserConfig.d.ts +2 -2
  37. package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
  38. package/dist/plugin/config/resolveUserConfig.js +149 -50
  39. package/dist/plugin/config/resolveUserConfig.js.map +1 -1
  40. package/dist/plugin/helpers/getBundleManifest.d.ts +25 -0
  41. package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -0
  42. package/dist/plugin/helpers/getBundleManifest.js +72 -0
  43. package/dist/plugin/helpers/getBundleManifest.js.map +1 -0
  44. package/dist/plugin/helpers/inputNormalizer.d.ts +14 -1
  45. package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
  46. package/dist/plugin/helpers/inputNormalizer.js +128 -16
  47. package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
  48. package/dist/plugin/helpers/tryManifest.d.ts +3 -1
  49. package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
  50. package/dist/plugin/helpers/tryManifest.js +1 -1
  51. package/dist/plugin/helpers/tryManifest.js.map +1 -1
  52. package/dist/plugin/loader/createBuildLoader.d.ts +6 -2
  53. package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
  54. package/dist/plugin/loader/createBuildLoader.js +37 -9
  55. package/dist/plugin/loader/createBuildLoader.js.map +1 -1
  56. package/dist/plugin/loader/createPageLoader.d.ts.map +1 -1
  57. package/dist/plugin/loader/createPageLoader.js +0 -7
  58. package/dist/plugin/loader/css-loader.d.ts +16 -0
  59. package/dist/plugin/loader/css-loader.d.ts.map +1 -0
  60. package/dist/plugin/loader/css-loader.js +70 -0
  61. package/dist/plugin/loader/css-loader.js.map +1 -0
  62. package/dist/plugin/loader/react-loader.d.ts +17 -0
  63. package/dist/plugin/loader/react-loader.d.ts.map +1 -0
  64. package/dist/plugin/loader/react-loader.js +647 -0
  65. package/dist/plugin/loader/react-loader.js.map +1 -0
  66. package/dist/plugin/loader/rsc/messageHandler.d.ts +2 -0
  67. package/dist/plugin/loader/rsc/messageHandler.d.ts.map +1 -0
  68. package/dist/plugin/loader/rsc/messageHandler.js +1 -0
  69. package/dist/plugin/loader/rsc/rsc-worker.development.d.ts +2 -0
  70. package/dist/plugin/loader/rsc/rsc-worker.development.d.ts.map +1 -0
  71. package/dist/plugin/loader/rsc/rsc-worker.development.js +1 -0
  72. package/dist/plugin/plugin.d.ts +0 -1
  73. package/dist/plugin/plugin.d.ts.map +1 -1
  74. package/dist/plugin/plugin.js +2 -1
  75. package/dist/plugin/preserver/plugin.d.ts.map +1 -1
  76. package/dist/plugin/preserver/plugin.js +3 -2
  77. package/dist/plugin/preserver/plugin.js.map +1 -1
  78. package/dist/plugin/react-client/index.d.ts +2 -1
  79. package/dist/plugin/react-client/index.d.ts.map +1 -1
  80. package/dist/plugin/react-client/index.js +19 -1
  81. package/dist/plugin/react-client/index.js.map +1 -0
  82. package/dist/plugin/react-client/plugin.d.ts +2 -2
  83. package/dist/plugin/react-client/plugin.d.ts.map +1 -1
  84. package/dist/plugin/react-client/plugin.js +283 -10
  85. package/dist/plugin/react-client/plugin.js.map +1 -1
  86. package/dist/plugin/react-server/createHandler.d.ts +2 -2
  87. package/dist/plugin/react-server/createHandler.d.ts.map +1 -1
  88. package/dist/plugin/react-server/createHandler.js +15 -9
  89. package/dist/plugin/react-server/createHandler.js.map +1 -1
  90. package/dist/plugin/react-server/createRscStream.d.ts +15 -3
  91. package/dist/plugin/react-server/createRscStream.d.ts.map +1 -1
  92. package/dist/plugin/react-server/createRscStream.js +53 -36
  93. package/dist/plugin/react-server/createRscStream.js.map +1 -1
  94. package/dist/plugin/react-server/createSsrHandler.d.ts +2 -2
  95. package/dist/plugin/react-server/createSsrHandler.d.ts.map +1 -1
  96. package/dist/plugin/react-server/createSsrHandler.js +5 -12
  97. package/dist/plugin/react-server/index.js +18 -9
  98. package/dist/plugin/react-server/index.js.map +1 -0
  99. package/dist/plugin/react-server/plugin.d.ts.map +1 -1
  100. package/dist/plugin/react-server/plugin.js +147 -137
  101. package/dist/plugin/react-server/plugin.js.map +1 -1
  102. package/dist/plugin/transformer/plugin.d.ts +2 -1
  103. package/dist/plugin/transformer/plugin.d.ts.map +1 -1
  104. package/dist/plugin/transformer/plugin.js +68 -75
  105. package/dist/plugin/transformer/plugin.js.map +1 -1
  106. package/dist/plugin/transformer/types.d.ts +4 -0
  107. package/dist/plugin/transformer/types.d.ts.map +1 -1
  108. package/dist/plugin/types.d.ts +56 -20
  109. package/dist/plugin/types.d.ts.map +1 -1
  110. package/dist/plugin/utils/logger.d.ts +9 -0
  111. package/dist/plugin/utils/logger.d.ts.map +1 -0
  112. package/dist/plugin/utils/logger.js +68 -0
  113. package/dist/plugin/utils/logger.js.map +1 -0
  114. package/dist/plugin/worker/createWorker.d.ts +1 -0
  115. package/dist/plugin/worker/createWorker.d.ts.map +1 -1
  116. package/dist/plugin/worker/createWorker.js +23 -36
  117. package/dist/plugin/worker/createWorker.js.map +1 -1
  118. package/dist/plugin/worker/html/html-worker.production.js +5 -1
  119. package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
  120. package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
  121. package/dist/plugin/worker/html/messageHandler.js +33 -28
  122. package/dist/plugin/worker/html/messageHandler.js.map +1 -1
  123. package/dist/plugin/worker/html/plugin.d.ts.map +1 -1
  124. package/dist/plugin/worker/html/plugin.js +10 -5
  125. package/dist/plugin/worker/html/renderPages.d.ts +7 -6
  126. package/dist/plugin/worker/html/renderPages.d.ts.map +1 -1
  127. package/dist/plugin/worker/html/renderPages.js +147 -93
  128. package/dist/plugin/worker/html/renderPages.js.map +1 -1
  129. package/dist/plugin/worker/loader.d.ts +1 -11
  130. package/dist/plugin/worker/loader.d.ts.map +1 -1
  131. package/dist/plugin/worker/loader.js +2 -2
  132. package/dist/plugin/worker/loader.js.map +1 -1
  133. package/dist/plugin/worker/plugin.d.ts +10 -1
  134. package/dist/plugin/worker/plugin.d.ts.map +1 -1
  135. package/dist/plugin/worker/plugin.js +10 -1
  136. package/dist/plugin/worker/rsc/index.d.ts +1 -3
  137. package/dist/plugin/worker/rsc/index.d.ts.map +1 -1
  138. package/dist/plugin/worker/rsc/index.js +1 -9
  139. package/dist/plugin/worker/rsc/index.js.map +1 -1
  140. package/dist/plugin/worker/rsc/messageHandler.d.ts +3 -0
  141. package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -0
  142. package/dist/plugin/worker/rsc/messageHandler.js +107 -0
  143. package/dist/plugin/worker/rsc/messageHandler.js.map +1 -0
  144. package/dist/plugin/worker/rsc/plugin.d.ts.map +1 -1
  145. package/dist/plugin/worker/rsc/plugin.js +74 -80
  146. package/dist/plugin/worker/rsc/rsc-worker.development.d.ts +32 -0
  147. package/dist/plugin/worker/rsc/rsc-worker.development.d.ts.map +1 -0
  148. package/dist/plugin/worker/rsc/rsc-worker.development.js +43 -0
  149. package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -0
  150. package/dist/plugin/worker/rsc/rsc-worker.js +4 -106
  151. package/dist/plugin/worker/rsc/rsc-worker.production.d.ts +2 -0
  152. package/dist/plugin/worker/rsc/rsc-worker.production.d.ts.map +1 -0
  153. package/dist/plugin/worker/rsc/rsc-worker.production.js +14 -0
  154. package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -0
  155. package/dist/plugin/worker/rsc/state.d.ts +11 -0
  156. package/dist/plugin/worker/rsc/state.d.ts.map +1 -0
  157. package/dist/plugin/worker/rsc/state.js +12 -0
  158. package/dist/plugin/worker/rsc/state.js.map +1 -0
  159. package/dist/plugin/worker/types.d.ts +62 -35
  160. package/dist/plugin/worker/types.d.ts.map +1 -1
  161. package/dist/server.d.ts +1 -3
  162. package/dist/server.d.ts.map +1 -1
  163. package/dist/server.js +1 -3
  164. package/dist/server.js.map +1 -1
  165. package/dist/tsconfig.tsbuildinfo +1 -1
  166. package/package.json +16 -14
  167. package/plugin/assertServerCondition.ts +2 -3
  168. package/plugin/checkFilesExist.ts +46 -66
  169. package/plugin/collect-css-manifest.ts +5 -1
  170. package/plugin/config/createModuleIdGenerator.ts +52 -0
  171. package/plugin/config/defaults.ts +27 -20
  172. package/plugin/config/resolveOptions.ts +311 -25
  173. package/plugin/config/resolvePages.ts +1 -1
  174. package/plugin/config/resolveUserConfig.ts +195 -61
  175. package/plugin/helpers/getBundleManifest.ts +113 -0
  176. package/plugin/helpers/inputNormalizer.ts +186 -25
  177. package/plugin/helpers/tryManifest.ts +3 -1
  178. package/plugin/loader/createBuildLoader.ts +50 -9
  179. package/plugin/loader/createPageLoader.ts +1 -7
  180. package/plugin/loader/css-loader.ts +96 -0
  181. package/plugin/loader/react-loader.ts +945 -0
  182. package/plugin/loader/rsc/messageHandler.tsx +1 -0
  183. package/plugin/loader/rsc/rsc-worker.development.ts +1 -0
  184. package/plugin/plugin.ts +2 -1
  185. package/plugin/preserver/plugin.ts +2 -1
  186. package/plugin/react-client/index.ts +12 -1
  187. package/plugin/react-client/plugin.ts +351 -11
  188. package/plugin/react-server/createHandler.ts +16 -18
  189. package/plugin/react-server/createRscStream.ts +75 -42
  190. package/plugin/react-server/createSsrHandler.ts +7 -26
  191. package/plugin/react-server/plugin.ts +192 -155
  192. package/plugin/transformer/plugin.ts +70 -104
  193. package/plugin/transformer/types.ts +4 -0
  194. package/plugin/types/global.d.ts +8 -0
  195. package/plugin/types.ts +120 -64
  196. package/plugin/utils/logger.ts +52 -0
  197. package/plugin/worker/createWorker.ts +43 -44
  198. package/plugin/worker/html/html-worker.production.tsx +7 -2
  199. package/plugin/worker/html/messageHandler.ts +42 -35
  200. package/plugin/worker/html/plugin.ts +15 -11
  201. package/plugin/worker/html/renderPages.ts +177 -123
  202. package/plugin/worker/loader.ts +4 -13
  203. package/plugin/worker/plugin.ts +10 -1
  204. package/plugin/worker/rsc/index.ts +4 -13
  205. package/plugin/worker/rsc/messageHandler.tsx +143 -0
  206. package/plugin/worker/rsc/plugin.ts +38 -37
  207. package/plugin/worker/rsc/rsc-worker.development.ts +107 -0
  208. package/plugin/worker/rsc/rsc-worker.production.ts +13 -0
  209. package/plugin/worker/rsc/rsc-worker.tsx +5 -128
  210. package/plugin/worker/rsc/state.ts +37 -0
  211. package/plugin/worker/types.ts +83 -38
  212. package/scripts/check-react-version.mjs +17 -7
  213. package/scripts/react+0.0.0-experimental-b3a95caf-20250113.patch +143 -4170
  214. package/scripts/react-dom+0.0.0-experimental-b3a95caf-20250113.patch +14271 -90079
  215. package/dist/node_modules/magic-string/dist/magic-string.es.js +0 -1283
  216. package/dist/node_modules/magic-string/dist/magic-string.es.js.map +0 -1
  217. package/dist/plugin/build/createClientBuildConfig.d.ts +0 -3
  218. package/dist/plugin/build/createClientBuildConfig.d.ts.map +0 -1
  219. package/dist/plugin/build/createClientBuildConfig.js +0 -14
  220. package/dist/plugin/build/createServerBuildConfig.d.ts +0 -12
  221. package/dist/plugin/build/createServerBuildConfig.d.ts.map +0 -1
  222. package/dist/plugin/build/createServerBuildConfig.js +0 -40
  223. package/dist/plugin/build/createSharedBuildConfig.d.ts +0 -5
  224. package/dist/plugin/build/createSharedBuildConfig.d.ts.map +0 -1
  225. package/dist/plugin/build/createSharedBuildConfig.js +0 -28
  226. package/dist/plugin/build/mergeInputs.d.ts +0 -9
  227. package/dist/plugin/build/mergeInputs.d.ts.map +0 -1
  228. package/dist/plugin/build/mergeInputs.js +0 -56
  229. package/dist/plugin/components.js.map +0 -1
  230. package/dist/plugin/config/moduleIdDefault.d.ts +0 -8
  231. package/dist/plugin/config/moduleIdDefault.d.ts.map +0 -1
  232. package/dist/plugin/config/moduleIdDefault.js +0 -23
  233. package/dist/plugin/config/moduleIdDefault.js.map +0 -1
  234. package/dist/plugin/helpers/createClientInputNormalizer.d.ts +0 -8
  235. package/dist/plugin/helpers/createClientInputNormalizer.d.ts.map +0 -1
  236. package/dist/plugin/helpers/createClientInputNormalizer.js +0 -35
  237. package/dist/plugin/helpers/createServerInputNormalizer.d.ts +0 -9
  238. package/dist/plugin/helpers/createServerInputNormalizer.d.ts.map +0 -1
  239. package/dist/plugin/helpers/createServerInputNormalizer.js +0 -37
  240. package/dist/plugin/helpers/createStaticInputNormalizer.d.ts +0 -7
  241. package/dist/plugin/helpers/createStaticInputNormalizer.d.ts.map +0 -1
  242. package/dist/plugin/helpers/createStaticInputNormalizer.js +0 -18
  243. package/dist/plugin/helpers/getModuleManifest.d.ts +0 -12
  244. package/dist/plugin/helpers/getModuleManifest.d.ts.map +0 -1
  245. package/dist/plugin/helpers/getModuleManifest.js +0 -24
  246. package/dist/plugin/helpers/getModuleManifest.js.map +0 -1
  247. package/dist/plugin/helpers/inputNormalizerWorker.d.ts +0 -11
  248. package/dist/plugin/helpers/inputNormalizerWorker.d.ts.map +0 -1
  249. package/dist/plugin/helpers/inputNormalizerWorker.js +0 -30
  250. package/dist/plugin/helpers/normalizedRelativePath.d.ts +0 -11
  251. package/dist/plugin/helpers/normalizedRelativePath.d.ts.map +0 -1
  252. package/dist/plugin/helpers/normalizedRelativePath.js +0 -36
  253. package/dist/plugin/helpers/resolveFilePath.d.ts +0 -13
  254. package/dist/plugin/helpers/resolveFilePath.d.ts.map +0 -1
  255. package/dist/plugin/helpers/resolveFilePath.js +0 -74
  256. package/dist/plugin/helpers/resolveWorkerModule.d.ts +0 -6
  257. package/dist/plugin/helpers/resolveWorkerModule.d.ts.map +0 -1
  258. package/dist/plugin/helpers/resolveWorkerModule.js +0 -24
  259. package/dist/plugin/helpers/validateModuleBase.d.ts +0 -3
  260. package/dist/plugin/helpers/validateModuleBase.d.ts.map +0 -1
  261. package/dist/plugin/helpers/validateModuleBase.js +0 -16
  262. package/dist/plugin/helpers/validateResolvedConfig.d.ts +0 -3
  263. package/dist/plugin/helpers/validateResolvedConfig.d.ts.map +0 -1
  264. package/dist/plugin/helpers/validateResolvedConfig.js +0 -17
  265. package/dist/plugin/react-server/createDevMiddleware.d.ts +0 -8
  266. package/dist/plugin/react-server/createDevMiddleware.d.ts.map +0 -1
  267. package/dist/plugin/react-server/createDevMiddleware.js +0 -68
  268. package/dist/plugin/react-server/createDevServer.d.ts +0 -4
  269. package/dist/plugin/react-server/createDevServer.d.ts.map +0 -1
  270. package/dist/plugin/react-server/createDevServer.js +0 -4
  271. package/dist/plugin/react-server/createReactNodeStreamer.d.ts +0 -10
  272. package/dist/plugin/react-server/createReactNodeStreamer.d.ts.map +0 -1
  273. package/dist/plugin/react-server/createReactNodeStreamer.js +0 -7
  274. package/dist/plugin/transformer/transformer-client-components.d.ts +0 -21
  275. package/dist/plugin/transformer/transformer-client-components.d.ts.map +0 -1
  276. package/dist/plugin/transformer/transformer-client-components.js +0 -61
  277. package/dist/plugin/transformer/transformer-client-components.js.map +0 -1
  278. package/dist/plugin/transformer/transformer-server-actions.d.ts +0 -29
  279. package/dist/plugin/transformer/transformer-server-actions.d.ts.map +0 -1
  280. package/dist/plugin/transformer/transformer-server-actions.js +0 -76
  281. package/dist/plugin/transformer/transformer-server-actions.js.map +0 -1
  282. package/dist/plugin/worker/rsc/createRscStream.d.ts +0 -5
  283. package/dist/plugin/worker/rsc/createRscStream.d.ts.map +0 -1
  284. package/dist/plugin/worker/rsc/createRscStream.js +0 -39
  285. package/dist/plugin/worker/rsc/createRscStream.js.map +0 -1
  286. package/dist/plugin/worker/rsc/development.d.ts +0 -5
  287. package/dist/plugin/worker/rsc/development.d.ts.map +0 -1
  288. package/dist/plugin/worker/rsc/development.js +0 -13
  289. package/dist/plugin/worker/rsc/development.js.map +0 -1
  290. package/dist/plugin/worker/rsc/plugin.js.map +0 -1
  291. package/dist/plugin/worker/rsc/production.d.ts +0 -5
  292. package/dist/plugin/worker/rsc/production.d.ts.map +0 -1
  293. package/dist/plugin/worker/rsc/production.js +0 -13
  294. package/dist/plugin/worker/rsc/production.js.map +0 -1
  295. package/plugin/build/createClientBuildConfig.ts +0 -21
  296. package/plugin/build/createServerBuildConfig.ts +0 -66
  297. package/plugin/build/createSharedBuildConfig.ts +0 -35
  298. package/plugin/build/mergeInputs.ts +0 -58
  299. package/plugin/config/moduleIdDefault.ts +0 -23
  300. package/plugin/helpers/createClientInputNormalizer.ts +0 -48
  301. package/plugin/helpers/createServerInputNormalizer.ts +0 -52
  302. package/plugin/helpers/createStaticInputNormalizer.ts +0 -26
  303. package/plugin/helpers/getModuleManifest.ts +0 -31
  304. package/plugin/helpers/inputNormalizerWorker.ts +0 -47
  305. package/plugin/helpers/normalizedRelativePath.ts +0 -59
  306. package/plugin/helpers/resolveFilePath.ts +0 -108
  307. package/plugin/helpers/resolveWorkerModule.ts +0 -41
  308. package/plugin/helpers/validateModuleBase.ts +0 -30
  309. package/plugin/helpers/validateResolvedConfig.ts +0 -21
  310. package/plugin/react-server/createDevMiddleware.ts +0 -91
  311. package/plugin/react-server/createDevServer.ts +0 -9
  312. package/plugin/react-server/createReactNodeStreamer.ts +0 -26
  313. package/plugin/transformer/transformer-client-components.ts +0 -94
  314. package/plugin/transformer/transformer-server-actions.ts +0 -110
  315. package/plugin/worker/rsc/createRscStream.ts +0 -42
  316. package/plugin/worker/rsc/development.ts +0 -6
  317. package/plugin/worker/rsc/production.ts +0 -6
  318. package/scripts/react-server-dom-esm+0.0.1.patch +0 -24775
@@ -1,11 +0,0 @@
1
- import type { Worker } from "node:worker_threads";
2
- import type { InputNormalizerWorker } from "../types.js";
3
- interface WorkerNormalizerOptions {
4
- root: string;
5
- moduleBase: string;
6
- worker: Worker;
7
- moduleBaseExceptions?: string[];
8
- }
9
- export declare function createInputNormalizerWorker({ root, worker, }: WorkerNormalizerOptions): InputNormalizerWorker;
10
- export {};
11
- //# sourceMappingURL=inputNormalizerWorker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inputNormalizerWorker.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/inputNormalizerWorker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAmB,MAAM,aAAa,CAAC;AAG1E,UAAU,uBAAuB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC;AAED,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,EACJ,MAAM,GACP,EAAE,uBAAuB,GAAG,qBAAqB,CAgCjD"}
@@ -1,30 +0,0 @@
1
- import { createInputNormalizer } from "./inputNormalizer.js";
2
- export function createInputNormalizerWorker({ root, worker, }) {
3
- const baseNormalizer = createInputNormalizer(root);
4
- return async (input) => {
5
- // Handle React components specially with worker
6
- if (typeof input === "function") {
7
- return new Promise((resolve, reject) => {
8
- const handler = (message) => {
9
- if (message.type === "CLIENT_REFERENCE") {
10
- worker.off('message', handler);
11
- resolve([message.ref.$$id, message.ref.$$location]);
12
- }
13
- if (message.type === "ERROR") {
14
- worker.off('message', handler);
15
- reject(new Error(message.error));
16
- }
17
- };
18
- worker.on('message', handler);
19
- worker.postMessage({
20
- type: "CLIENT_REFERENCE",
21
- id: input.name || 'AnonymousComponent',
22
- location: input.toString(),
23
- key: input.name
24
- });
25
- });
26
- }
27
- // For all other types, use the base normalizer
28
- return baseNormalizer(input);
29
- };
30
- }
@@ -1,11 +0,0 @@
1
- type NormalizedRelativePathOptions = {
2
- root: string;
3
- outDir: string;
4
- moduleBase: string;
5
- noLeadingSlash: boolean;
6
- noTrailingSlash: boolean;
7
- moduleBaseExceptions: string[];
8
- };
9
- export declare const createNormalizedRelativePath: (options?: NormalizedRelativePathOptions) => (path: string) => string;
10
- export {};
11
- //# sourceMappingURL=normalizedRelativePath.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalizedRelativePath.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/normalizedRelativePath.ts"],"names":[],"mappings":"AAEA,KAAK,6BAA6B,GAAG;IAEnC,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,EAAE,MAAM,CAAC;IAEnB,cAAc,EAAE,OAAO,CAAC;IAExB,eAAe,EAAE,OAAO,CAAC;IAEzB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,4BAA4B,aAC9B,6BAA6B,YAuCxB,MAAM,WACrB,CAAC"}
@@ -1,36 +0,0 @@
1
- import { normalizePath } from "vite";
2
- export const createNormalizedRelativePath = (options = {
3
- root: process.cwd(),
4
- outDir: "dist",
5
- moduleBase: "src",
6
- noLeadingSlash: false,
7
- noTrailingSlash: false,
8
- moduleBaseExceptions: [],
9
- }) => {
10
- let base = options.noLeadingSlash && options.moduleBase.startsWith("/")
11
- ? options.moduleBase.slice(1)
12
- : options.moduleBase;
13
- if (options.noTrailingSlash && base.endsWith("/")) {
14
- base = base.slice(0, -1);
15
- }
16
- const removeOutDir = (path) => options.outDir === path
17
- ? path.slice(options.outDir.length)
18
- : path;
19
- const removeRoot = (path) => {
20
- const relative = path.startsWith(options.root)
21
- ? path.slice(options.root.length)
22
- : path;
23
- return relative;
24
- };
25
- const ensureModuleBase = (path) => {
26
- let transformed = path;
27
- if (options.noLeadingSlash && path.startsWith("/")) {
28
- transformed = path.slice(1);
29
- }
30
- if (options.noTrailingSlash && transformed.endsWith("/")) {
31
- transformed = transformed.slice(0, -1);
32
- }
33
- return transformed;
34
- };
35
- return (path) => ensureModuleBase(removeOutDir(removeRoot(normalizePath(path))));
36
- };
@@ -1,13 +0,0 @@
1
- type ResolveOptions = {
2
- projectRoot?: string;
3
- nodePath?: string;
4
- pluginRoot?: string;
5
- filePath: string;
6
- subDir?: string;
7
- normalize?: boolean;
8
- distDir?: string;
9
- mode?: "production" | "development" | "test";
10
- };
11
- export declare function resolveFilePath({ projectRoot, nodePath, mode, pluginRoot, distDir, filePath, subDir, normalize, }: ResolveOptions): Promise<string>;
12
- export {};
13
- //# sourceMappingURL=resolveFilePath.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveFilePath.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/resolveFilePath.ts"],"names":[],"mappings":"AAMA,KAAK,cAAc,GAAG;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,YAAY,GAAG,aAAa,GAAG,MAAM,CAAC;CAC9C,CAAC;AAEF,wBAAsB,eAAe,CAAC,EACpC,WAA2B,EAC3B,QAAmC,EACnC,IAAgB,EAChB,UAA4B,EAC5B,OAA0B,EAC1B,QAAQ,EACR,MAAM,EACN,SAAiB,GAClB,EAAE,cAAc,mBAiFhB"}
@@ -1,74 +0,0 @@
1
- import { join, basename } from "node:path";
2
- import { access, realpath } from "node:fs/promises";
3
- import { normalizePath } from "vite";
4
- import { getDistDir, getMode, getNodePath, getPluginRoot } from "../config/getPaths.js";
5
- import pkg from "../../package.json" with { type: 'json' };
6
- export async function resolveFilePath({ projectRoot = process.cwd(), nodePath = getNodePath(projectRoot), mode = getMode(), pluginRoot = getPluginRoot(), distDir = getDistDir(mode), filePath, subDir, normalize = false, }) {
7
- try {
8
- let resolvedPath;
9
- // Helper to check if file exists
10
- const exists = async (path) => {
11
- try {
12
- await access(path);
13
- return true;
14
- }
15
- catch {
16
- return false;
17
- }
18
- };
19
- // If it's a plugin export (like '/rsc-worker'), use exports map
20
- if (filePath.startsWith('/') && filePath.slice(1) in pkg.exports) {
21
- const exportPath = filePath.slice(1);
22
- const pluginPath = pkg.exports[exportPath];
23
- return join(process.cwd(), pluginRoot, pluginPath); // Make absolute
24
- }
25
- // In test mode, preserve relative paths
26
- if (mode === 'test' && !filePath.startsWith('/')) {
27
- return filePath;
28
- }
29
- // For all other paths, try relative to project root first
30
- const projectPath = join(projectRoot, filePath);
31
- if (await exists(projectPath)) {
32
- return normalize ? normalizePath(projectPath) : projectPath;
33
- }
34
- // 1. Try dist folder
35
- const distPath = join(distDir, subDir ?? '', basename(filePath));
36
- if (await exists(distPath)) {
37
- resolvedPath = await realpath(distPath);
38
- }
39
- // 2. Try node_modules path
40
- if (!resolvedPath && filePath.startsWith('/node_modules/')) {
41
- const npmPath = join(nodePath, filePath.slice('/node_modules/'.length));
42
- if (await exists(npmPath)) {
43
- resolvedPath = await realpath(npmPath);
44
- }
45
- }
46
- // 3. Try direct path
47
- if (!resolvedPath && await exists(filePath)) {
48
- resolvedPath = await realpath(filePath);
49
- }
50
- // 4. Try relative to project root
51
- if (!resolvedPath) {
52
- const projectPath = join(projectRoot, filePath);
53
- if (await exists(projectPath)) {
54
- resolvedPath = await realpath(projectPath);
55
- }
56
- }
57
- if (!resolvedPath) {
58
- throw new Error(`Could not resolve path. Tried:\n` +
59
- `- ${distPath}\n` +
60
- `- ${join(nodePath, filePath.slice('/node_modules/'.length))}\n` +
61
- `- ${filePath}\n` +
62
- `- ${join(projectRoot, filePath)}`);
63
- }
64
- return normalize ? normalizePath(resolvedPath
65
- .replace(pluginRoot, "/node_modules/vite-plugin-react-server")
66
- .replace(projectRoot, "/")
67
- .replace(nodePath, "/node_modules")
68
- .replace(/^(?!\/)/, '/')) : resolvedPath;
69
- }
70
- catch (error) {
71
- // If realpath fails, return normalized input path
72
- return normalize ? normalizePath(filePath) : filePath;
73
- }
74
- }
@@ -1,6 +0,0 @@
1
- export declare function resolveWorkerModule(moduleGraph: Set<string> | string[], options: {
2
- root: string;
3
- outDir: string;
4
- workerPath: string;
5
- }): Promise<string>;
6
- //# sourceMappingURL=resolveWorkerModule.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveWorkerModule.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/resolveWorkerModule.ts"],"names":[],"mappings":"AAEA,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,EACnC,OAAO,EAAE;IACP,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAA;CACnB,mBAgCF"}
@@ -1,24 +0,0 @@
1
- import { tryManifest } from "./tryManifest.js";
2
- export async function resolveWorkerModule(moduleGraph, options) {
3
- console.log('Resolving worker module:', {
4
- moduleGraph: Array.from(moduleGraph),
5
- options
6
- });
7
- // Try module graph first
8
- const workerModule = Array.from(moduleGraph).find(id => id.includes(options.workerPath));
9
- console.log('Found in module graph:', workerModule);
10
- if (workerModule) {
11
- return workerModule;
12
- }
13
- // Fallback to manifest
14
- const resolvedManifest = tryManifest({
15
- root: options.root,
16
- outDir: options.outDir,
17
- ssrManifest: false
18
- });
19
- console.log('Manifest result:', resolvedManifest);
20
- if (resolvedManifest.type === "error") {
21
- throw new Error(`Could not find worker path in module graph or manifest: ${options.workerPath}`);
22
- }
23
- return resolvedManifest.manifest[options.workerPath]?.file;
24
- }
@@ -1,3 +0,0 @@
1
- import type { InputOption } from "rollup";
2
- export declare function validateModuleBase(input: InputOption, moduleBase: string, moduleBaseExceptions: string[]): void;
3
- //# sourceMappingURL=validateModuleBase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validateModuleBase.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/validateModuleBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE1C,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,WAAW,EAClB,UAAU,EAAE,MAAM,EAClB,oBAAoB,EAAE,MAAM,EAAE,QAwB/B"}
@@ -1,16 +0,0 @@
1
- export function validateModuleBase(input, moduleBase, moduleBaseExceptions) {
2
- for (const [key, value] of Object.entries(input)) {
3
- const isException = moduleBaseExceptions.includes(key) || ["/index", "index"].includes(key);
4
- if (!key.includes("/"))
5
- return;
6
- if (value.startsWith("//")) {
7
- throw new Error(`Path shouldn't start with //`);
8
- }
9
- if (!key.startsWith(moduleBase) && !isException) {
10
- throw new Error(`Invalid input: ${key} does not start with ${moduleBase}. If this is a valid key, add it to moduleBaseExceptions otherwise put the file in the ${moduleBase} directory. Exception: ${moduleBaseExceptions.join(", ")}`);
11
- }
12
- if (!value.startsWith("/" + moduleBase) && !isException) {
13
- throw new Error(`Invalid value: ${value} does not start with ${moduleBase}. If this is a valid path, add it to moduleBaseExceptions otherwise put the file in the ${moduleBase} directory. Exception: ${moduleBaseExceptions.join(", ")}`);
14
- }
15
- }
16
- }
@@ -1,3 +0,0 @@
1
- import type { ResolvedConfig } from "vite";
2
- export declare function validateResolvedConfig(config: ResolvedConfig): asserts config is ResolvedConfig;
3
- //# sourceMappingURL=validateResolvedConfig.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validateResolvedConfig.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/validateResolvedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE3C,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,IAAI,cAAc,CAiB7F"}
@@ -1,17 +0,0 @@
1
- export function validateResolvedConfig(config) {
2
- if (typeof config === "object" &&
3
- config != null &&
4
- "build" in config &&
5
- typeof config.build === "object" &&
6
- config.build != null &&
7
- "rollupOptions" in config.build &&
8
- typeof config.build.rollupOptions === "object" &&
9
- config.build.rollupOptions != null &&
10
- "input" in config.build.rollupOptions &&
11
- typeof config.build.rollupOptions.input === "object" &&
12
- config.build.rollupOptions.input != null) {
13
- return undefined;
14
- }
15
- throw new Error("Invalid config");
16
- }
17
- ;
@@ -1,8 +0,0 @@
1
- import type { ViteDevServer } from "vite";
2
- import { type RequestHandler, type StreamPluginOptions } from "../types.js";
3
- export type DevMiddlewareOptions = Required<Pick<StreamPluginOptions, "moduleBase" | "moduleBasePath" | "moduleBaseURL" | "projectRoot">> & Pick<StreamPluginOptions, "Page" | "props" | "build" | "Html" | "pageExportName" | "propsExportName">;
4
- /**
5
- * Creates a request handler for development
6
- */
7
- export declare function createDevMiddleware(server: ViteDevServer, options: DevMiddlewareOptions): RequestHandler;
8
- //# sourceMappingURL=createDevMiddleware.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createDevMiddleware.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/createDevMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAG5E,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CACzC,IAAI,CACF,mBAAmB,EACnB,YAAY,GAAG,gBAAgB,GAAG,eAAe,GAAG,aAAa,CAClE,CACF,GACC,IAAI,CAAC,mBAAmB,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,gBAAgB,GAAG,iBAAiB,CAAC,CAAC;AAExG;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,oBAAoB,GAC5B,cAAc,CAuEhB"}
@@ -1,68 +0,0 @@
1
- import { IncomingMessage, ServerResponse } from "http";
2
- import {} from "../types.js";
3
- import { createHandler } from "./createHandler.js";
4
- /**
5
- * Creates a request handler for development
6
- */
7
- export function createDevMiddleware(server, options) {
8
- // Add HMR support
9
- const hmr = server.hot;
10
- hmr?.on('vite:beforeUpdate', () => {
11
- // Clear module cache before updates
12
- server.moduleGraph.invalidateAll();
13
- });
14
- return async (req, res, next) => {
15
- // Skip non-page requests
16
- if (!req.url ||
17
- (req.url.includes(".") && !req.url.endsWith("/index.rsc"))) {
18
- return next();
19
- }
20
- const url = req.url.endsWith("/index.rsc")
21
- ? req.url.replace("/index.rsc", "/")
22
- : req.url;
23
- try {
24
- console.log("[stream] Handling RSC stream");
25
- const result = await createHandler(url, options, {
26
- loader: (id) => {
27
- const mod = server.ssrLoadModule(id);
28
- if (!mod) {
29
- throw new Error(`[RSC] Module not found: ${id}`);
30
- }
31
- else {
32
- console.log('[RSC] Loaded module:', id);
33
- }
34
- return mod;
35
- },
36
- moduleGraph: server.moduleGraph,
37
- });
38
- if (result.type === "error") {
39
- if (result.error.message?.includes("module runner has been closed")) {
40
- console.log("[RSC] Module runner closed, returning 503");
41
- res.writeHead(503, { "Content-Type": "text/x-component" });
42
- res.end('{"error":"Server restarting..."}');
43
- return;
44
- }
45
- console.error("[RSC] Stream error:", result.error);
46
- res.writeHead(500, { "Content-Type": "text/x-component" });
47
- res.end('{"error":"Internal Server Error"}');
48
- return;
49
- }
50
- if (result.type !== "success") {
51
- res.end();
52
- return;
53
- }
54
- res.setHeader("Content-Type", "text/x-component");
55
- if (result.stream)
56
- result.stream.pipe(res);
57
- }
58
- catch (error) {
59
- if (error.message?.includes("module runner has been closed")) {
60
- console.log("[RSC] Module runner closed, returning 503");
61
- res.writeHead(503, { "Content-Type": "text/x-component" });
62
- res.end('{"error":"Server restarting..."}');
63
- return;
64
- }
65
- next(error);
66
- }
67
- };
68
- }
@@ -1,4 +0,0 @@
1
- import type { ViteDevServer } from "vite";
2
- import { type DevMiddlewareOptions } from "./createDevMiddleware.js";
3
- export declare function createDevServer(server: ViteDevServer, options: DevMiddlewareOptions): void;
4
- //# sourceMappingURL=createDevServer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createDevServer.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/createDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAE1F,wBAAgB,eAAe,CAC7B,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,oBAAoB,QAG9B"}
@@ -1,4 +0,0 @@
1
- import { createDevMiddleware } from "./createDevMiddleware.js";
2
- export function createDevServer(server, options) {
3
- server.middlewares.use(createDevMiddleware(server, options));
4
- }
@@ -1,10 +0,0 @@
1
- import React from "react";
2
- import { type CreateFromNodeStreamOptions } from "react-server-dom-esm/client.node";
3
- import type { Readable } from "stream";
4
- export declare function createReactNodeStreamer({ stream, moduleBasePath, moduleBaseURL, options, }: {
5
- stream: Readable;
6
- moduleBasePath: string;
7
- moduleBaseURL: string;
8
- options?: CreateFromNodeStreamOptions;
9
- }): React.Usable<React.ReactNode>;
10
- //# sourceMappingURL=createReactNodeStreamer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createReactNodeStreamer.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/createReactNodeStreamer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAEL,KAAK,2BAA2B,EAEjC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC,wBAAgB,uBAAuB,CAAC,EACtC,MAAM,EACN,cAAc,EACd,aAAa,EACb,OAAO,GACR,EAAE;IACD,MAAM,EAAE,QAAQ,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,2BAA2B,CAAC;CACvC,GAMM,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CACnC"}
@@ -1,7 +0,0 @@
1
- import React from "react";
2
- import { createFromNodeStream,
3
- // @ts-ignore
4
- } from "react-server-dom-esm/client.node";
5
- export function createReactNodeStreamer({ stream, moduleBasePath, moduleBaseURL, options, }) {
6
- return createFromNodeStream(stream, moduleBasePath, moduleBaseURL, options);
7
- }
@@ -1,21 +0,0 @@
1
- import type { Plugin as RollupPlugin } from "rollup";
2
- import type { TransformerOptions } from "./types.js";
3
- export declare function createClientComponentTransformer({ moduleId: userModuleId, }: TransformerOptions): RollupPlugin;
4
- /**
5
- * transformedCode += `
6
- const ${exportName}Ref = Object.defineProperties(
7
- ${
8
- isClass
9
- ? `class extends ${exportName} {
10
- constructor(...args) { super(...args); }
11
- }`
12
- : `function(...args) { return ${exportName}.apply(null, args); }`
13
- },
14
- {
15
- $$typeof: { value: Symbol.for("react.client.reference") },
16
- $$id: { value: ${JSON.stringify(moduleId + "#" + exportName)} }
17
- }
18
- );
19
- export { ${exportName}Ref as ${exportName} };`;
20
- */
21
- //# sourceMappingURL=transformer-client-components.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformer-client-components.d.ts","sourceRoot":"","sources":["../../../plugin/transformer/transformer-client-components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,gCAAgC,CAAC,EAC/C,QAAQ,EAAE,YAAY,GACvB,EAAE,kBAAkB,GAAG,YAAY,CAsEnC;AAED;;;;;;;;;;;;;;;;GAgBG"}
@@ -1,61 +0,0 @@
1
- /**
2
- * vite-plugin-react-server
3
- * Copyright (c) Nico Brinkkemper
4
- * MIT License
5
- */
6
- function createClientComponentTransformer({
7
- moduleId: userModuleId
8
- }) {
9
- let moduleIdFn = userModuleId;
10
- return {
11
- name: "vite-plugin-react-server:client-components-transformer",
12
- async transform(code, id, options) {
13
- try {
14
- if (id.includes("node_modules") || id.includes("vite/dist")) {
15
- return null;
16
- }
17
- const info = this?.getModuleInfo(id);
18
- const hasDirective = code.match(/^["']use client["'];?/);
19
- const isClientComponent = hasDirective || info?.meta?.["directives"]?.includes("use client");
20
- if (!isClientComponent) {
21
- return null;
22
- }
23
- let transformedCode = code;
24
- const moduleId = moduleIdFn(id, options?.ssr ?? false);
25
- const exportMatches = Array.from(
26
- code.matchAll(/export\s+(?:const|let|var|function|class)\s+(\w+)/g)
27
- );
28
- if (!exportMatches.length) {
29
- return null;
30
- }
31
- for (const [fullMatch, exportName] of exportMatches) {
32
- if (!exportName) continue;
33
- const isClass = fullMatch.includes("class");
34
- transformedCode = transformedCode.replace(
35
- fullMatch,
36
- fullMatch.replace("export ", "")
37
- );
38
- transformedCode += `
39
- const ${exportName}Ref = Object.defineProperties(
40
- ${isClass ? `class extends ${exportName} {
41
- constructor(...args) { super(...args); }
42
- }` : `function(...args) { return ${exportName}.apply(null, args); }`},
43
- {
44
- $$typeof: { value: Symbol.for("react.client.reference") },
45
- $$id: { value: ${JSON.stringify(moduleId + "#" + exportName)} },
46
- $$filepath: { value: ${JSON.stringify(id)} }
47
- }
48
- );
49
- export { ${exportName}Ref as ${exportName} };`;
50
- }
51
- return { code: transformedCode, map: null };
52
- } catch (error) {
53
- console.error(`[RSC] Error transforming client component: ${id}`, error);
54
- throw error;
55
- }
56
- }
57
- };
58
- }
59
-
60
- export { createClientComponentTransformer };
61
- //# sourceMappingURL=transformer-client-components.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformer-client-components.js","sources":["../../../plugin/transformer/transformer-client-components.ts"],"sourcesContent":["import type { Plugin as RollupPlugin } from \"rollup\";\nimport type { TransformerOptions } from \"./types.js\";\n\nexport function createClientComponentTransformer({\n moduleId: userModuleId,\n}: TransformerOptions): RollupPlugin {\n let moduleIdFn = userModuleId;\n\n return {\n name: \"vite-plugin-react-server:client-components-transformer\",\n\n async transform(code: string, id: string, options?: { ssr?: boolean }) {\n try {\n // Skip node_modules and vite internal files\n if (id.includes('node_modules') || id.includes('vite/dist')) {\n return null;\n }\n\n // Check if this is a client component from metadata or directive\n const info = this?.getModuleInfo(id);\n const hasDirective = code.match(/^[\"']use client[\"'];?/);\n const isClientComponent = hasDirective || info?.meta?.['directives']?.includes('use client');\n\n if (!isClientComponent) {\n return null; // Not a client component, skip\n }\n\n let transformedCode = code;\n const moduleId = moduleIdFn!(id, options?.ssr ?? false);\n\n // Find all named exports\n const exportMatches = Array.from(\n code.matchAll(/export\\s+(?:const|let|var|function|class)\\s+(\\w+)/g)\n );\n\n if (!exportMatches.length) {\n return null;\n }\n\n // Transform each export\n for (const [fullMatch, exportName] of exportMatches) {\n if (!exportName) continue;\n\n const isClass = fullMatch.includes(\"class\");\n\n // Remove export keyword\n transformedCode = transformedCode.replace(\n fullMatch,\n fullMatch.replace(\"export \", \"\")\n );\n\n transformedCode += `\nconst ${exportName}Ref = Object.defineProperties(\n ${isClass \n ? `class extends ${exportName} {\n constructor(...args) { super(...args); }\n }`\n : `function(...args) { return ${exportName}.apply(null, args); }`\n },\n {\n $$typeof: { value: Symbol.for(\"react.client.reference\") },\n $$id: { value: ${JSON.stringify(moduleId + \"#\" + exportName)} },\n $$filepath: { value: ${JSON.stringify(id)} }\n }\n);\nexport { ${exportName}Ref as ${exportName} };`;\n }\n\n return { code: transformedCode, map: null };\n } catch (error) {\n console.error(`[RSC] Error transforming client component: ${id}`, error);\n throw error;\n }\n },\n };\n}\n\n/**\n * transformedCode += `\nconst ${exportName}Ref = Object.defineProperties(\n ${\n isClass\n ? `class extends ${exportName} {\n constructor(...args) { super(...args); }\n }`\n : `function(...args) { return ${exportName}.apply(null, args); }`\n },\n {\n $$typeof: { value: Symbol.for(\"react.client.reference\") },\n $$id: { value: ${JSON.stringify(moduleId + \"#\" + exportName)} }\n }\n);\nexport { ${exportName}Ref as ${exportName} };`;\n */\n"],"names":[],"mappings":";;;;;AAGO,SAAS,gCAAiC,CAAA;AAAA,EAC/C,QAAU,EAAA;AACZ,CAAqC,EAAA;AACnC,EAAA,IAAI,UAAa,GAAA,YAAA;AAEjB,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,wDAAA;AAAA,IAEN,MAAM,SAAA,CAAU,IAAc,EAAA,EAAA,EAAY,OAA6B,EAAA;AACrE,MAAI,IAAA;AAEF,QAAA,IAAI,GAAG,QAAS,CAAA,cAAc,KAAK,EAAG,CAAA,QAAA,CAAS,WAAW,CAAG,EAAA;AAC3D,UAAO,OAAA,IAAA;AAAA;AAIT,QAAM,MAAA,IAAA,GAAO,IAAM,EAAA,aAAA,CAAc,EAAE,CAAA;AACnC,QAAM,MAAA,YAAA,GAAe,IAAK,CAAA,KAAA,CAAM,uBAAuB,CAAA;AACvD,QAAA,MAAM,oBAAoB,YAAgB,IAAA,IAAA,EAAM,OAAO,YAAY,CAAA,EAAG,SAAS,YAAY,CAAA;AAE3F,QAAA,IAAI,CAAC,iBAAmB,EAAA;AACtB,UAAO,OAAA,IAAA;AAAA;AAGT,QAAA,IAAI,eAAkB,GAAA,IAAA;AACtB,QAAA,MAAM,QAAW,GAAA,UAAA,CAAY,EAAI,EAAA,OAAA,EAAS,OAAO,KAAK,CAAA;AAGtD,QAAA,MAAM,gBAAgB,KAAM,CAAA,IAAA;AAAA,UAC1B,IAAA,CAAK,SAAS,oDAAoD;AAAA,SACpE;AAEA,QAAI,IAAA,CAAC,cAAc,MAAQ,EAAA;AACzB,UAAO,OAAA,IAAA;AAAA;AAIT,QAAA,KAAA,MAAW,CAAC,SAAA,EAAW,UAAU,CAAA,IAAK,aAAe,EAAA;AACnD,UAAA,IAAI,CAAC,UAAY,EAAA;AAEjB,UAAM,MAAA,OAAA,GAAU,SAAU,CAAA,QAAA,CAAS,OAAO,CAAA;AAG1C,UAAA,eAAA,GAAkB,eAAgB,CAAA,OAAA;AAAA,YAChC,SAAA;AAAA,YACA,SAAA,CAAU,OAAQ,CAAA,SAAA,EAAW,EAAE;AAAA,WACjC;AAEA,UAAmB,eAAA,IAAA;AAAA,MAAA,EACrB,UAAU,CAAA;AAAA,EACd,EAAA,OAAA,GACE,iBAAiB,UAAU,CAAA;AAAA;AAAA,OAG3B,CAAA,GAAA,CAAA,2BAAA,EAA8B,UAAU,CAC5C,qBAAA,CAAA,CAAA;AAAA;AAAA;AAAA,mBAAA,EAGmB,IAAK,CAAA,SAAA,CAAU,QAAW,GAAA,GAAA,GAAM,UAAU,CAAC,CAAA;AAAA,yBACrC,EAAA,IAAA,CAAK,SAAU,CAAA,EAAE,CAAC,CAAA;AAAA;AAAA;AAAA,SAGlC,EAAA,UAAU,UAAU,UAAU,CAAA,GAAA,CAAA;AAAA;AAGjC,QAAA,OAAO,EAAE,IAAA,EAAM,eAAiB,EAAA,GAAA,EAAK,IAAK,EAAA;AAAA,eACnC,KAAO,EAAA;AACd,QAAA,OAAA,CAAQ,KAAM,CAAA,CAAA,2CAAA,EAA8C,EAAE,CAAA,CAAA,EAAI,KAAK,CAAA;AACvE,QAAM,MAAA,KAAA;AAAA;AACR;AACF,GACF;AACF;;;;"}
@@ -1,29 +0,0 @@
1
- import type { TransformerOptions } from "./types.js";
2
- export declare function createServerActionTransformer(options: TransformerOptions): {
3
- name: string;
4
- enforce: "post";
5
- transform(code: string, path: string, { ssr }?: {
6
- ssr: boolean;
7
- }): Promise<{
8
- code: string;
9
- map: string;
10
- } | null>;
11
- };
12
- /**
13
- * transformedCode += `
14
- const ${exportName}Ref = Object.defineProperties(
15
- ${
16
- isClass
17
- ? `class extends ${exportName} {
18
- constructor(...args) { super(...args); }
19
- }`
20
- : `function(...args) { return ${exportName}.apply(null, args); }`
21
- },
22
- {
23
- $$typeof: { value: Symbol.for("react.client.reference") },
24
- $$id: { value: ${JSON.stringify(moduleId + "#" + exportName)} }
25
- }
26
- );
27
- export { ${exportName}Ref as ${exportName} };`;
28
- */
29
- //# sourceMappingURL=transformer-server-actions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformer-server-actions.d.ts","sourceRoot":"","sources":["../../../plugin/transformer/transformer-server-actions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,kBAAkB;;;oBAM7D,MAAM,QACN,MAAM,YACH;QAAE,GAAG,EAAE,OAAO,CAAA;KAAE;;;;EAgF9B;AAED;;;;;;;;;;;;;;;;GAgBG"}
@@ -1,76 +0,0 @@
1
- /**
2
- * vite-plugin-react-server
3
- * Copyright (c) Nico Brinkkemper
4
- * MIT License
5
- */
6
- import { SourceMapGenerator } from 'source-map';
7
-
8
- function createServerActionTransformer(options) {
9
- return {
10
- name: "vite-plugin-react-server:server-actions-transformer",
11
- enforce: "post",
12
- async transform(code, path, { ssr } = { ssr: false }) {
13
- try {
14
- let transformedCode = code;
15
- const directiveMatch = code.match(/^["']use server["'];?/);
16
- const moduleId = options.moduleId(path, ssr);
17
- console.log("[RSC Transform] Module path transformation:", {
18
- original: path,
19
- transformed: moduleId
20
- });
21
- const exportMatches = Array.from(
22
- code.matchAll(/export\s+(?:const|let|var|function|class)\s+(\w+)/g)
23
- );
24
- if (!exportMatches.length) {
25
- console.warn(
26
- `[RSC] No exports found in server action module: ${path}`
27
- );
28
- return null;
29
- }
30
- for (const [fullMatch, exportName] of exportMatches) {
31
- if (!exportName) {
32
- console.warn(
33
- `[RSC] Invalid export in server action module: ${path}`
34
- );
35
- continue;
36
- }
37
- const isClass = fullMatch.includes("class");
38
- transformedCode = transformedCode.replace(
39
- fullMatch,
40
- fullMatch.replace("export ", "")
41
- );
42
- if (!directiveMatch || directiveMatch.index !== 0) {
43
- } else {
44
- transformedCode += `
45
- const ${exportName}Ref = Object.defineProperties(
46
- ${isClass ? `class extends ${exportName} {
47
- constructor(...args) { super(...args); }
48
- }` : `function(...args) { return ${exportName}.apply(null, args); }`},
49
- {
50
- $$typeof: { value: Symbol.for("react.server.reference") },
51
- $$id: { value: ${JSON.stringify(moduleId + "#" + exportName)} },
52
- $$filepath: { value: ${JSON.stringify(path)} },
53
- $$async: { value: true }
54
- }
55
- );
56
- export { ${exportName}Ref as ${exportName} };
57
- `;
58
- }
59
- }
60
- return {
61
- code: transformedCode,
62
- map: new SourceMapGenerator({ file: path }).toString()
63
- };
64
- } catch (error) {
65
- console.error(
66
- `[RSC] Error transforming client component: ${path}`,
67
- error
68
- );
69
- throw error;
70
- }
71
- }
72
- };
73
- }
74
-
75
- export { createServerActionTransformer };
76
- //# sourceMappingURL=transformer-server-actions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformer-server-actions.js","sources":["../../../plugin/transformer/transformer-server-actions.ts"],"sourcesContent":["import { SourceMapGenerator } from \"source-map\";\nimport type { TransformerOptions } from \"./types.js\";\n\nexport function createServerActionTransformer(options: TransformerOptions) {\n return {\n name: \"vite-plugin-react-server:server-actions-transformer\",\n enforce: \"post\" as const,\n\n async transform(\n code: string,\n path: string,\n { ssr }: { ssr: boolean } = { ssr: false }\n ) {\n try {\n let transformedCode = code;\n const directiveMatch = code.match(/^[\"']use server[\"'];?/);\n const moduleId = options.moduleId(path, ssr);\n\n // Log the path transformation\n console.log(\"[RSC Transform] Module path transformation:\", {\n original: path,\n transformed: moduleId,\n });\n\n // Find all named exports\n const exportMatches = Array.from(\n code.matchAll(/export\\s+(?:const|let|var|function|class)\\s+(\\w+)/g)\n );\n\n if (!exportMatches.length) {\n console.warn(\n `[RSC] No exports found in server action module: ${path}`\n );\n return null;\n }\n\n // Transform each export\n for (const [fullMatch, exportName] of exportMatches) {\n if (!exportName) {\n console.warn(\n `[RSC] Invalid export in server action module: ${path}`\n );\n continue;\n }\n\n const isClass = fullMatch.includes(\"class\");\n\n // Remove export keyword\n transformedCode = transformedCode.replace(\n fullMatch,\n fullMatch.replace(\"export \", \"\")\n );\n\n if (!directiveMatch || directiveMatch.index !== 0) {\n // Server action\n } else {\n // Client component\n transformedCode += `\nconst ${exportName}Ref = Object.defineProperties(\n ${\n isClass\n ? `class extends ${exportName} {\n constructor(...args) { super(...args); }\n }`\n : `function(...args) { return ${exportName}.apply(null, args); }`\n },\n {\n $$typeof: { value: Symbol.for(\"react.server.reference\") },\n $$id: { value: ${JSON.stringify(moduleId + \"#\" + exportName)} },\n $$filepath: { value: ${JSON.stringify(path)} },\n $$async: { value: true }\n }\n);\nexport { ${exportName}Ref as ${exportName} };\n `;\n }\n }\n\n return {\n code: transformedCode,\n map: new SourceMapGenerator({ file: path }).toString(),\n };\n } catch (error) {\n console.error(\n `[RSC] Error transforming client component: ${path}`,\n error\n );\n throw error;\n }\n },\n };\n}\n\n/**\n * transformedCode += `\nconst ${exportName}Ref = Object.defineProperties(\n ${\n isClass\n ? `class extends ${exportName} {\n constructor(...args) { super(...args); }\n }`\n : `function(...args) { return ${exportName}.apply(null, args); }`\n },\n {\n $$typeof: { value: Symbol.for(\"react.client.reference\") },\n $$id: { value: ${JSON.stringify(moduleId + \"#\" + exportName)} }\n }\n);\nexport { ${exportName}Ref as ${exportName} };`;\n */\n"],"names":[],"mappings":";;;;;;;AAGO,SAAS,8BAA8B,OAA6B,EAAA;AACzE,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,qDAAA;AAAA,IACN,OAAS,EAAA,MAAA;AAAA,IAET,MAAM,SACJ,CAAA,IAAA,EACA,IACA,EAAA,EAAE,KAA0B,GAAA,EAAE,GAAK,EAAA,KAAA,EACnC,EAAA;AACA,MAAI,IAAA;AACF,QAAA,IAAI,eAAkB,GAAA,IAAA;AACtB,QAAM,MAAA,cAAA,GAAiB,IAAK,CAAA,KAAA,CAAM,uBAAuB,CAAA;AACzD,QAAA,MAAM,QAAW,GAAA,OAAA,CAAQ,QAAS,CAAA,IAAA,EAAM,GAAG,CAAA;AAG3C,QAAA,OAAA,CAAQ,IAAI,6CAA+C,EAAA;AAAA,UACzD,QAAU,EAAA,IAAA;AAAA,UACV,WAAa,EAAA;AAAA,SACd,CAAA;AAGD,QAAA,MAAM,gBAAgB,KAAM,CAAA,IAAA;AAAA,UAC1B,IAAA,CAAK,SAAS,oDAAoD;AAAA,SACpE;AAEA,QAAI,IAAA,CAAC,cAAc,MAAQ,EAAA;AACzB,UAAQ,OAAA,CAAA,IAAA;AAAA,YACN,mDAAmD,IAAI,CAAA;AAAA,WACzD;AACA,UAAO,OAAA,IAAA;AAAA;AAIT,QAAA,KAAA,MAAW,CAAC,SAAA,EAAW,UAAU,CAAA,IAAK,aAAe,EAAA;AACnD,UAAA,IAAI,CAAC,UAAY,EAAA;AACf,YAAQ,OAAA,CAAA,IAAA;AAAA,cACN,iDAAiD,IAAI,CAAA;AAAA,aACvD;AACA,YAAA;AAAA;AAGF,UAAM,MAAA,OAAA,GAAU,SAAU,CAAA,QAAA,CAAS,OAAO,CAAA;AAG1C,UAAA,eAAA,GAAkB,eAAgB,CAAA,OAAA;AAAA,YAChC,SAAA;AAAA,YACA,SAAA,CAAU,OAAQ,CAAA,SAAA,EAAW,EAAE;AAAA,WACjC;AAEA,UAAA,IAAI,CAAC,cAAA,IAAkB,cAAe,CAAA,KAAA,KAAU,CAAG,EAAA;AAAA,WAE5C,MAAA;AAEL,YAAmB,eAAA,IAAA;AAAA,MAAA,EACvB,UAAU,CAAA;AAAA,EAEd,EAAA,OAAA,GACI,iBAAiB,UAAU,CAAA;AAAA;AAAA,SAG3B,CAAA,GAAA,CAAA,2BAAA,EAA8B,UAAU,CAC9C,qBAAA,CAAA,CAAA;AAAA;AAAA;AAAA,mBAAA,EAGmB,IAAK,CAAA,SAAA,CAAU,QAAW,GAAA,GAAA,GAAM,UAAU,CAAC,CAAA;AAAA,yBACrC,EAAA,IAAA,CAAK,SAAU,CAAA,IAAI,CAAC,CAAA;AAAA;AAAA;AAAA;AAAA,SAIpC,EAAA,UAAU,UAAU,UAAU,CAAA;AAAA,YAAA,CAAA;AAAA;AAE/B;AAGF,QAAO,OAAA;AAAA,UACL,IAAM,EAAA,eAAA;AAAA,UACN,GAAA,EAAK,IAAI,kBAAmB,CAAA,EAAE,MAAM,IAAK,EAAC,EAAE,QAAS;AAAA,SACvD;AAAA,eACO,KAAO,EAAA;AACd,QAAQ,OAAA,CAAA,KAAA;AAAA,UACN,8CAA8C,IAAI,CAAA,CAAA;AAAA,UAClD;AAAA,SACF;AACA,QAAM,MAAA,KAAA;AAAA;AACR;AACF,GACF;AACF;;;;"}
@@ -1,5 +0,0 @@
1
- import type { Writable } from "node:stream";
2
- import type { MessagePort } from "node:worker_threads";
3
- import type { RscRenderState } from "../types.js";
4
- export declare function createRscStream(renderState: RscRenderState, writeStream: Writable, parentPort: MessagePort | null): any;
5
- //# sourceMappingURL=createRscStream.d.ts.map