vite-plugin-react-server 0.3.11 → 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 (220) hide show
  1. package/dist/package.json +15 -11
  2. package/dist/plugin/checkFilesExist.d.ts +2 -2
  3. package/dist/plugin/checkFilesExist.d.ts.map +1 -1
  4. package/dist/plugin/checkFilesExist.js +39 -57
  5. package/dist/plugin/checkFilesExist.js.map +1 -1
  6. package/dist/plugin/collect-css-manifest.d.ts.map +1 -1
  7. package/dist/plugin/collect-css-manifest.js +5 -0
  8. package/dist/plugin/collect-css-manifest.js.map +1 -1
  9. package/dist/plugin/components.js +10 -15
  10. package/dist/plugin/config/createModuleIdGenerator.js +1 -1
  11. package/dist/plugin/config/createModuleIdGenerator.js.map +1 -1
  12. package/dist/plugin/config/defaults.d.ts +5 -14
  13. package/dist/plugin/config/defaults.d.ts.map +1 -1
  14. package/dist/plugin/config/defaults.js +12 -12
  15. package/dist/plugin/config/defaults.js.map +1 -1
  16. package/dist/plugin/config/getPaths.js +1 -1
  17. package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
  18. package/dist/plugin/config/resolveOptions.js +73 -52
  19. package/dist/plugin/config/resolveOptions.js.map +1 -1
  20. package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
  21. package/dist/plugin/config/resolveUserConfig.js +53 -65
  22. package/dist/plugin/config/resolveUserConfig.js.map +1 -1
  23. package/dist/plugin/helpers/getBundleManifest.d.ts +6 -1
  24. package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
  25. package/dist/plugin/helpers/getBundleManifest.js +48 -19
  26. package/dist/plugin/helpers/getBundleManifest.js.map +1 -1
  27. package/dist/plugin/helpers/inputNormalizer.d.ts +1 -2
  28. package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
  29. package/dist/plugin/helpers/inputNormalizer.js +52 -46
  30. package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
  31. package/dist/plugin/helpers/tryManifest.d.ts +1 -1
  32. package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
  33. package/dist/plugin/helpers/tryManifest.js.map +1 -1
  34. package/dist/plugin/loader/createBuildLoader.d.ts +1 -1
  35. package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
  36. package/dist/plugin/loader/createBuildLoader.js +29 -26
  37. package/dist/plugin/loader/createBuildLoader.js.map +1 -1
  38. package/dist/plugin/loader/css-loader.d.ts +16 -0
  39. package/dist/plugin/loader/css-loader.d.ts.map +1 -0
  40. package/dist/plugin/loader/css-loader.js +70 -0
  41. package/dist/plugin/loader/css-loader.js.map +1 -0
  42. package/dist/plugin/loader/react-loader.d.ts +17 -0
  43. package/dist/plugin/loader/react-loader.d.ts.map +1 -0
  44. package/dist/plugin/loader/react-loader.js +647 -0
  45. package/dist/plugin/loader/react-loader.js.map +1 -0
  46. package/dist/plugin/loader/rsc/messageHandler.d.ts +2 -0
  47. package/dist/plugin/loader/rsc/messageHandler.d.ts.map +1 -0
  48. package/dist/plugin/loader/rsc/messageHandler.js +1 -0
  49. package/dist/plugin/loader/rsc/rsc-worker.development.d.ts +2 -0
  50. package/dist/plugin/loader/rsc/rsc-worker.development.d.ts.map +1 -0
  51. package/dist/plugin/loader/rsc/rsc-worker.development.js +1 -0
  52. package/dist/plugin/react-client/index.js +2 -2
  53. package/dist/plugin/react-client/index.js.map +1 -1
  54. package/dist/plugin/react-client/plugin.d.ts.map +1 -1
  55. package/dist/plugin/react-client/plugin.js +202 -25
  56. package/dist/plugin/react-client/plugin.js.map +1 -1
  57. package/dist/plugin/react-server/createHandler.d.ts.map +1 -1
  58. package/dist/plugin/react-server/createHandler.js +10 -4
  59. package/dist/plugin/react-server/createHandler.js.map +1 -1
  60. package/dist/plugin/react-server/createRscStream.d.ts +15 -3
  61. package/dist/plugin/react-server/createRscStream.d.ts.map +1 -1
  62. package/dist/plugin/react-server/createRscStream.js +52 -49
  63. package/dist/plugin/react-server/createRscStream.js.map +1 -1
  64. package/dist/plugin/react-server/plugin.d.ts.map +1 -1
  65. package/dist/plugin/react-server/plugin.js +24 -20
  66. package/dist/plugin/react-server/plugin.js.map +1 -1
  67. package/dist/plugin/transformer/plugin.d.ts.map +1 -1
  68. package/dist/plugin/transformer/plugin.js +65 -52
  69. package/dist/plugin/transformer/plugin.js.map +1 -1
  70. package/dist/plugin/types.d.ts +5 -0
  71. package/dist/plugin/types.d.ts.map +1 -1
  72. package/dist/plugin/utils/logger.d.ts +9 -0
  73. package/dist/plugin/utils/logger.d.ts.map +1 -0
  74. package/dist/plugin/utils/logger.js +68 -0
  75. package/dist/plugin/utils/logger.js.map +1 -0
  76. package/dist/plugin/worker/createWorker.d.ts +1 -0
  77. package/dist/plugin/worker/createWorker.d.ts.map +1 -1
  78. package/dist/plugin/worker/createWorker.js +23 -36
  79. package/dist/plugin/worker/createWorker.js.map +1 -1
  80. package/dist/plugin/worker/html/html-worker.production.js +5 -1
  81. package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
  82. package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
  83. package/dist/plugin/worker/html/messageHandler.js +10 -19
  84. package/dist/plugin/worker/html/messageHandler.js.map +1 -1
  85. package/dist/plugin/worker/html/renderPages.d.ts +2 -2
  86. package/dist/plugin/worker/html/renderPages.d.ts.map +1 -1
  87. package/dist/plugin/worker/html/renderPages.js +130 -131
  88. package/dist/plugin/worker/html/renderPages.js.map +1 -1
  89. package/dist/plugin/worker/rsc/index.d.ts +1 -3
  90. package/dist/plugin/worker/rsc/index.d.ts.map +1 -1
  91. package/dist/plugin/worker/rsc/index.js +1 -9
  92. package/dist/plugin/worker/rsc/index.js.map +1 -1
  93. package/dist/plugin/worker/rsc/messageHandler.d.ts +3 -0
  94. package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -0
  95. package/dist/plugin/worker/rsc/messageHandler.js +107 -0
  96. package/dist/plugin/worker/rsc/messageHandler.js.map +1 -0
  97. package/dist/plugin/worker/rsc/plugin.d.ts.map +1 -1
  98. package/dist/plugin/worker/rsc/plugin.js +74 -80
  99. package/dist/plugin/worker/rsc/rsc-worker.development.d.ts +32 -0
  100. package/dist/plugin/worker/rsc/rsc-worker.development.d.ts.map +1 -0
  101. package/dist/plugin/worker/rsc/rsc-worker.development.js +43 -0
  102. package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -0
  103. package/dist/plugin/worker/rsc/rsc-worker.js +4 -106
  104. package/dist/plugin/worker/rsc/rsc-worker.production.d.ts +2 -0
  105. package/dist/plugin/worker/rsc/rsc-worker.production.d.ts.map +1 -0
  106. package/dist/plugin/worker/rsc/rsc-worker.production.js +14 -0
  107. package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -0
  108. package/dist/plugin/worker/rsc/state.d.ts +11 -0
  109. package/dist/plugin/worker/rsc/state.d.ts.map +1 -0
  110. package/dist/plugin/worker/rsc/state.js +12 -0
  111. package/dist/plugin/worker/rsc/state.js.map +1 -0
  112. package/dist/plugin/worker/types.d.ts +60 -46
  113. package/dist/plugin/worker/types.d.ts.map +1 -1
  114. package/dist/tsconfig.tsbuildinfo +1 -1
  115. package/package.json +15 -11
  116. package/plugin/checkFilesExist.ts +42 -62
  117. package/plugin/collect-css-manifest.ts +5 -1
  118. package/plugin/config/createModuleIdGenerator.ts +1 -1
  119. package/plugin/config/defaults.ts +13 -15
  120. package/plugin/config/resolveOptions.ts +134 -76
  121. package/plugin/config/resolveUserConfig.ts +75 -76
  122. package/plugin/helpers/getBundleManifest.ts +69 -31
  123. package/plugin/helpers/inputNormalizer.ts +82 -70
  124. package/plugin/helpers/tryManifest.ts +1 -1
  125. package/plugin/loader/createBuildLoader.ts +38 -41
  126. package/plugin/loader/css-loader.ts +96 -0
  127. package/plugin/loader/react-loader.ts +945 -0
  128. package/plugin/loader/rsc/messageHandler.tsx +1 -0
  129. package/plugin/loader/rsc/rsc-worker.development.ts +1 -0
  130. package/plugin/react-client/index.ts +1 -1
  131. package/plugin/react-client/plugin.ts +266 -41
  132. package/plugin/react-server/createHandler.ts +9 -5
  133. package/plugin/react-server/createRscStream.ts +75 -54
  134. package/plugin/react-server/plugin.ts +26 -21
  135. package/plugin/transformer/plugin.ts +67 -76
  136. package/plugin/types/global.d.ts +8 -0
  137. package/plugin/types.ts +2 -0
  138. package/plugin/utils/logger.ts +52 -0
  139. package/plugin/worker/createWorker.ts +43 -44
  140. package/plugin/worker/html/html-worker.production.tsx +7 -2
  141. package/plugin/worker/html/messageHandler.ts +13 -21
  142. package/plugin/worker/html/renderPages.ts +146 -179
  143. package/plugin/worker/rsc/index.ts +4 -13
  144. package/plugin/worker/rsc/messageHandler.tsx +143 -0
  145. package/plugin/worker/rsc/plugin.ts +38 -37
  146. package/plugin/worker/rsc/rsc-worker.development.ts +107 -0
  147. package/plugin/worker/rsc/rsc-worker.production.ts +13 -0
  148. package/plugin/worker/rsc/rsc-worker.tsx +5 -128
  149. package/plugin/worker/rsc/state.ts +37 -0
  150. package/plugin/worker/types.ts +79 -55
  151. package/scripts/check-react-version.mjs +17 -7
  152. package/scripts/react+0.0.0-experimental-b3a95caf-20250113.patch +143 -4170
  153. package/scripts/react-dom+0.0.0-experimental-b3a95caf-20250113.patch +14271 -90079
  154. package/dist/plugin/components.js.map +0 -1
  155. package/dist/plugin/helpers/createClientInputNormalizer.d.ts +0 -8
  156. package/dist/plugin/helpers/createClientInputNormalizer.d.ts.map +0 -1
  157. package/dist/plugin/helpers/createClientInputNormalizer.js +0 -35
  158. package/dist/plugin/helpers/createServerInputNormalizer.d.ts +0 -9
  159. package/dist/plugin/helpers/createServerInputNormalizer.d.ts.map +0 -1
  160. package/dist/plugin/helpers/createServerInputNormalizer.js +0 -37
  161. package/dist/plugin/helpers/createStaticInputNormalizer.d.ts +0 -7
  162. package/dist/plugin/helpers/createStaticInputNormalizer.d.ts.map +0 -1
  163. package/dist/plugin/helpers/createStaticInputNormalizer.js +0 -18
  164. package/dist/plugin/helpers/getModuleManifest.d.ts +0 -17
  165. package/dist/plugin/helpers/getModuleManifest.d.ts.map +0 -1
  166. package/dist/plugin/helpers/getModuleManifest.js +0 -23
  167. package/dist/plugin/helpers/inputNormalizerWorker.d.ts +0 -12
  168. package/dist/plugin/helpers/inputNormalizerWorker.d.ts.map +0 -1
  169. package/dist/plugin/helpers/inputNormalizerWorker.js +0 -33
  170. package/dist/plugin/helpers/normalizedRelativePath.d.ts +0 -11
  171. package/dist/plugin/helpers/normalizedRelativePath.d.ts.map +0 -1
  172. package/dist/plugin/helpers/normalizedRelativePath.js +0 -36
  173. package/dist/plugin/helpers/resolveFilePath.d.ts +0 -13
  174. package/dist/plugin/helpers/resolveFilePath.d.ts.map +0 -1
  175. package/dist/plugin/helpers/resolveFilePath.js +0 -74
  176. package/dist/plugin/helpers/resolveWorkerModule.d.ts +0 -6
  177. package/dist/plugin/helpers/resolveWorkerModule.d.ts.map +0 -1
  178. package/dist/plugin/helpers/resolveWorkerModule.js +0 -24
  179. package/dist/plugin/helpers/validateModuleBase.d.ts +0 -3
  180. package/dist/plugin/helpers/validateModuleBase.d.ts.map +0 -1
  181. package/dist/plugin/helpers/validateModuleBase.js +0 -16
  182. package/dist/plugin/helpers/validateResolvedConfig.d.ts +0 -3
  183. package/dist/plugin/helpers/validateResolvedConfig.d.ts.map +0 -1
  184. package/dist/plugin/helpers/validateResolvedConfig.js +0 -17
  185. package/dist/plugin/transformer/transformer-client-components.d.ts +0 -30
  186. package/dist/plugin/transformer/transformer-client-components.d.ts.map +0 -1
  187. package/dist/plugin/transformer/transformer-client-components.js +0 -122
  188. package/dist/plugin/transformer/transformer-client-components.js.map +0 -1
  189. package/dist/plugin/transformer/transformer-server-actions.d.ts +0 -29
  190. package/dist/plugin/transformer/transformer-server-actions.d.ts.map +0 -1
  191. package/dist/plugin/transformer/transformer-server-actions.js +0 -90
  192. package/dist/plugin/worker/rsc/createRscStream.d.ts +0 -5
  193. package/dist/plugin/worker/rsc/createRscStream.d.ts.map +0 -1
  194. package/dist/plugin/worker/rsc/createRscStream.js +0 -39
  195. package/dist/plugin/worker/rsc/createRscStream.js.map +0 -1
  196. package/dist/plugin/worker/rsc/development.d.ts +0 -5
  197. package/dist/plugin/worker/rsc/development.d.ts.map +0 -1
  198. package/dist/plugin/worker/rsc/development.js +0 -13
  199. package/dist/plugin/worker/rsc/development.js.map +0 -1
  200. package/dist/plugin/worker/rsc/plugin.js.map +0 -1
  201. package/dist/plugin/worker/rsc/production.d.ts +0 -5
  202. package/dist/plugin/worker/rsc/production.d.ts.map +0 -1
  203. package/dist/plugin/worker/rsc/production.js +0 -13
  204. package/dist/plugin/worker/rsc/production.js.map +0 -1
  205. package/plugin/helpers/createClientInputNormalizer.ts +0 -48
  206. package/plugin/helpers/createServerInputNormalizer.ts +0 -52
  207. package/plugin/helpers/createStaticInputNormalizer.ts +0 -26
  208. package/plugin/helpers/getModuleManifest.ts +0 -36
  209. package/plugin/helpers/inputNormalizerWorker.ts +0 -52
  210. package/plugin/helpers/normalizedRelativePath.ts +0 -59
  211. package/plugin/helpers/resolveFilePath.ts +0 -108
  212. package/plugin/helpers/resolveWorkerModule.ts +0 -41
  213. package/plugin/helpers/validateModuleBase.ts +0 -30
  214. package/plugin/helpers/validateResolvedConfig.ts +0 -21
  215. package/plugin/transformer/transformer-client-components.ts +0 -168
  216. package/plugin/transformer/transformer-server-actions.ts +0 -125
  217. package/plugin/worker/rsc/createRscStream.ts +0 -42
  218. package/plugin/worker/rsc/development.ts +0 -6
  219. package/plugin/worker/rsc/production.ts +0 -6
  220. package/scripts/react-server-dom-esm+0.0.1.patch +0 -24775
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformer-client-components.js","sources":["../../../plugin/transformer/transformer-client-components.ts"],"sourcesContent":["import type { PluginContext } from \"rollup\";\nimport type { TransformerOptions } from \"./types.js\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\nimport { createInputNormalizer } from \"../helpers/inputNormalizer.js\";\nimport type { ResolvedUserConfig, ResolvedUserOptions } from \"../types.js\";\nimport type { ConfigEnv } from \"vite\";\nimport { join } from \"path\";\nimport { tryManifest } from \"../helpers/tryManifest.js\";\n\nexport function createClientComponentTransformer(\n {\n moduleBase = DEFAULT_CONFIG.MODULE_BASE,\n projectRoot,\n moduleId,\n build,\n }: ResolvedUserOptions,\n config: ResolvedUserConfig,\n configEnv: ConfigEnv\n) {\n let moduleIdFn = moduleId;\n const normalizer = createInputNormalizer({\n root: projectRoot,\n preserveModulesRoot: moduleBase,\n removeExtension: true,\n });\n const isClient = config.build.outDir?.endsWith(build.client);\n const isServer = config.build.outDir?.endsWith(build.server);\n const references = isServer\n ? tryManifest({\n root: projectRoot,\n outDir: join(build.outDir, build.client),\n ssrManifest: false,\n }).manifest\n : null;\n\n return {\n name: \"vite-plugin-react-server:client-components-transformer\",\n\n async transform(\n this: PluginContext,\n code: string,\n id: string,\n options?: { ssr?: boolean }\n ) {\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 let rest = id.split(\"/\");\n let fileName = rest.pop() as string;\n let dir = rest.join(\"/\");\n if (dir.startsWith(projectRoot)) {\n dir = dir.replace(projectRoot, \"\");\n }\n const index = dir.indexOf(moduleBase);\n if (index !== -1) {\n if (configEnv.command === \"build\") {\n if (isServer) {\n dir = join(build.assetsDir, dir.slice(index + moduleBase.length));\n } else {\n dir = new URL(\n dir,\n `file://${config?.server?.host ?? \"localhost\"}:${\n config?.server?.port ?? configEnv.isPreview ? 4173 : 5173\n }`\n ).pathname;\n }\n } else if (configEnv.command === \"serve\") {\n dir = \"\";\n }\n }\n if (!fileName) fileName = id;\n const info = this?.getModuleInfo(id);\n const hasDirective = code.match(/^[\"']use client[\"'];?/);\n const isClientComponent =\n 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, configEnv.isSsrBuild ?? false);\n const [key, value] = normalizer([moduleId, id]);\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 console.log(\"exportName\", dir, fileName, exportName);\n const isClass = fullMatch.includes(\"class\");\n // Remove export keyword\n transformedCode = transformedCode.replace(\n fullMatch,\n fullMatch.replace(\"export \", \"\")\n );\n let path = `import.meta.url`;\n // path from moduleBase to value\n const { manifest, error } = tryManifest({\n root: projectRoot,\n outDir: join(build.outDir, build.client),\n ssrManifest: false,\n });\n if (error) {\n console.error(`[RSC] Error getting manifest: ${error}`);\n continue;\n }\n const fileFromManifest = manifest[join(moduleBase, value)]?.file;\n if (fileFromManifest) {\n path = JSON.stringify(fileFromManifest);\n } else {\n console.error(`[RSC] File not found in manifest: ${value}`);\n continue;\n }\n\n transformedCode += `const ${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: \\`\\${${path}}${\"#\" + exportName}\\` }\n }\n);\nexport { ${exportName}Ref as ${exportName} };`;\n }\n return { code: transformedCode, map: null };\n } catch (error) {\n console.error(\n `[RSC] Error transforming client component: ${id}`,\n error\n );\n throw error;\n }\n },\n } as const;\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":["moduleId"],"mappings":";;;;;;;;;;AASO,SAAS,gCACd,CA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E,CAAA,CAAA;AAC1D,YAAA;AAAA;AAGF,UAAA,eAAA,IAAmB,CAAS,MAAA,EAAA,UAAU,CACpC,8BAAA,EAAA,OAAA,GACI,iBAAiB,UAAU,CAAA;AAAA;AAAA,OAG3B,CAAA,GAAA,CAAA,2BAAA,EAA8B,UAAU,CAC9C,qBAAA,CAAA,CAAA;AAAA;AAAA;AAAA,wBAGgB,EAAA,IAAI,CAAI,CAAA,EAAA,GAAA,GAAM,UAAU,CAAA;AAAA;AAAA;AAAA,SAGvC,EAAA,UAAU,UAAU,UAAU,CAAA,GAAA,CAAA;AAAA;AAEjC,QAAA,OAAO,EAAE,IAAA,EAAM,eAAiB,EAAA,GAAA,EAAK,IAAK,EAAA;AAAA,eACnC,KAAO,EAAA;AACd,QAAQ,OAAA,CAAA,KAAA;AAAA,UACN,8CAA8C,EAAE,CAAA,CAAA;AAAA,UAChD;AAAA,SACF;AACA,QAAM,MAAA,KAAA;AAAA;AACR;AACF,GACF;AACF;;;;"}
@@ -1,29 +0,0 @@
1
- import type { ResolvedUserOptions, ResolvedUserConfig } from "../types.js";
2
- import type { ConfigEnv } from "vite";
3
- export declare function createServerActionTransformer({ moduleBase, projectRoot, moduleId, }: ResolvedUserOptions, config: ResolvedUserConfig, configEnv: ConfigEnv): {
4
- name: string;
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":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAGtC,wBAAgB,6BAA6B,CAAC,EAC5C,UAAuC,EACvC,WAAW,EACX,QAAQ,GACT,EAAE,mBAAmB,EAAE,MAAM,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAS;;oBAW5D,MAAM,QACN,MAAM,YACD;QAAE,GAAG,EAAE,OAAO,CAAA;KAAE;;;;EAkFhC;AAED;;;;;;;;;;;;;;;;GAgBG"}
@@ -1,90 +0,0 @@
1
- import { SourceMapGenerator } from "source-map";
2
- import { DEFAULT_CONFIG } from "../config/defaults.js";
3
- import { createInputNormalizer } from "../helpers/inputNormalizer.js";
4
- export function createServerActionTransformer({ moduleBase = DEFAULT_CONFIG.MODULE_BASE, projectRoot, moduleId, }, config, configEnv) {
5
- let moduleIdFn = moduleId;
6
- const normalizer = createInputNormalizer({
7
- root: projectRoot,
8
- preserveModulesRoot: moduleBase,
9
- removeExtension: DEFAULT_CONFIG.FILE_REGEX,
10
- });
11
- return {
12
- name: "vite-plugin-react-server:server-actions-transformer",
13
- async transform(code, path, { ssr } = { ssr: false }) {
14
- try {
15
- let transformedCode = code;
16
- const directiveMatch = code.match(/^["']use server["'];?/);
17
- const moduleId = moduleIdFn(path, ssr);
18
- const [key, value] = normalizer(moduleId);
19
- // Log the path transformation
20
- console.log("[RSC Transform] Module path transformation:", {
21
- original: path,
22
- transformed: moduleId,
23
- });
24
- // Find all named exports
25
- const exportMatches = Array.from(code.matchAll(/export\s+(?:const|let|var|function|class)\s+(\w+)/g));
26
- if (!exportMatches.length) {
27
- console.warn(`[RSC] No exports found in server action module: ${path}`);
28
- return null;
29
- }
30
- // Transform each export
31
- for (const [fullMatch, exportName] of exportMatches) {
32
- if (!exportName) {
33
- console.warn(`[RSC] Invalid export in server action module: ${path}`);
34
- continue;
35
- }
36
- const isClass = fullMatch.includes("class");
37
- // Remove export keyword
38
- transformedCode = transformedCode.replace(fullMatch, fullMatch.replace("export ", ""));
39
- if (!directiveMatch || directiveMatch.index !== 0) {
40
- // Server action
41
- }
42
- else {
43
- // Client component
44
- transformedCode += `
45
- const ${exportName}Ref = Object.defineProperties(
46
- ${isClass
47
- ? `class extends ${exportName} {
48
- constructor(...args) { super(...args); }
49
- }`
50
- : `function(...args) { return ${exportName}.apply(null, args); }`},
51
- {
52
- $$typeof: { value: Symbol.for("react.server.reference") },
53
- $$src: { value: ${JSON.stringify(value)} },
54
- $$id: { value: import.meta.url.slice(import.meta.url.indexOf("/${key}")}) + ${JSON.stringify("#" + exportName)} },
55
- $$async: { value: true }
56
- }
57
- );
58
- export { ${exportName}Ref as ${exportName} };
59
- `;
60
- }
61
- }
62
- return {
63
- code: transformedCode,
64
- map: new SourceMapGenerator({ file: path }).toString(),
65
- };
66
- }
67
- catch (error) {
68
- console.error(`[RSC] Error transforming client component: ${path}`, error);
69
- throw error;
70
- }
71
- },
72
- };
73
- }
74
- /**
75
- * transformedCode += `
76
- const ${exportName}Ref = Object.defineProperties(
77
- ${
78
- isClass
79
- ? `class extends ${exportName} {
80
- constructor(...args) { super(...args); }
81
- }`
82
- : `function(...args) { return ${exportName}.apply(null, args); }`
83
- },
84
- {
85
- $$typeof: { value: Symbol.for("react.client.reference") },
86
- $$id: { value: ${JSON.stringify(moduleId + "#" + exportName)} }
87
- }
88
- );
89
- export { ${exportName}Ref as ${exportName} };`;
90
- */
@@ -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
@@ -1 +0,0 @@
1
- {"version":3,"file":"createRscStream.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/createRscStream.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,eAAe,CAC7B,WAAW,EAAE,cAAc,EAC3B,WAAW,EAAE,QAAQ,EACrB,UAAU,EAAE,WAAW,GAAG,IAAI,OA+B/B"}
@@ -1,39 +0,0 @@
1
- /**
2
- * vite-plugin-react-server
3
- * Copyright (c) Nico Brinkkemper
4
- * MIT License
5
- */
6
- import { renderToPipeableStream } from 'react-server-dom-esm/server.node';
7
-
8
- function createRscStream(renderState, writeStream, parentPort) {
9
- console.log("[createRscStream] Creating stream for:", renderState.id);
10
- const stream = renderToPipeableStream(renderState.componentImport, {
11
- onShellReady() {
12
- console.log("[createRscStream] onShellReady called for:", renderState.id);
13
- stream.pipe(writeStream);
14
- },
15
- onAllReady() {
16
- console.log("[createRscStream] onAllReady called for:", renderState.id);
17
- writeStream.on("finish", () => {
18
- parentPort?.postMessage({
19
- type: "WROTE_FILE",
20
- id: renderState.id,
21
- outputPath: renderState.rscOutputPath
22
- });
23
- });
24
- },
25
- onError(error) {
26
- console.error("[createRscStream] Render error:", error);
27
- parentPort?.postMessage({
28
- type: "ERROR",
29
- error: error instanceof Error ? error.message : String(error),
30
- id: renderState.id
31
- });
32
- stream.abort();
33
- }
34
- });
35
- return stream;
36
- }
37
-
38
- export { createRscStream };
39
- //# sourceMappingURL=createRscStream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createRscStream.js","sources":["../../../../plugin/worker/rsc/createRscStream.ts"],"sourcesContent":["import { renderToPipeableStream \n // @ts-ignore\n} from \"react-server-dom-esm/server.node\";\nimport type { Writable } from \"node:stream\";\nimport type { MessagePort } from \"node:worker_threads\";\nimport type { RscRenderState } from \"../types.js\";\n\nexport function createRscStream(\n renderState: RscRenderState,\n writeStream: Writable,\n parentPort: MessagePort | null\n) {\n console.log(\"[createRscStream] Creating stream for:\", renderState.id);\n\n const stream = renderToPipeableStream(renderState.componentImport, {\n onShellReady() {\n console.log(\"[createRscStream] onShellReady called for:\", renderState.id);\n stream.pipe(writeStream);\n },\n onAllReady() {\n console.log(\"[createRscStream] onAllReady called for:\", renderState.id);\n writeStream.on(\"finish\", () => {\n parentPort?.postMessage({\n type: \"WROTE_FILE\",\n id: renderState.id,\n outputPath: renderState.rscOutputPath\n });\n });\n },\n onError(error: unknown) {\n console.error(\"[createRscStream] Render error:\", error);\n parentPort?.postMessage({\n type: \"ERROR\",\n error: error instanceof Error ? error.message : String(error),\n id: renderState.id\n });\n stream.abort();\n }\n });\n\n return stream;\n}\n"],"names":[],"mappings":";;;;;;;AAOgB,SAAA,eAAA,CACd,WACA,EAAA,WAAA,EACA,UACA,EAAA;AACA,EAAQ,OAAA,CAAA,GAAA,CAAI,wCAA0C,EAAA,WAAA,CAAY,EAAE,CAAA;AAEpE,EAAM,MAAA,MAAA,GAAS,sBAAuB,CAAA,WAAA,CAAY,eAAiB,EAAA;AAAA,IACjE,YAAe,GAAA;AACb,MAAQ,OAAA,CAAA,GAAA,CAAI,4CAA8C,EAAA,WAAA,CAAY,EAAE,CAAA;AACxE,MAAA,MAAA,CAAO,KAAK,WAAW,CAAA;AAAA,KACzB;AAAA,IACA,UAAa,GAAA;AACX,MAAQ,OAAA,CAAA,GAAA,CAAI,0CAA4C,EAAA,WAAA,CAAY,EAAE,CAAA;AACtE,MAAY,WAAA,CAAA,EAAA,CAAG,UAAU,MAAM;AAC7B,QAAA,UAAA,EAAY,WAAY,CAAA;AAAA,UACtB,IAAM,EAAA,YAAA;AAAA,UACN,IAAI,WAAY,CAAA,EAAA;AAAA,UAChB,YAAY,WAAY,CAAA;AAAA,SACzB,CAAA;AAAA,OACF,CAAA;AAAA,KACH;AAAA,IACA,QAAQ,KAAgB,EAAA;AACtB,MAAQ,OAAA,CAAA,KAAA,CAAM,mCAAmC,KAAK,CAAA;AACtD,MAAA,UAAA,EAAY,WAAY,CAAA;AAAA,QACtB,IAAM,EAAA,OAAA;AAAA,QACN,OAAO,KAAiB,YAAA,KAAA,GAAQ,KAAM,CAAA,OAAA,GAAU,OAAO,KAAK,CAAA;AAAA,QAC5D,IAAI,WAAY,CAAA;AAAA,OACjB,CAAA;AACD,MAAA,MAAA,CAAO,KAAM,EAAA;AAAA;AACf,GACD,CAAA;AAED,EAAO,OAAA,MAAA;AACT;;;;"}
@@ -1,5 +0,0 @@
1
- import { createRscStream as devCreateRscStream } from './createRscStream.js';
2
- import { createWorker as devCreateWorker } from '../createWorker.js';
3
- export declare const createRscStream: typeof devCreateRscStream;
4
- export declare const createWorker: typeof devCreateWorker;
5
- //# sourceMappingURL=development.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"development.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/development.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrE,eAAO,MAAM,eAAe,2BAAqB,CAAC;AAClD,eAAO,MAAM,YAAY,wBAAkB,CAAC"}
@@ -1,13 +0,0 @@
1
- /**
2
- * vite-plugin-react-server
3
- * Copyright (c) Nico Brinkkemper
4
- * MIT License
5
- */
6
- import { createRscStream as createRscStream$1 } from './createRscStream.js';
7
- import { createWorker as createWorker$1 } from '../createWorker.js';
8
-
9
- const createRscStream = createRscStream$1;
10
- const createWorker = createWorker$1;
11
-
12
- export { createRscStream, createWorker };
13
- //# sourceMappingURL=development.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"development.js","sources":["../../../../plugin/worker/rsc/development.ts"],"sourcesContent":["import { createRscStream as devCreateRscStream } from './createRscStream.js';\nimport { createWorker as devCreateWorker } from '../createWorker.js';\n\n// Development-specific implementations\nexport const createRscStream = devCreateRscStream;\nexport const createWorker = devCreateWorker; "],"names":["devCreateRscStream","devCreateWorker"],"mappings":";;;;;;;;AAIO,MAAM,eAAkB,GAAAA;AACxB,MAAM,YAAe,GAAAC;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.js","sources":["../../../../plugin/worker/rsc/plugin.ts"],"sourcesContent":["import type { Plugin } from \"vite\";\nimport { resolve } from \"path\";\nimport type { ModuleFormat } from 'rollup';\nimport type { StreamPluginOptions } from \"../../types.js\";\nimport { DEFAULT_CONFIG } from \"../../config/defaults.js\";\nimport { getPluginRoot } from \"../../config/getPaths.js\";\n\nexport function reactRscWorkerPlugin(options: StreamPluginOptions): Plugin {\n return {\n name: \"vite:react-rsc-worker\",\n config(config) {\n const root = config.root ?? process.cwd();\n const pluginRoot = getPluginRoot();\n const rscWorkerPath = typeof options.rscWorkerPath === 'string' \n ? resolve(root, options.rscWorkerPath) \n : resolve(pluginRoot, DEFAULT_CONFIG.RSC_WORKER_PATH);\n \n const format: ModuleFormat = 'esm';\n\n // Single worker output for server build\n const workerConfig = {\n input: {\n 'rsc-worker': rscWorkerPath,\n },\n output: {\n format,\n dir: options.build?.server ?? 'dist/server', // Output to server directory\n entryFileNames: '[name].js',\n preserveModules: true,\n manualChunks: {\n 'rsc-worker': [rscWorkerPath]\n },\n resolve: {\n conditions: ['react-server'],\n }\n }\n };\n\n return {\n build: {\n rollupOptions: {\n preserveEntrySignatures: 'strict',\n input: {\n ...workerConfig.input,\n ...(typeof config.build?.rollupOptions?.input === 'object' \n ? config.build?.rollupOptions?.input \n : {}),\n },\n external: [\n 'vite',\n 'rollup',\n 'react',\n 'react-dom',\n 'react-dom/server',\n 'react-server-dom-esm',\n 'react-server-dom-esm/client.node',\n 'react-server-dom-esm/server.node',\n 'react-server-dom-esm/node-loader',\n 'source-map',\n 'acorn-loose',\n 'webpack-sources',\n 'stream',\n 'util',\n 'crypto',\n 'async_hooks',\n 'fs',\n 'path',\n 'worker_threads',\n // if we use node: paths in our code, it should always be catched by below rule.\n /^node:.*/,\n ],\n output: {\n ...workerConfig.output,\n }\n },\n manifest: true, // Ensure manifest is generated\n minify: false,\n sourcemap: true,\n }\n };\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAOO,SAAS,qBAAqB,OAAsC,EAAA;AACzE,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,uBAAA;AAAA,IACN,OAAO,MAAQ,EAAA;AACb,MAAA,MAAM,IAAO,GAAA,MAAA,CAAO,IAAQ,IAAA,OAAA,CAAQ,GAAI,EAAA;AACxC,MAAA,MAAM,aAAa,aAAc,EAAA;AACjC,MAAA,MAAM,aAAgB,GAAA,OAAO,OAAQ,CAAA,aAAA,KAAkB,QACnD,GAAA,OAAA,CAAQ,IAAM,EAAA,OAAA,CAAQ,aAAa,CAAA,GACnC,OAAQ,CAAA,UAAA,EAAY,eAAe,eAAe,CAAA;AAEtD,MAAA,MAAM,MAAuB,GAAA,KAAA;AAG7B,MAAA,MAAM,YAAe,GAAA;AAAA,QACnB,KAAO,EAAA;AAAA,UACL,YAAc,EAAA;AAAA,SAChB;AAAA,QACA,MAAQ,EAAA;AAAA,UACN,MAAA;AAAA,UACA,GAAA,EAAK,OAAQ,CAAA,KAAA,EAAO,MAAU,IAAA,aAAA;AAAA;AAAA,UAC9B,cAAgB,EAAA,WAAA;AAAA,UAChB,eAAiB,EAAA,IAAA;AAAA,UACjB,YAAc,EAAA;AAAA,YACZ,YAAA,EAAc,CAAC,aAAa;AAAA,WAC9B;AAAA,UACA,OAAS,EAAA;AAAA,YACP,UAAA,EAAY,CAAC,cAAc;AAAA;AAC7B;AACF,OACF;AAEA,MAAO,OAAA;AAAA,QACL,KAAO,EAAA;AAAA,UACL,aAAe,EAAA;AAAA,YACb,uBAAyB,EAAA,QAAA;AAAA,YACzB,KAAO,EAAA;AAAA,cACL,GAAG,YAAa,CAAA,KAAA;AAAA,cAChB,GAAI,OAAO,MAAA,CAAO,KAAO,EAAA,aAAA,EAAe,KAAU,KAAA,QAAA,GAC9C,MAAO,CAAA,KAAA,EAAO,aAAe,EAAA,KAAA,GAC7B;AAAC,aACP;AAAA,YACA,QAAU,EAAA;AAAA,cACR,MAAA;AAAA,cACA,QAAA;AAAA,cACA,OAAA;AAAA,cACA,WAAA;AAAA,cACA,kBAAA;AAAA,cACA,sBAAA;AAAA,cACA,kCAAA;AAAA,cACA,kCAAA;AAAA,cACA,kCAAA;AAAA,cACA,YAAA;AAAA,cACA,aAAA;AAAA,cACA,iBAAA;AAAA,cACA,QAAA;AAAA,cACA,MAAA;AAAA,cACA,QAAA;AAAA,cACA,aAAA;AAAA,cACA,IAAA;AAAA,cACA,MAAA;AAAA,cACA,gBAAA;AAAA;AAAA,cAEA;AAAA,aACF;AAAA,YACA,MAAQ,EAAA;AAAA,cACN,GAAG,YAAa,CAAA;AAAA;AAClB,WACF;AAAA,UACA,QAAU,EAAA,IAAA;AAAA;AAAA,UACV,MAAQ,EAAA,KAAA;AAAA,UACR,SAAW,EAAA;AAAA;AACb,OACF;AAAA;AACF,GACF;AACF;;;;"}
@@ -1,5 +0,0 @@
1
- import { createRscStream as prodCreateRscStream } from './createRscStream.js';
2
- import { createWorker as prodCreateWorker } from '../createWorker.js';
3
- export declare const createRscStream: typeof prodCreateRscStream;
4
- export declare const createWorker: typeof prodCreateWorker;
5
- //# sourceMappingURL=production.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"production.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/production.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtE,eAAO,MAAM,eAAe,4BAAsB,CAAC;AACnD,eAAO,MAAM,YAAY,yBAAmB,CAAC"}
@@ -1,13 +0,0 @@
1
- /**
2
- * vite-plugin-react-server
3
- * Copyright (c) Nico Brinkkemper
4
- * MIT License
5
- */
6
- import { createRscStream as createRscStream$1 } from './createRscStream.js';
7
- import { createWorker as createWorker$1 } from '../createWorker.js';
8
-
9
- const createRscStream = createRscStream$1;
10
- const createWorker = createWorker$1;
11
-
12
- export { createRscStream, createWorker };
13
- //# sourceMappingURL=production.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"production.js","sources":["../../../../plugin/worker/rsc/production.ts"],"sourcesContent":["import { createRscStream as prodCreateRscStream } from './createRscStream.js';\nimport { createWorker as prodCreateWorker } from '../createWorker.js';\n\n// Production-specific optimizations could go here\nexport const createRscStream = prodCreateRscStream;\nexport const createWorker = prodCreateWorker; "],"names":["prodCreateRscStream","prodCreateWorker"],"mappings":";;;;;;;;AAIO,MAAM,eAAkB,GAAAA;AACxB,MAAM,YAAe,GAAAC;;;;"}
@@ -1,48 +0,0 @@
1
- import type { Worker } from 'worker_threads';
2
- import type { InputNormalizerWorker } from '../types.js';
3
-
4
- type ClientNormalizerOptions = {
5
- rscWorker: Worker;
6
- };
7
-
8
- export const createClientInputNormalizer = ({
9
- rscWorker
10
- }: ClientNormalizerOptions): InputNormalizerWorker => {
11
- return async (input): Promise<[string, string]> => {
12
- // Handle string
13
- if(typeof input === "string") {
14
- return [input, input];
15
- }
16
-
17
- // Handle React component
18
- if(typeof input === "function") {
19
- return new Promise((resolve, reject) => {
20
- const handler = (message: any) => {
21
- if (message.type === "CLIENT_REFERENCE") {
22
- rscWorker.off('message', handler);
23
- resolve([message.ref.$$id, message.ref.$$location]);
24
- }
25
- if (message.type === "ERROR") {
26
- rscWorker.off('message', handler);
27
- reject(new Error(message.error));
28
- }
29
- };
30
-
31
- rscWorker.on('message', handler);
32
- rscWorker.postMessage({
33
- type: "CLIENT_REFERENCE",
34
- id: input.name || 'AnonymousComponent',
35
- location: input.toString(),
36
- key: input.name
37
- });
38
- });
39
- }
40
-
41
- // Handle arrays
42
- if(Array.isArray(input)) {
43
- return [input[0], input[0]];
44
- }
45
-
46
- throw new Error('Invalid client input type');
47
- };
48
- };
@@ -1,52 +0,0 @@
1
- import { join } from "node:path";
2
- import type { Worker } from "node:worker_threads";
3
- import type { InputNormalizerWorker } from "../types.js";
4
-
5
- interface ServerNormalizerOptions {
6
- root: string;
7
- htmlWorker: Worker;
8
- }
9
-
10
- export function createServerInputNormalizer({
11
- root,
12
- htmlWorker
13
- }: ServerNormalizerOptions): InputNormalizerWorker {
14
- return async (input) => {
15
- // Handle React components with worker
16
- if (typeof input === "function") {
17
- return new Promise((resolve, reject) => {
18
- const handler = (message: any) => {
19
- if (message.type === "CLIENT_REFERENCE") {
20
- htmlWorker.off('message', handler);
21
- resolve([message.ref.$$id, message.ref.$$location]);
22
- }
23
- if (message.type === "ERROR") {
24
- htmlWorker.off('message', handler);
25
- reject(new Error(message.error));
26
- }
27
- };
28
-
29
- htmlWorker.on('message', handler);
30
- htmlWorker.postMessage({
31
- type: "CLIENT_REFERENCE",
32
- id: input.name || 'AnonymousComponent',
33
- location: input.toString(),
34
- key: input.name
35
- });
36
- });
37
- }
38
-
39
- // Handle tuple input [key, path]
40
- if (Array.isArray(input)) {
41
- const [key, path] = input;
42
- return [key, join(root, path)];
43
- }
44
-
45
- // Handle string input
46
- if (typeof input === "string") {
47
- return [input, join(root, input)];
48
- }
49
-
50
- throw new Error(`Invalid input type: ${typeof input}`);
51
- };
52
- }
@@ -1,26 +0,0 @@
1
- import { join } from "node:path";
2
- import type { InputNormalizer } from "../types.js";
3
-
4
- interface StaticNormalizerOptions {
5
- root: string;
6
- }
7
-
8
- export function createStaticInputNormalizer({ root }: StaticNormalizerOptions): InputNormalizer {
9
- return (input) => {
10
- // Handle tuple input [key, path]
11
- if (Array.isArray(input)) {
12
- const [key, path] = input;
13
- // Keep the key as-is for Rollup entry point naming
14
- // Just resolve the path relative to root
15
- return [key, join(root, path)];
16
- }
17
-
18
- // Handle string input
19
- if (typeof input === "string") {
20
- // For single string inputs, let Rollup handle the naming
21
- return [input, join(root, input)];
22
- }
23
-
24
- throw new Error(`Invalid input type: ${typeof input}`);
25
- };
26
- }
@@ -1,36 +0,0 @@
1
- import type { ModuleInfo, PluginContext } from 'rollup';
2
-
3
- interface ModuleManifestEntry {
4
- file: string;
5
- name: string;
6
- src?: string;
7
- isEntry?: boolean;
8
- imports?: string[];
9
- dynamicImports?: string[];
10
- }
11
-
12
- /**
13
- * Get the module manifest from the plugin context, will only work during development
14
- * @param this - The plugin context
15
- * @returns The module manifest
16
- */
17
- export function getModuleManifest(this: PluginContext): Record<string, ModuleManifestEntry> {
18
- const manifest: Record<string, ModuleManifestEntry> = {};
19
-
20
- // Build module graph from plugin context
21
- for (const id of this.getModuleIds()) {
22
- const info: ModuleInfo | null = this.getModuleInfo(id);
23
- if (!info) continue;
24
-
25
- manifest[id] = {
26
- file: info.id,
27
- src: info.id,
28
- name: id,
29
- isEntry: info.isEntry,
30
- imports: Array.from(info.importedIds),
31
- dynamicImports: Array.from(info.dynamicallyImportedIds)
32
- };
33
- }
34
-
35
- return manifest;
36
- }
@@ -1,52 +0,0 @@
1
- import type { Worker } from "node:worker_threads";
2
- import type { InputNormalizerWorker, NormalizerInput } from "../types.js";
3
- import { createInputNormalizer } from "./inputNormalizer.js";
4
-
5
- interface WorkerNormalizerOptions {
6
- root: string;
7
- moduleBase: string;
8
- worker: Worker;
9
- moduleBaseExceptions?: string[];
10
- preserveModulesRoot: boolean | undefined;
11
- }
12
-
13
- export function createInputNormalizerWorker({
14
- root,
15
- moduleBase,
16
- worker,
17
- preserveModulesRoot,
18
- }: WorkerNormalizerOptions): InputNormalizerWorker {
19
- const baseNormalizer = createInputNormalizer({
20
- root,
21
- preserveModulesRoot: preserveModulesRoot === true ? moduleBase : undefined,
22
- });
23
-
24
- return async (input: NormalizerInput): Promise<[string, string]> => {
25
- // Handle React components specially with worker
26
- if (typeof input === "function") {
27
- return new Promise((resolve, reject) => {
28
- const handler = (message: any) => {
29
- if (message.type === "CLIENT_REFERENCE") {
30
- worker.off("message", handler);
31
- resolve([message.ref.$$id, message.ref.$$location]);
32
- }
33
- if (message.type === "ERROR") {
34
- worker.off("message", handler);
35
- reject(new Error(message.error));
36
- }
37
- };
38
-
39
- worker.on("message", handler);
40
- worker.postMessage({
41
- type: "CLIENT_REFERENCE",
42
- id: input.name || "AnonymousComponent",
43
- location: input.toString(),
44
- key: input.name,
45
- });
46
- });
47
- }
48
-
49
- // For all other types, use the base normalizer
50
- return baseNormalizer(input);
51
- };
52
- }
@@ -1,59 +0,0 @@
1
- import { normalizePath } from "vite";
2
-
3
- type NormalizedRelativePathOptions = {
4
- // will automatically remove this part
5
- root: string;
6
- // will automatically see this as a optional extra part of the rootDir that will be removed
7
- outDir: string;
8
- // will ensure it always starts with this path, if it does not it will be added
9
- moduleBase: string;
10
- // will ensure it never starts with a leading /, which in some cases is needed (vite entry), other cases it is not for example from project root /
11
- noLeadingSlash: boolean;
12
- // will ensure it never ends with a trailing /
13
- noTrailingSlash: boolean;
14
- // allowed exception to moduleBase rules
15
- moduleBaseExceptions: string[];
16
- };
17
-
18
- export const createNormalizedRelativePath = (
19
- options: NormalizedRelativePathOptions = {
20
- root: process.cwd(),
21
- outDir: "dist",
22
- moduleBase: "src",
23
- noLeadingSlash: false,
24
- noTrailingSlash: false,
25
- moduleBaseExceptions: [],
26
- }
27
- ) => {
28
- let base =
29
- options.noLeadingSlash && options.moduleBase.startsWith("/")
30
- ? options.moduleBase.slice(1)
31
- : options.moduleBase;
32
- if (options.noTrailingSlash && base.endsWith("/")) {
33
- base = base.slice(0, -1);
34
- }
35
- const removeOutDir = (path: string) =>
36
- (options.outDir as string) === path
37
- ? path.slice(options.outDir.length)
38
- : path;
39
-
40
- const removeRoot = (path: string) => {
41
- const relative = path.startsWith(options.root)
42
- ? path.slice(options.root.length)
43
- : path;
44
- return relative;
45
- };
46
-
47
- const ensureModuleBase = (path: string) => {
48
- let transformed = path;
49
- if (options.noLeadingSlash && path.startsWith("/")) {
50
- transformed = path.slice(1);
51
- }
52
- if (options.noTrailingSlash && transformed.endsWith("/")) {
53
- transformed = transformed.slice(0, -1);
54
- }
55
- return transformed;
56
- };
57
-
58
- return (path: string) => ensureModuleBase(removeOutDir(removeRoot(normalizePath(path))));
59
- };