vite-plugin-react-server 0.3.9 → 0.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) 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 +2 -4
  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.js +10 -7
  13. package/dist/plugin/checkFilesExist.js.map +1 -1
  14. package/dist/plugin/components.js +1 -1
  15. package/dist/plugin/components.js.map +1 -1
  16. package/dist/plugin/config/createModuleIdGenerator.d.ts +11 -0
  17. package/dist/plugin/config/createModuleIdGenerator.d.ts.map +1 -0
  18. package/dist/plugin/config/createModuleIdGenerator.js +44 -0
  19. package/dist/plugin/config/createModuleIdGenerator.js.map +1 -0
  20. package/dist/plugin/config/defaults.d.ts +31 -19
  21. package/dist/plugin/config/defaults.d.ts.map +1 -1
  22. package/dist/plugin/config/defaults.js +22 -27
  23. package/dist/plugin/config/defaults.js.map +1 -1
  24. package/dist/plugin/config/resolveOptions.d.ts +1 -1
  25. package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
  26. package/dist/plugin/config/resolveOptions.js +202 -16
  27. package/dist/plugin/config/resolveOptions.js.map +1 -1
  28. package/dist/plugin/config/resolvePages.d.ts +2 -0
  29. package/dist/plugin/config/resolvePages.d.ts.map +1 -1
  30. package/dist/plugin/config/resolvePages.js.map +1 -1
  31. package/dist/plugin/config/resolveUserConfig.d.ts +2 -2
  32. package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
  33. package/dist/plugin/config/resolveUserConfig.js +161 -50
  34. package/dist/plugin/config/resolveUserConfig.js.map +1 -1
  35. package/dist/plugin/helpers/getBundleManifest.d.ts +20 -0
  36. package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -0
  37. package/dist/plugin/helpers/getBundleManifest.js +43 -0
  38. package/dist/plugin/helpers/getBundleManifest.js.map +1 -0
  39. package/dist/plugin/helpers/getModuleManifest.d.ts +5 -0
  40. package/dist/plugin/helpers/getModuleManifest.d.ts.map +1 -1
  41. package/dist/plugin/helpers/getModuleManifest.js +20 -21
  42. package/dist/plugin/helpers/inputNormalizer.d.ts +15 -1
  43. package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
  44. package/dist/plugin/helpers/inputNormalizer.js +122 -16
  45. package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
  46. package/dist/plugin/helpers/inputNormalizerWorker.d.ts +2 -1
  47. package/dist/plugin/helpers/inputNormalizerWorker.d.ts.map +1 -1
  48. package/dist/plugin/helpers/inputNormalizerWorker.js +10 -7
  49. package/dist/plugin/helpers/tryManifest.d.ts +2 -0
  50. package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
  51. package/dist/plugin/helpers/tryManifest.js +1 -1
  52. package/dist/plugin/helpers/tryManifest.js.map +1 -1
  53. package/dist/plugin/loader/createBuildLoader.d.ts +6 -2
  54. package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
  55. package/dist/plugin/loader/createBuildLoader.js +35 -10
  56. package/dist/plugin/loader/createBuildLoader.js.map +1 -1
  57. package/dist/plugin/loader/createPageLoader.d.ts.map +1 -1
  58. package/dist/plugin/loader/createPageLoader.js +0 -7
  59. package/dist/plugin/plugin.d.ts +0 -1
  60. package/dist/plugin/plugin.d.ts.map +1 -1
  61. package/dist/plugin/plugin.js +2 -1
  62. package/dist/plugin/preserver/plugin.d.ts.map +1 -1
  63. package/dist/plugin/preserver/plugin.js +3 -2
  64. package/dist/plugin/preserver/plugin.js.map +1 -1
  65. package/dist/plugin/react-client/index.d.ts +2 -1
  66. package/dist/plugin/react-client/index.d.ts.map +1 -1
  67. package/dist/plugin/react-client/index.js +19 -1
  68. package/dist/plugin/react-client/index.js.map +1 -0
  69. package/dist/plugin/react-client/plugin.d.ts +2 -2
  70. package/dist/plugin/react-client/plugin.d.ts.map +1 -1
  71. package/dist/plugin/react-client/plugin.js +106 -10
  72. package/dist/plugin/react-client/plugin.js.map +1 -1
  73. package/dist/plugin/react-server/createHandler.d.ts +2 -2
  74. package/dist/plugin/react-server/createHandler.d.ts.map +1 -1
  75. package/dist/plugin/react-server/createHandler.js +5 -5
  76. package/dist/plugin/react-server/createHandler.js.map +1 -1
  77. package/dist/plugin/react-server/createRscStream.d.ts.map +1 -1
  78. package/dist/plugin/react-server/createRscStream.js +15 -1
  79. package/dist/plugin/react-server/createRscStream.js.map +1 -1
  80. package/dist/plugin/react-server/createSsrHandler.d.ts +2 -2
  81. package/dist/plugin/react-server/createSsrHandler.d.ts.map +1 -1
  82. package/dist/plugin/react-server/createSsrHandler.js +5 -12
  83. package/dist/plugin/react-server/index.js +18 -9
  84. package/dist/plugin/react-server/index.js.map +1 -0
  85. package/dist/plugin/react-server/plugin.d.ts.map +1 -1
  86. package/dist/plugin/react-server/plugin.js +133 -127
  87. package/dist/plugin/react-server/plugin.js.map +1 -1
  88. package/dist/plugin/transformer/plugin.d.ts +2 -1
  89. package/dist/plugin/transformer/plugin.d.ts.map +1 -1
  90. package/dist/plugin/transformer/plugin.js +52 -72
  91. package/dist/plugin/transformer/plugin.js.map +1 -1
  92. package/dist/plugin/transformer/transformer-client-components.d.ts +12 -3
  93. package/dist/plugin/transformer/transformer-client-components.d.ts.map +1 -1
  94. package/dist/plugin/transformer/transformer-client-components.js +71 -10
  95. package/dist/plugin/transformer/transformer-client-components.js.map +1 -1
  96. package/dist/plugin/transformer/transformer-server-actions.d.ts +3 -3
  97. package/dist/plugin/transformer/transformer-server-actions.d.ts.map +1 -1
  98. package/dist/plugin/transformer/transformer-server-actions.js +80 -66
  99. package/dist/plugin/transformer/types.d.ts +4 -0
  100. package/dist/plugin/transformer/types.d.ts.map +1 -1
  101. package/dist/plugin/types.d.ts +51 -20
  102. package/dist/plugin/types.d.ts.map +1 -1
  103. package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
  104. package/dist/plugin/worker/html/messageHandler.js +37 -23
  105. package/dist/plugin/worker/html/messageHandler.js.map +1 -1
  106. package/dist/plugin/worker/html/plugin.d.ts.map +1 -1
  107. package/dist/plugin/worker/html/plugin.js +10 -5
  108. package/dist/plugin/worker/html/renderPages.d.ts +7 -6
  109. package/dist/plugin/worker/html/renderPages.d.ts.map +1 -1
  110. package/dist/plugin/worker/html/renderPages.js +112 -57
  111. package/dist/plugin/worker/html/renderPages.js.map +1 -1
  112. package/dist/plugin/worker/loader.d.ts +1 -11
  113. package/dist/plugin/worker/loader.d.ts.map +1 -1
  114. package/dist/plugin/worker/loader.js +2 -2
  115. package/dist/plugin/worker/loader.js.map +1 -1
  116. package/dist/plugin/worker/plugin.d.ts +10 -1
  117. package/dist/plugin/worker/plugin.d.ts.map +1 -1
  118. package/dist/plugin/worker/plugin.js +10 -1
  119. package/dist/plugin/worker/types.d.ts +17 -4
  120. package/dist/plugin/worker/types.d.ts.map +1 -1
  121. package/dist/server.d.ts +1 -3
  122. package/dist/server.d.ts.map +1 -1
  123. package/dist/server.js +1 -3
  124. package/dist/server.js.map +1 -1
  125. package/dist/tsconfig.tsbuildinfo +1 -1
  126. package/package.json +2 -4
  127. package/plugin/assertServerCondition.ts +2 -3
  128. package/plugin/checkFilesExist.ts +10 -10
  129. package/plugin/components.tsx +1 -1
  130. package/plugin/config/createModuleIdGenerator.ts +52 -0
  131. package/plugin/config/defaults.ts +24 -15
  132. package/plugin/config/resolveOptions.ts +253 -25
  133. package/plugin/config/resolvePages.ts +1 -1
  134. package/plugin/config/resolveUserConfig.ts +197 -62
  135. package/plugin/helpers/getBundleManifest.ts +75 -0
  136. package/plugin/helpers/getModuleManifest.ts +5 -0
  137. package/plugin/helpers/inputNormalizer.ts +175 -26
  138. package/plugin/helpers/inputNormalizerWorker.ts +13 -8
  139. package/plugin/helpers/tryManifest.ts +2 -0
  140. package/plugin/loader/createBuildLoader.ts +54 -10
  141. package/plugin/loader/createPageLoader.ts +1 -7
  142. package/plugin/plugin.ts +2 -1
  143. package/plugin/preserver/plugin.ts +2 -1
  144. package/plugin/react-client/index.ts +12 -1
  145. package/plugin/react-client/plugin.ts +127 -12
  146. package/plugin/react-server/createHandler.ts +7 -13
  147. package/plugin/react-server/createRscStream.ts +14 -2
  148. package/plugin/react-server/createSsrHandler.ts +7 -26
  149. package/plugin/react-server/plugin.ts +176 -144
  150. package/plugin/transformer/plugin.ts +69 -94
  151. package/plugin/transformer/transformer-client-components.ts +98 -24
  152. package/plugin/transformer/transformer-server-actions.ts +22 -7
  153. package/plugin/transformer/types.ts +4 -0
  154. package/plugin/types.ts +118 -64
  155. package/plugin/worker/html/messageHandler.ts +46 -31
  156. package/plugin/worker/html/plugin.ts +15 -11
  157. package/plugin/worker/html/renderPages.ts +175 -88
  158. package/plugin/worker/loader.ts +4 -13
  159. package/plugin/worker/plugin.ts +10 -1
  160. package/plugin/worker/types.ts +24 -3
  161. package/dist/node_modules/magic-string/dist/magic-string.es.js +0 -1283
  162. package/dist/node_modules/magic-string/dist/magic-string.es.js.map +0 -1
  163. package/dist/plugin/build/createClientBuildConfig.d.ts +0 -3
  164. package/dist/plugin/build/createClientBuildConfig.d.ts.map +0 -1
  165. package/dist/plugin/build/createClientBuildConfig.js +0 -14
  166. package/dist/plugin/build/createServerBuildConfig.d.ts +0 -12
  167. package/dist/plugin/build/createServerBuildConfig.d.ts.map +0 -1
  168. package/dist/plugin/build/createServerBuildConfig.js +0 -40
  169. package/dist/plugin/build/createSharedBuildConfig.d.ts +0 -5
  170. package/dist/plugin/build/createSharedBuildConfig.d.ts.map +0 -1
  171. package/dist/plugin/build/createSharedBuildConfig.js +0 -28
  172. package/dist/plugin/build/mergeInputs.d.ts +0 -9
  173. package/dist/plugin/build/mergeInputs.d.ts.map +0 -1
  174. package/dist/plugin/build/mergeInputs.js +0 -56
  175. package/dist/plugin/config/moduleIdDefault.d.ts +0 -8
  176. package/dist/plugin/config/moduleIdDefault.d.ts.map +0 -1
  177. package/dist/plugin/config/moduleIdDefault.js +0 -23
  178. package/dist/plugin/config/moduleIdDefault.js.map +0 -1
  179. package/dist/plugin/helpers/getModuleManifest.js.map +0 -1
  180. package/dist/plugin/react-server/createDevMiddleware.d.ts +0 -8
  181. package/dist/plugin/react-server/createDevMiddleware.d.ts.map +0 -1
  182. package/dist/plugin/react-server/createDevMiddleware.js +0 -68
  183. package/dist/plugin/react-server/createDevServer.d.ts +0 -4
  184. package/dist/plugin/react-server/createDevServer.d.ts.map +0 -1
  185. package/dist/plugin/react-server/createDevServer.js +0 -4
  186. package/dist/plugin/react-server/createReactNodeStreamer.d.ts +0 -10
  187. package/dist/plugin/react-server/createReactNodeStreamer.d.ts.map +0 -1
  188. package/dist/plugin/react-server/createReactNodeStreamer.js +0 -7
  189. package/dist/plugin/transformer/transformer-server-actions.js.map +0 -1
  190. package/plugin/build/createClientBuildConfig.ts +0 -21
  191. package/plugin/build/createServerBuildConfig.ts +0 -66
  192. package/plugin/build/createSharedBuildConfig.ts +0 -35
  193. package/plugin/build/mergeInputs.ts +0 -58
  194. package/plugin/config/moduleIdDefault.ts +0 -23
  195. package/plugin/react-server/createDevMiddleware.ts +0 -91
  196. package/plugin/react-server/createDevServer.ts +0 -9
  197. package/plugin/react-server/createReactNodeStreamer.ts +0 -26
@@ -0,0 +1,20 @@
1
+ import type { OutputBundle, PluginContext } from "rollup";
2
+ interface BundleManifestEntry {
3
+ file: string;
4
+ name: string;
5
+ src?: string;
6
+ isEntry?: boolean;
7
+ imports?: string[];
8
+ dynamicImports?: string[];
9
+ css?: string[];
10
+ }
11
+ /**
12
+ * Get the bundle manifest from the plugin context. Will only work during production build
13
+ * @param pluginContext - The plugin context
14
+ * @param bundle - The bundle
15
+ * @param preserveModulesRoot - The preserve modules root
16
+ * @returns The bundle manifest
17
+ */
18
+ export declare function getBundleManifest(pluginContext: PluginContext, bundle: OutputBundle, preserveModulesRoot: string | undefined): Record<string, BundleManifestEntry>;
19
+ export {};
20
+ //# sourceMappingURL=getBundleManifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBundleManifest.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/getBundleManifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,YAAY,EACZ,aAAa,EACd,MAAM,QAAQ,CAAC;AAIhB,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,YAAY,EACpB,mBAAmB,EAAE,MAAM,GAAG,SAAS,GACtC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CA6CrC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * vite-plugin-react-server
3
+ * Copyright (c) Nico Brinkkemper
4
+ * MIT License
5
+ */
6
+ import { createInputNormalizer } from './inputNormalizer.js';
7
+ import { join } from 'path';
8
+
9
+ function getBundleManifest(pluginContext, bundle, preserveModulesRoot) {
10
+ const normalizer = createInputNormalizer({
11
+ root: pluginContext.environment.config.root,
12
+ removeExtension: false,
13
+ preserveModulesRoot: undefined
14
+ });
15
+ if (!bundle) {
16
+ return {};
17
+ }
18
+ return Object.fromEntries(
19
+ Object.entries(bundle).map(([fileName, chunk]) => {
20
+ if (chunk.type !== "chunk") return null;
21
+ const [moduleId, sourcePath] = normalizer(
22
+ chunk.facadeModuleId || chunk.moduleIds[0] || fileName
23
+ );
24
+ return [
25
+ moduleId,
26
+ {
27
+ file: join(pluginContext.environment.config.build.outDir, fileName),
28
+ name: moduleId,
29
+ src: sourcePath.startsWith(pluginContext.environment.config.root) ? sourcePath.slice(pluginContext.environment.config.root.length + 1) : sourcePath,
30
+ isEntry: chunk.isEntry,
31
+ ...Object.keys(chunk.imports).length > 0 ? { imports: chunk.imports } : {},
32
+ ...Object.keys(chunk.dynamicImports).length > 0 ? { dynamicImports: chunk.dynamicImports } : {},
33
+ ...chunk.viteMetadata?.importedCss ? {
34
+ css: Array.from(chunk.viteMetadata.importedCss)
35
+ } : {}
36
+ }
37
+ ];
38
+ }).filter(Boolean)
39
+ );
40
+ }
41
+
42
+ export { getBundleManifest };
43
+ //# sourceMappingURL=getBundleManifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBundleManifest.js","sources":["../../../plugin/helpers/getBundleManifest.ts"],"sourcesContent":["import type {\n NormalizedOutputOptions,\n OutputBundle,\n PluginContext,\n} from \"rollup\";\nimport { createInputNormalizer } from \"./inputNormalizer.js\";\nimport { join } from \"path\";\n\ninterface BundleManifestEntry {\n file: string;\n name: string;\n src?: string;\n isEntry?: boolean;\n imports?: string[];\n dynamicImports?: string[];\n css?: string[];\n}\n\n/**\n * Get the bundle manifest from the plugin context. Will only work during production build\n * @param pluginContext - The plugin context\n * @param bundle - The bundle\n * @param preserveModulesRoot - The preserve modules root\n * @returns The bundle manifest\n */\nexport function getBundleManifest(\n pluginContext: PluginContext,\n bundle: OutputBundle,\n preserveModulesRoot: string | undefined\n): Record<string, BundleManifestEntry> {\n\n const normalizer = createInputNormalizer({\n root: pluginContext.environment.config.root,\n removeExtension: false,\n preserveModulesRoot:\n typeof preserveModulesRoot === \"string\" ? preserveModulesRoot : undefined,\n });\n\n if (!bundle) {\n return {};\n }\n\n return Object.fromEntries(\n Object.entries(bundle)\n .map(([fileName, chunk]) => {\n if (chunk.type !== \"chunk\") return null as never;\n\n // Normalize both the module ID and file path\n const [moduleId, sourcePath] = normalizer(\n chunk.facadeModuleId || chunk.moduleIds[0] || fileName\n );\n return [\n moduleId,\n {\n file: join( pluginContext.environment.config.build.outDir, fileName),\n name: moduleId,\n src: sourcePath.startsWith(pluginContext.environment.config.root) ? sourcePath.slice(pluginContext.environment.config.root.length + 1) : sourcePath,\n isEntry: chunk.isEntry,\n ...(Object.keys(chunk.imports).length > 0\n ? { imports: chunk.imports }\n : {}),\n ...(Object.keys(chunk.dynamicImports).length > 0\n ? { dynamicImports: chunk.dynamicImports }\n : {}),\n ...(chunk.viteMetadata?.importedCss\n ? {\n css: Array.from(chunk.viteMetadata.importedCss),\n }\n : {}),\n },\n ];\n })\n .filter(Boolean)\n );\n}\n"],"names":[],"mappings":";;;;;;;;AAyBgB,SAAA,iBAAA,CACd,aACA,EAAA,MAAA,EACA,mBACqC,EAAA;AAErC,EAAA,MAAM,aAAa,qBAAsB,CAAA;AAAA,IACvC,IAAA,EAAM,aAAc,CAAA,WAAA,CAAY,MAAO,CAAA,IAAA;AAAA,IACvC,eAAiB,EAAA,KAAA;AAAA,IACjB,mBACE,EAAgE;AAAA,GACnE,CAAA;AAED,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAA,OAAO,EAAC;AAAA;AAGV,EAAA,OAAO,MAAO,CAAA,WAAA;AAAA,IACZ,MAAA,CAAO,QAAQ,MAAM,CAAA,CAClB,IAAI,CAAC,CAAC,QAAU,EAAA,KAAK,CAAM,KAAA;AAC1B,MAAI,IAAA,KAAA,CAAM,IAAS,KAAA,OAAA,EAAgB,OAAA,IAAA;AAGnC,MAAM,MAAA,CAAC,QAAU,EAAA,UAAU,CAAI,GAAA,UAAA;AAAA,QAC7B,KAAM,CAAA,cAAA,IAAkB,KAAM,CAAA,SAAA,CAAU,CAAC,CAAK,IAAA;AAAA,OAChD;AACA,MAAO,OAAA;AAAA,QACL,QAAA;AAAA,QACA;AAAA,UACE,MAAM,IAAM,CAAA,aAAA,CAAc,YAAY,MAAO,CAAA,KAAA,CAAM,QAAQ,QAAQ,CAAA;AAAA,UACnE,IAAM,EAAA,QAAA;AAAA,UACN,KAAK,UAAW,CAAA,UAAA,CAAW,aAAc,CAAA,WAAA,CAAY,OAAO,IAAI,CAAA,GAAI,UAAW,CAAA,KAAA,CAAM,cAAc,WAAY,CAAA,MAAA,CAAO,IAAK,CAAA,MAAA,GAAS,CAAC,CAAI,GAAA,UAAA;AAAA,UACzI,SAAS,KAAM,CAAA,OAAA;AAAA,UACf,GAAI,MAAA,CAAO,IAAK,CAAA,KAAA,CAAM,OAAO,CAAA,CAAE,MAAS,GAAA,CAAA,GACpC,EAAE,OAAA,EAAS,KAAM,CAAA,OAAA,KACjB,EAAC;AAAA,UACL,GAAI,MAAA,CAAO,IAAK,CAAA,KAAA,CAAM,cAAc,CAAA,CAAE,MAAS,GAAA,CAAA,GAC3C,EAAE,cAAA,EAAgB,KAAM,CAAA,cAAA,KACxB,EAAC;AAAA,UACL,GAAI,KAAM,CAAA,YAAA,EAAc,WACpB,GAAA;AAAA,YACE,GAAK,EAAA,KAAA,CAAM,IAAK,CAAA,KAAA,CAAM,aAAa,WAAW;AAAA,cAEhD;AAAC;AACP,OACF;AAAA,KACD,CACA,CAAA,MAAA,CAAO,OAAO;AAAA,GACnB;AACF;;;;"}
@@ -7,6 +7,11 @@ interface ModuleManifestEntry {
7
7
  imports?: string[];
8
8
  dynamicImports?: string[];
9
9
  }
10
+ /**
11
+ * Get the module manifest from the plugin context, will only work during development
12
+ * @param this - The plugin context
13
+ * @returns The module manifest
14
+ */
10
15
  export declare function getModuleManifest(this: PluginContext): Record<string, ModuleManifestEntry>;
11
16
  export {};
12
17
  //# sourceMappingURL=getModuleManifest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getModuleManifest.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/getModuleManifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,QAAQ,CAAC;AAExD,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAmB1F"}
1
+ {"version":3,"file":"getModuleManifest.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/getModuleManifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,QAAQ,CAAC;AAExD,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAmB1F"}
@@ -1,24 +1,23 @@
1
1
  /**
2
- * vite-plugin-react-server
3
- * Copyright (c) Nico Brinkkemper
4
- * MIT License
2
+ * Get the module manifest from the plugin context, will only work during development
3
+ * @param this - The plugin context
4
+ * @returns The module manifest
5
5
  */
6
- function getModuleManifest() {
7
- const manifest = {};
8
- for (const id of this.getModuleIds()) {
9
- const info = this.getModuleInfo(id);
10
- if (!info) continue;
11
- manifest[id] = {
12
- file: info.id,
13
- src: info.id,
14
- name: id,
15
- isEntry: info.isEntry,
16
- imports: Array.from(info.importedIds),
17
- dynamicImports: Array.from(info.dynamicallyImportedIds)
18
- };
19
- }
20
- return manifest;
6
+ export function getModuleManifest() {
7
+ const manifest = {};
8
+ // Build module graph from plugin context
9
+ for (const id of this.getModuleIds()) {
10
+ const info = this.getModuleInfo(id);
11
+ if (!info)
12
+ continue;
13
+ manifest[id] = {
14
+ file: info.id,
15
+ src: info.id,
16
+ name: id,
17
+ isEntry: info.isEntry,
18
+ imports: Array.from(info.importedIds),
19
+ dynamicImports: Array.from(info.dynamicallyImportedIds)
20
+ };
21
+ }
22
+ return manifest;
21
23
  }
22
-
23
- export { getModuleManifest };
24
- //# sourceMappingURL=getModuleManifest.js.map
@@ -1,3 +1,17 @@
1
1
  import type { InputNormalizer } from "../types.js";
2
- export declare function createInputNormalizer(root: string): InputNormalizer;
2
+ type CreateInputNormalizerProps = {
3
+ root: string;
4
+ preserveModulesRoot?: string | undefined;
5
+ removeExtension?: boolean | RegExp | string | ((path: string) => boolean);
6
+ moduleBasePath?: string;
7
+ };
8
+ /**
9
+ * @description Create a function that normalizes the input
10
+ * @param root - The root of the project
11
+ * @param preserveModulesRoot - The root of the preserve modules
12
+ * @param removeExtension - Whether to remove the extension of the file
13
+ * @returns A function that normalizes the input
14
+ */
15
+ export declare function createInputNormalizer({ root, preserveModulesRoot, removeExtension, moduleBasePath, }: CreateInputNormalizerProps): InputNormalizer;
16
+ export {};
3
17
  //# sourceMappingURL=inputNormalizer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inputNormalizer.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/inputNormalizer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAC;AAEpE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CA+BnE"}
1
+ {"version":3,"file":"inputNormalizer.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/inputNormalizer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAC;AAIpE,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;IAC1E,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAsHD;;;;;;GAMG;AACJ,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,mBAA+B,EAC/B,eAA2C,EAC3C,cAAoB,GACrB,EAAE,0BAA0B,GAAG,eAAe,CA6C9C"}
@@ -3,29 +3,135 @@
3
3
  * Copyright (c) Nico Brinkkemper
4
4
  * MIT License
5
5
  */
6
- import { join } from 'path';
7
6
  import { normalizePath } from 'vite';
7
+ import { join } from 'path';
8
8
  import { DEFAULT_CONFIG } from '../config/defaults.js';
9
9
 
10
- function createInputNormalizer(root) {
11
- const normalizeKey = (key) => {
12
- return key.replace(DEFAULT_CONFIG.FILE_REGEX, "").replace(/^\/+/, "");
13
- };
14
- return (input) => {
15
- if (Array.isArray(input)) {
16
- const [key, path] = input;
10
+ const resolveExtensionOptions = (removeExtension) => {
11
+ if (typeof removeExtension === "boolean") {
12
+ if (removeExtension) {
13
+ return (path) => {
14
+ const extensionIndex = path.lastIndexOf(".");
15
+ return extensionIndex !== -1 ? path.slice(0, extensionIndex) : path;
16
+ };
17
+ }
18
+ return (path) => path;
19
+ }
20
+ if (typeof removeExtension === "string") {
21
+ return (path) => path.replace(removeExtension, "");
22
+ }
23
+ if (removeExtension instanceof RegExp) {
24
+ return (path) => removeExtension.test(path) ? path.replace(removeExtension, "") : path;
25
+ }
26
+ if (typeof removeExtension === "function") {
27
+ return (path) => {
28
+ const extIndex = path.lastIndexOf(".");
29
+ if (extIndex !== -1) {
30
+ const extension = path.slice(extIndex);
31
+ if (removeExtension(extension)) {
32
+ return path.slice(0, extIndex);
33
+ }
34
+ }
35
+ return path;
36
+ };
37
+ }
38
+ return (path) => path;
39
+ };
40
+ const resolveRootOption = (root, preserveModulesRoot) => {
41
+ if (typeof root !== "string" && typeof preserveModulesRoot !== "string") {
42
+ return "";
43
+ }
44
+ if (typeof preserveModulesRoot === "string" && typeof root === "string") {
45
+ const normalizedRoot = normalizePath(root);
46
+ const normalizedPreserveModulesRoot = normalizePath(preserveModulesRoot);
47
+ if (normalizedPreserveModulesRoot.startsWith(normalizedRoot)) {
48
+ return join(normalizedPreserveModulesRoot, "/");
49
+ }
50
+ return join(normalizedRoot, normalizedPreserveModulesRoot, "/");
51
+ }
52
+ if (typeof preserveModulesRoot === "string" && typeof root !== "string") {
53
+ const normalizedRoot = normalizePath(root);
54
+ const normalizedPreserveModulesRoot = normalizePath(preserveModulesRoot);
55
+ if (normalizedRoot.startsWith(normalizedPreserveModulesRoot)) {
56
+ return join(normalizedPreserveModulesRoot, "/");
57
+ }
58
+ return join(normalizedRoot, normalizedPreserveModulesRoot, "/");
59
+ }
60
+ if (typeof preserveModulesRoot !== "string" && typeof root === "string") {
61
+ const normalizedRoot = normalizePath(root);
62
+ return join(normalizedRoot, "/");
63
+ }
64
+ return "/";
65
+ };
66
+ const createKeyNormalizer = ({
67
+ normalizedRoot,
68
+ preserveModulesRoot,
69
+ handleExtension
70
+ }) => (key) => {
71
+ const normalPath = normalizePath(key);
72
+ const noRoot = normalPath.startsWith(normalizedRoot) ? normalPath.slice(normalizedRoot.length) : normalPath;
73
+ const noExtension = handleExtension(noRoot);
74
+ let noRelativeNorAbsolute = noExtension;
75
+ while (noRelativeNorAbsolute.startsWith("/") || noRelativeNorAbsolute.startsWith(".")) {
76
+ noRelativeNorAbsolute = noRelativeNorAbsolute.slice(1);
77
+ }
78
+ if (preserveModulesRoot) {
79
+ const removedModulesRoot = noRelativeNorAbsolute.startsWith(
80
+ preserveModulesRoot
81
+ ) ? noRelativeNorAbsolute.slice(preserveModulesRoot.length) : noRelativeNorAbsolute;
82
+ return removedModulesRoot.startsWith(normalizedRoot) ? removedModulesRoot.slice(normalizedRoot.length) : removedModulesRoot;
83
+ }
84
+ return noRelativeNorAbsolute;
85
+ };
86
+ const createPathNormalizer = ({ normalizedRoot, moduleBasePath }) => (path) => {
87
+ if (typeof path !== "string") {
88
+ throw new Error(`Invalid path: ${JSON.stringify(path)}`);
89
+ }
90
+ const normalPath = normalizePath(path);
91
+ const noRoot = normalPath.startsWith(normalizedRoot) ? normalPath.slice(normalizedRoot.length) : normalPath;
92
+ if (noRoot.startsWith(moduleBasePath)) {
93
+ return noRoot.slice(1);
94
+ }
95
+ return noRoot;
96
+ };
97
+ function createInputNormalizer({
98
+ root,
99
+ preserveModulesRoot = undefined,
100
+ removeExtension = DEFAULT_CONFIG.FILE_REGEX,
101
+ moduleBasePath = "/"
102
+ }) {
103
+ const normalizedRoot = resolveRootOption(root, preserveModulesRoot);
104
+ const handleExtension = resolveExtensionOptions(removeExtension);
105
+ const normalizeEntryKey = createKeyNormalizer({
106
+ normalizedRoot,
107
+ preserveModulesRoot,
108
+ handleExtension
109
+ });
110
+ const normalizeEntryPath = createPathNormalizer({ normalizedRoot, moduleBasePath });
111
+ return function normalizeInput(id) {
112
+ if (Array.isArray(id)) {
113
+ const [key, path] = id;
114
+ if (typeof key === "string" && Array.isArray(path) && path.length === 2) {
115
+ const isNumber = !isNaN(Number(key));
116
+ if (isNumber) {
117
+ return normalizeInput([path[0], path[1]]);
118
+ }
119
+ return normalizeInput([join(key, path[0]), path[1]]);
120
+ }
121
+ if (typeof key !== "string" || typeof path !== "string") {
122
+ throw new Error(`Invalid input: ${JSON.stringify(id)}`);
123
+ }
124
+ return [normalizeEntryKey(key), normalizeEntryPath(path)];
125
+ } else if (typeof id === "string") {
126
+ return [normalizeEntryKey(id), normalizeEntryPath(id)];
127
+ } else if (typeof id === "object" && id !== null && "$$typeof" in id && "$$id" in id && typeof id.$$id === "string") {
17
128
  const normalized = [
18
- normalizeKey(key),
19
- normalizePath(join(root, path))
129
+ normalizeEntryKey(id.$$id),
130
+ normalizeEntryPath(id.$$id)
20
131
  ];
21
132
  return normalized;
22
133
  }
23
- if (typeof input === "string") {
24
- const key = normalizeKey(input);
25
- const path = normalizePath(join(root, input));
26
- return [key, path];
27
- }
28
- throw new Error(`Invalid input type: ${typeof input}`);
134
+ throw new Error(`Invalid input type: ${typeof id}`);
29
135
  };
30
136
  }
31
137
 
@@ -1 +1 @@
1
- {"version":3,"file":"inputNormalizer.js","sources":["../../../plugin/helpers/inputNormalizer.ts"],"sourcesContent":["import { join } from \"path\";\nimport { normalizePath } from \"vite\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\nimport type { InputNormalizer, NormalizerInput } from \"../types.js\";\n\nexport function createInputNormalizer(root: string): InputNormalizer {\n\n // Normalize a key by removing file extensions and leading slashes\n const normalizeKey = (key: string): string => {\n return key\n .replace(DEFAULT_CONFIG.FILE_REGEX, \"\") // Remove TypeScript/JavaScript extensions\n .replace(/^\\/+/, \"\"); // Remove leading slashes\n };\n\n // Main normalize function\n return (input: NormalizerInput): [string, string] => {\n \n // Handle tuple input [key, path]\n if (Array.isArray(input)) {\n const [key, path] = input;\n const normalized: [string, string] = [\n normalizeKey(key),\n normalizePath(join(root, path))\n ] \n return normalized;\n }\n\n // Handle string input\n if (typeof input === \"string\") {\n const key = normalizeKey(input);\n const path = normalizePath(join(root, input)); \n return [key, path];\n }\n\n throw new Error(`Invalid input type: ${typeof input}`);\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAKO,SAAS,sBAAsB,IAA+B,EAAA;AAGnE,EAAM,MAAA,YAAA,GAAe,CAAC,GAAwB,KAAA;AAC5C,IAAO,OAAA,GAAA,CACJ,QAAQ,cAAe,CAAA,UAAA,EAAY,EAAE,CACrC,CAAA,OAAA,CAAQ,QAAQ,EAAE,CAAA;AAAA,GACvB;AAGA,EAAA,OAAO,CAAC,KAA6C,KAAA;AAGnD,IAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,KAAK,CAAG,EAAA;AACxB,MAAM,MAAA,CAAC,GAAK,EAAA,IAAI,CAAI,GAAA,KAAA;AACpB,MAAA,MAAM,UAA+B,GAAA;AAAA,QACnC,aAAa,GAAG,CAAA;AAAA,QAChB,aAAc,CAAA,IAAA,CAAK,IAAM,EAAA,IAAI,CAAC;AAAA,OAChC;AACA,MAAO,OAAA,UAAA;AAAA;AAIT,IAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC7B,MAAM,MAAA,GAAA,GAAM,aAAa,KAAK,CAAA;AAC9B,MAAA,MAAM,IAAO,GAAA,aAAA,CAAc,IAAK,CAAA,IAAA,EAAM,KAAK,CAAC,CAAA;AAC5C,MAAO,OAAA,CAAC,KAAK,IAAI,CAAA;AAAA;AAGnB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAuB,oBAAA,EAAA,OAAO,KAAK,CAAE,CAAA,CAAA;AAAA,GACvD;AACF;;;;"}
1
+ {"version":3,"file":"inputNormalizer.js","sources":["../../../plugin/helpers/inputNormalizer.ts"],"sourcesContent":["import { normalizePath } from \"vite\";\nimport type { InputNormalizer, NormalizerInput } from \"../types.js\";\nimport { join } from \"path\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\n\ntype CreateInputNormalizerProps = {\n root: string;\n preserveModulesRoot?: string | undefined;\n removeExtension?: boolean | RegExp | string | ((path: string) => boolean);\n moduleBasePath?: string;\n};\n\nconst resolveExtensionOptions = (\n removeExtension: CreateInputNormalizerProps[\"removeExtension\"]\n) => {\n if (typeof removeExtension === \"boolean\") {\n if (removeExtension) {\n return (path: string) => {\n const extensionIndex = path.lastIndexOf(\".\");\n return extensionIndex !== -1 ? path.slice(0, extensionIndex) : path;\n };\n }\n return (path: string) => path;\n }\n if (typeof removeExtension === \"string\") {\n return (path: string) => path.replace(removeExtension, \"\");\n }\n if (removeExtension instanceof RegExp) {\n return (path: string) =>\n removeExtension.test(path) ? path.replace(removeExtension, \"\") : path;\n }\n if (typeof removeExtension === \"function\") {\n return (path: string) => {\n const extIndex = path.lastIndexOf(\".\");\n if (extIndex !== -1) {\n const extension = path.slice(extIndex);\n if (removeExtension(extension)) {\n return path.slice(0, extIndex);\n }\n }\n return path;\n };\n }\n return (path: string) => path;\n};\n\nconst resolveRootOption = (\n root: CreateInputNormalizerProps[\"root\"],\n preserveModulesRoot: CreateInputNormalizerProps[\"preserveModulesRoot\"]\n) => {\n if (typeof root !== \"string\" && typeof preserveModulesRoot !== \"string\") {\n return \"\";\n }\n if (typeof preserveModulesRoot === \"string\" && typeof root === \"string\") {\n const normalizedRoot = normalizePath(root);\n const normalizedPreserveModulesRoot = normalizePath(preserveModulesRoot);\n if (normalizedPreserveModulesRoot.startsWith(normalizedRoot)) {\n return join(normalizedPreserveModulesRoot, \"/\");\n }\n return join(normalizedRoot, normalizedPreserveModulesRoot, \"/\");\n }\n if (typeof preserveModulesRoot === \"string\" && typeof root !== \"string\") {\n const normalizedRoot = normalizePath(root);\n const normalizedPreserveModulesRoot = normalizePath(preserveModulesRoot);\n if (normalizedRoot.startsWith(normalizedPreserveModulesRoot)) {\n return join(normalizedPreserveModulesRoot, \"/\");\n }\n return join(normalizedRoot, normalizedPreserveModulesRoot, \"/\");\n }\n if (typeof preserveModulesRoot !== \"string\" && typeof root === \"string\") {\n const normalizedRoot = normalizePath(root);\n return join(normalizedRoot, \"/\");\n }\n return \"/\";\n};\nconst createKeyNormalizer =\n ({\n normalizedRoot,\n preserveModulesRoot,\n handleExtension,\n }: {\n normalizedRoot: string;\n preserveModulesRoot: string | undefined;\n handleExtension: (path: string) => string;\n }) =>\n (key: string) => {\n const normalPath = normalizePath(key);\n const noRoot = normalPath.startsWith(normalizedRoot)\n ? normalPath.slice(normalizedRoot.length)\n : normalPath;\n const noExtension = handleExtension(noRoot);\n\n let noRelativeNorAbsolute = noExtension;\n while (\n noRelativeNorAbsolute.startsWith(\"/\") ||\n noRelativeNorAbsolute.startsWith(\".\")\n ) {\n noRelativeNorAbsolute = noRelativeNorAbsolute.slice(1);\n }\n if (preserveModulesRoot) {\n const removedModulesRoot = noRelativeNorAbsolute.startsWith(\n preserveModulesRoot\n )\n ? noRelativeNorAbsolute.slice(preserveModulesRoot.length)\n : noRelativeNorAbsolute;\n return removedModulesRoot.startsWith(normalizedRoot)\n ? removedModulesRoot.slice(normalizedRoot.length)\n : removedModulesRoot;\n }\n return noRelativeNorAbsolute;\n };\n\nconst createPathNormalizer =\n ({ normalizedRoot, moduleBasePath }: { normalizedRoot: string, moduleBasePath: string }) =>\n (path: string) => {\n if(typeof path !== 'string') {\n throw new Error(`Invalid path: ${JSON.stringify(path)}`);\n }\n const normalPath = normalizePath(path);\n const noRoot = normalPath.startsWith(normalizedRoot)\n ? normalPath.slice(normalizedRoot.length)\n : normalPath;\n // no leading slash when starting with module base\n if(noRoot.startsWith(moduleBasePath)) {\n return noRoot.slice(1);\n }\n return noRoot;\n };\n /**\n * @description Create a function that normalizes the input\n * @param root - The root of the project\n * @param preserveModulesRoot - The root of the preserve modules\n * @param removeExtension - Whether to remove the extension of the file\n * @returns A function that normalizes the input\n */\nexport function createInputNormalizer({\n root,\n preserveModulesRoot = undefined,\n removeExtension = DEFAULT_CONFIG.FILE_REGEX,\n moduleBasePath = \"/\",\n}: CreateInputNormalizerProps): InputNormalizer {\n const normalizedRoot = resolveRootOption(root, preserveModulesRoot);\n const handleExtension = resolveExtensionOptions(removeExtension);\n\n const normalizeEntryKey = createKeyNormalizer({\n normalizedRoot,\n preserveModulesRoot,\n handleExtension,\n });\n\n const normalizeEntryPath = createPathNormalizer({ normalizedRoot, moduleBasePath });\n return function normalizeInput(id: NormalizerInput): [string, string] {\n // Normalize both paths to use POSIX separators\n if (Array.isArray(id)) {\n const [key, path] = id;\n if(typeof key === 'string' && Array.isArray(path) && path.length === 2) {\n const isNumber = !isNaN(Number(key));\n if(isNumber) {\n // ignore it\n return normalizeInput([path[0], path[1]]);\n }\n return normalizeInput([join(key, path[0]), path[1]]);\n }\n if(typeof key !== 'string' || typeof path !== 'string') {\n throw new Error(`Invalid input: ${JSON.stringify(id)}`);\n }\n return [normalizeEntryKey(key), normalizeEntryPath(path)];\n } else if (typeof id === \"string\") {\n // Return both the normalized ID and original normalized path\n return [normalizeEntryKey(id), normalizeEntryPath(id)];\n } else if (\n typeof id === \"object\" &&\n id !== null &&\n \"$$typeof\" in id &&\n \"$$id\" in id &&\n typeof id.$$id === \"string\"\n ) {\n const normalized: [string, string] = [\n normalizeEntryKey(id.$$id),\n normalizeEntryPath(id.$$id),\n ];\n return normalized;\n }\n throw new Error(`Invalid input type: ${typeof id}`);\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAYA,MAAM,uBAAA,GAA0B,CAC9B,eACG,KAAA;AACH,EAAI,IAAA,OAAO,oBAAoB,SAAW,EAAA;AACxC,IAAA,IAAI,eAAiB,EAAA;AACnB,MAAA,OAAO,CAAC,IAAiB,KAAA;AACvB,QAAM,MAAA,cAAA,GAAiB,IAAK,CAAA,WAAA,CAAY,GAAG,CAAA;AAC3C,QAAA,OAAO,mBAAmB,EAAK,GAAA,IAAA,CAAK,KAAM,CAAA,CAAA,EAAG,cAAc,CAAI,GAAA,IAAA;AAAA,OACjE;AAAA;AAEF,IAAA,OAAO,CAAC,IAAiB,KAAA,IAAA;AAAA;AAE3B,EAAI,IAAA,OAAO,oBAAoB,QAAU,EAAA;AACvC,IAAA,OAAO,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,iBAAiB,EAAE,CAAA;AAAA;AAE3D,EAAA,IAAI,2BAA2B,MAAQ,EAAA;AACrC,IAAO,OAAA,CAAC,IACN,KAAA,eAAA,CAAgB,IAAK,CAAA,IAAI,IAAI,IAAK,CAAA,OAAA,CAAQ,eAAiB,EAAA,EAAE,CAAI,GAAA,IAAA;AAAA;AAErE,EAAI,IAAA,OAAO,oBAAoB,UAAY,EAAA;AACzC,IAAA,OAAO,CAAC,IAAiB,KAAA;AACvB,MAAM,MAAA,QAAA,GAAW,IAAK,CAAA,WAAA,CAAY,GAAG,CAAA;AACrC,MAAA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9
  }
9
- export declare function createInputNormalizerWorker({ root, worker, }: WorkerNormalizerOptions): InputNormalizerWorker;
10
+ export declare function createInputNormalizerWorker({ root, moduleBase, worker, preserveModulesRoot, }: WorkerNormalizerOptions): InputNormalizerWorker;
10
11
  export {};
11
12
  //# sourceMappingURL=inputNormalizerWorker.d.ts.map
@@ -1 +1 @@
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
+ {"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;IAChC,mBAAmB,EAAE,OAAO,GAAG,SAAS,CAAC;CAC1C;AAED,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,EACJ,UAAU,EACV,MAAM,EACN,mBAAmB,GACpB,EAAE,uBAAuB,GAAG,qBAAqB,CAkCjD"}
@@ -1,26 +1,29 @@
1
1
  import { createInputNormalizer } from "./inputNormalizer.js";
2
- export function createInputNormalizerWorker({ root, worker, }) {
3
- const baseNormalizer = createInputNormalizer(root);
2
+ export function createInputNormalizerWorker({ root, moduleBase, worker, preserveModulesRoot, }) {
3
+ const baseNormalizer = createInputNormalizer({
4
+ root,
5
+ preserveModulesRoot: preserveModulesRoot === true ? moduleBase : undefined,
6
+ });
4
7
  return async (input) => {
5
8
  // Handle React components specially with worker
6
9
  if (typeof input === "function") {
7
10
  return new Promise((resolve, reject) => {
8
11
  const handler = (message) => {
9
12
  if (message.type === "CLIENT_REFERENCE") {
10
- worker.off('message', handler);
13
+ worker.off("message", handler);
11
14
  resolve([message.ref.$$id, message.ref.$$location]);
12
15
  }
13
16
  if (message.type === "ERROR") {
14
- worker.off('message', handler);
17
+ worker.off("message", handler);
15
18
  reject(new Error(message.error));
16
19
  }
17
20
  };
18
- worker.on('message', handler);
21
+ worker.on("message", handler);
19
22
  worker.postMessage({
20
23
  type: "CLIENT_REFERENCE",
21
- id: input.name || 'AnonymousComponent',
24
+ id: input.name || "AnonymousComponent",
22
25
  location: input.toString(),
23
- key: input.name
26
+ key: input.name,
24
27
  });
25
28
  });
26
29
  }
@@ -7,9 +7,11 @@ type TryManifestOptions<SSR extends boolean> = {
7
7
  export declare function tryManifest<SSR extends boolean>(options: TryManifestOptions<SSR>): {
8
8
  type: "success";
9
9
  manifest: SSR extends true ? Record<string, string[]> : Manifest;
10
+ error?: never;
10
11
  } | {
11
12
  type: "error";
12
13
  error: Error;
14
+ manifest?: never;
13
15
  };
14
16
  export {};
15
17
  //# sourceMappingURL=tryManifest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tryManifest.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/tryManifest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAErC,KAAK,kBAAkB,CAAC,GAAG,SAAS,OAAO,IAAI;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC;AAEF,wBAAgB,WAAW,CAAC,GAAG,SAAS,OAAO,EAAE,OAAO,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAAG;IAClF,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,GAAG,SAAS,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC;CAClE,GAAG;IACF,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;CACd,CAoBA"}
1
+ {"version":3,"file":"tryManifest.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/tryManifest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAErC,KAAK,kBAAkB,CAAC,GAAG,SAAS,OAAO,IAAI;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC;AAEF,wBAAgB,WAAW,CAAC,GAAG,SAAS,OAAO,EAAE,OAAO,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAAG;IAClF,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,GAAG,SAAS,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC;IACjE,KAAK,CAAC,EAAC,KAAK,CAAA;CACb,GAAG;IACF,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAC,KAAK,CAAA;CAChB,CAoBA"}
@@ -11,7 +11,7 @@ function tryManifest(options) {
11
11
  options.root,
12
12
  options.outDir,
13
13
  ".vite",
14
- "manifest.json"
14
+ options.ssrManifest ? "ssr-manifest.json" : "manifest.json"
15
15
  );
16
16
  try {
17
17
  const result = JSON.parse(readFileSync(manifestPath, "utf-8"));
@@ -1 +1 @@
1
- {"version":3,"file":"tryManifest.js","sources":["../../../plugin/helpers/tryManifest.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport type { Manifest } from \"vite\";\n\ntype TryManifestOptions<SSR extends boolean> = {\n root: string;\n outDir: string;\n ssrManifest: SSR;\n};\n\nexport function tryManifest<SSR extends boolean>(options: TryManifestOptions<SSR>): {\n type: \"success\";\n manifest: SSR extends true ? Record<string, string[]> : Manifest;\n} | {\n type: \"error\";\n error: Error;\n} {\n const manifestPath = resolve(\n options.root,\n options.outDir,\n \".vite\",\n options.ssrManifest ? \"ssr-manifest.json\" : \"manifest.json\"\n );\n try {\n const result= JSON.parse(readFileSync(manifestPath, \"utf-8\"));\n return {\n type: \"success\",\n manifest: result,\n }\n } catch (e) {\n console.log(\"No manifest found\", manifestPath);\n return {\n type: \"error\",\n error: e as Error,\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAUO,SAAS,YAAiC,OAM/C,EAAA;AACA,EAAA,MAAM,YAAe,GAAA,OAAA;AAAA,IACnB,OAAQ,CAAA,IAAA;AAAA,IACR,OAAQ,CAAA,MAAA;AAAA,IACR,OAAA;AAAA,IAC4C;AAAA,GAC9C;AACA,EAAI,IAAA;AACF,IAAA,MAAM,SAAS,IAAK,CAAA,KAAA,CAAM,YAAa,CAAA,YAAA,EAAc,OAAO,CAAC,CAAA;AAC7D,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,SAAA;AAAA,MACN,QAAU,EAAA;AAAA,KACZ;AAAA,WACO,CAAG,EAAA;AACV,IAAQ,OAAA,CAAA,GAAA,CAAI,qBAAqB,YAAY,CAAA;AAC7C,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,OAAA;AAAA,MACN,KAAO,EAAA;AAAA,KACT;AAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"tryManifest.js","sources":["../../../plugin/helpers/tryManifest.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport type { Manifest } from \"vite\";\n\ntype TryManifestOptions<SSR extends boolean> = {\n root: string;\n outDir: string;\n ssrManifest: SSR;\n};\n\nexport function tryManifest<SSR extends boolean>(options: TryManifestOptions<SSR>): {\n type: \"success\";\n manifest: SSR extends true ? Record<string, string[]> : Manifest;\n error?:never\n} | {\n type: \"error\";\n error: Error;\n manifest?:never\n} {\n const manifestPath = resolve(\n options.root,\n options.outDir,\n \".vite\",\n options.ssrManifest ? \"ssr-manifest.json\" : \"manifest.json\"\n );\n try {\n const result= JSON.parse(readFileSync(manifestPath, \"utf-8\"));\n return {\n type: \"success\",\n manifest: result,\n }\n } catch (e) {\n console.log(\"No manifest found\", manifestPath);\n return {\n type: \"error\",\n error: e as Error,\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAUO,SAAS,YAAiC,OAQ/C,EAAA;AACA,EAAA,MAAM,YAAe,GAAA,OAAA;AAAA,IACnB,OAAQ,CAAA,IAAA;AAAA,IACR,OAAQ,CAAA,MAAA;AAAA,IACR,OAAA;AAAA,IACA,OAAA,CAAQ,cAAc,mBAAsB,GAAA;AAAA,GAC9C;AACA,EAAI,IAAA;AACF,IAAA,MAAM,SAAS,IAAK,CAAA,KAAA,CAAM,YAAa,CAAA,YAAA,EAAc,OAAO,CAAC,CAAA;AAC7D,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,SAAA;AAAA,MACN,QAAU,EAAA;AAAA,KACZ;AAAA,WACO,CAAG,EAAA;AACV,IAAQ,OAAA,CAAA,GAAA,CAAI,qBAAqB,YAAY,CAAA;AAC7C,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,OAAA;AAAA,MACN,KAAO,EAAA;AAAA,KACT;AAAA;AAEJ;;;;"}
@@ -1,9 +1,13 @@
1
1
  import type { PluginContext } from "rollup";
2
- import type { ResolvedUserConfig } from "../../server.js";
2
+ import type { ResolvedUserConfig, ResolvedUserOptions } from "../../server.js";
3
+ import type { Manifest } from "vite";
3
4
  export interface BuildLoaderOptions {
4
5
  root: string;
5
6
  pluginContext: PluginContext;
6
7
  userConfig: ResolvedUserConfig;
8
+ userOptions: ResolvedUserOptions;
9
+ serverManifest: Manifest;
10
+ clientManifest: Manifest;
7
11
  }
8
- export declare function createBuildLoader({ root, userConfig, }: BuildLoaderOptions): (id: string) => Promise<any>;
12
+ export declare function createBuildLoader({ userConfig, userOptions, pluginContext, clientManifest, serverManifest, }: BuildLoaderOptions): (id: string) => Promise<any>;
9
13
  //# sourceMappingURL=createBuildLoader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createBuildLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createBuildLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,kBAAkB,CAAC;CAChC;AAED,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,UAAU,GACX,EAAE,kBAAkB,QACD,MAAM,kBAOzB"}
1
+ {"version":3,"file":"createBuildLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createBuildLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGrC,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,WAAW,EAAE,mBAAmB,CAAC;IACjC,cAAc,EAAE,QAAQ,CAAC;IACzB,cAAc,EAAE,QAAQ,CAAC;CAC1B;AAED,wBAAgB,iBAAiB,CAAC,EAChC,UAAU,EACV,WAAW,EACX,aAAa,EACb,cAAc,EACd,cAAc,GACf,EAAE,kBAAkB,QAUmB,MAAM,kBAmC7C"}
@@ -3,19 +3,44 @@
3
3
  * Copyright (c) Nico Brinkkemper
4
4
  * MIT License
5
5
  */
6
- import { join } from 'path';
7
- import { DEFAULT_CONFIG } from '../config/defaults.js';
6
+ import { join } from 'node:path';
7
+ import { createInputNormalizer } from '../helpers/inputNormalizer.js';
8
8
 
9
9
  function createBuildLoader({
10
- root,
11
- userConfig
10
+ userConfig,
11
+ userOptions,
12
+ pluginContext,
13
+ clientManifest,
14
+ serverManifest
12
15
  }) {
13
- return async (id) => {
14
- return import(join(
15
- root,
16
- userConfig.build.outDir,
17
- id.replace(DEFAULT_CONFIG.FILE_REGEX, "") + ".js"
18
- ));
16
+ const root = pluginContext.environment.config.root ?? userConfig.root ?? userOptions.projectRoot ?? process.cwd();
17
+ const normalizer = createInputNormalizer({
18
+ root: userConfig.root,
19
+ preserveModulesRoot: userOptions.build.preserveModulesRoot === true ? userOptions.moduleBase : undefined
20
+ });
21
+ return async function buildLoader(id) {
22
+ const [normalizedId] = normalizer(id.replace(/^\//, ""));
23
+ const clientEntry = Object.entries(clientManifest).find(([key]) => {
24
+ const [keyNormalized] = normalizer(key);
25
+ return keyNormalized === normalizedId;
26
+ });
27
+ if (clientEntry) {
28
+ console.log("[vite:plugin-react-server] Loading client entry", clientEntry[1].file);
29
+ const module = await import(join(root, clientEntry[1].file));
30
+ return module;
31
+ }
32
+ const serverEntry = Object.entries(serverManifest).find(([key]) => {
33
+ const [keyNormalized] = normalizer(key);
34
+ return keyNormalized === normalizedId;
35
+ });
36
+ if (serverEntry) {
37
+ const module = await import(join(root, serverEntry[1].file));
38
+ return module;
39
+ }
40
+ const availableModules = [...Object.keys(clientManifest), ...Object.keys(serverManifest)];
41
+ throw new Error(
42
+ `Module not found: ${id}, available modules: ${availableModules.join(", ")}`
43
+ );
19
44
  };
20
45
  }
21
46
 
@@ -1 +1 @@
1
- {"version":3,"file":"createBuildLoader.js","sources":["../../../plugin/loader/createBuildLoader.ts"],"sourcesContent":["import { join } from \"path\";\nimport type { PluginContext } from \"rollup\";\nimport type { ResolvedUserConfig } from \"../../server.js\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\n\nexport interface BuildLoaderOptions {\n root: string;\n pluginContext: PluginContext;\n userConfig: ResolvedUserConfig;\n}\n\nexport function createBuildLoader({\n root,\n userConfig,\n}: BuildLoaderOptions) {\n return async (id: string) => {\n return import(join(\n root,\n userConfig.build.outDir,\n id.replace(DEFAULT_CONFIG.FILE_REGEX, \"\") + \".js\"\n ));\n };\n}\n"],"names":[],"mappings":";;;;;;;;AAWO,SAAS,iBAAkB,CAAA;AAAA,EAChC,IAAA;AAAA,EACA;AACF,CAAuB,EAAA;AACrB,EAAA,OAAO,OAAO,EAAe,KAAA;AAC3B,IAAA,OAAO,OAAO,IAAA;AAAA,MACZ,IAAA;AAAA,MACA,WAAW,KAAM,CAAA,MAAA;AAAA,MACjB,EAAG,CAAA,OAAA,CAAQ,cAAe,CAAA,UAAA,EAAY,EAAE,CAAI,GAAA;AAAA,KAC9C,CAAA;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"createBuildLoader.js","sources":["../../../plugin/loader/createBuildLoader.ts"],"sourcesContent":["import { join, resolve } from \"node:path\";\nimport type { PluginContext } from \"rollup\";\nimport type { ResolvedUserConfig, ResolvedUserOptions } from \"../../server.js\";\nimport type { Manifest } from \"vite\";\nimport { createInputNormalizer } from \"../helpers/inputNormalizer.js\";\n\nexport interface BuildLoaderOptions {\n root: string;\n pluginContext: PluginContext;\n userConfig: ResolvedUserConfig;\n userOptions: ResolvedUserOptions;\n serverManifest: Manifest;\n clientManifest: Manifest;\n}\n\nexport function createBuildLoader({\n userConfig,\n userOptions,\n pluginContext,\n clientManifest,\n serverManifest,\n}: BuildLoaderOptions) {\n const root = pluginContext.environment.config.root ?? userConfig.root ?? userOptions.projectRoot ?? process.cwd();\n const normalizer = createInputNormalizer({\n root: userConfig.root,\n preserveModulesRoot:\n userOptions.build.preserveModulesRoot === true\n ? userOptions.moduleBase\n : undefined,\n });\n\n return async function buildLoader(id: string) {\n // Normalize the requested ID - strip leading slash\n const [normalizedId] = normalizer(id.replace(/^\\//, ''));\n\n // Try to find the module in either manifest\n const clientEntry = Object.entries(clientManifest).find(([key]) => {\n const [keyNormalized] = normalizer(key);\n return keyNormalized === normalizedId;\n });\n\n if (clientEntry) {\n console.log(\"[vite:plugin-react-server] Loading client entry\", clientEntry[1].file);\n const module = await import(\n join(root, clientEntry[1].file)\n );\n return module;\n }\n\n const serverEntry = Object.entries(serverManifest).find(([key]) => {\n const [keyNormalized] = normalizer(key);\n return keyNormalized === normalizedId;\n });\n\n if (serverEntry) {\n const module = await import(\n join(root, serverEntry[1].file)\n );\n return module;\n }\n const availableModules = [...Object.keys(clientManifest), ...Object.keys(serverManifest)]\n\n throw new Error(\n `Module not found: ${id}, available modules: ${availableModules.join(\", \")}`\n );\n };\n}\n"],"names":[],"mappings":";;;;;;;;AAeO,SAAS,iBAAkB,CAAA;AAAA,EAChC,UAAA;AAAA,EACA,WAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAuB,EAAA;AACrB,EAAM,MAAA,IAAA,GAAO,aAAc,CAAA,WAAA,CAAY,MAAO,CAAA,IAAA,IAAQ,WAAW,IAAQ,IAAA,WAAA,CAAY,WAAe,IAAA,OAAA,CAAQ,GAAI,EAAA;AAChH,EAAA,MAAM,aAAa,qBAAsB,CAAA;AAAA,IACvC,MAAM,UAAW,CAAA,IAAA;AAAA,IACjB,qBACE,WAAY,CAAA,KAAA,CAAM,mBAAwB,KAAA,IAAA,GACtC,YAAY,UACZ,GAAA;AAAA,GACP,CAAA;AAED,EAAO,OAAA,eAAe,Y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,CAAA;AAAA,KAC5E;AAAA,GACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createPageLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createPageLoader.ts"],"names":[],"mappings":"AAaA,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,mBAAmB,wFAM7B,0BAA0B,WAqBR,MAAM,iBAM1B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,UAAU,EACV,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,cAAc,GACf,EAAE,uBAAuB,QACS,MAAM,kBA+BxC"}
1
+ {"version":3,"file":"createPageLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createPageLoader.ts"],"names":[],"mappings":"AAaA,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,mBAAmB,wFAM7B,0BAA0B,WAqBR,MAAM,iBAM1B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,UAAU,EACV,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,cAAc,GACf,EAAE,uBAAuB,QACS,MAAM,kBAyBxC"}
@@ -32,13 +32,6 @@ export const createDefaultLoader = ({ id, registerServer, registerClient, always
32
32
  };
33
33
  export function createPageLoader({ manifest, root, outDir, moduleBase, alwaysRegisterServer, alwaysRegisterClient, registerServer, registerClient, }) {
34
34
  return async function loader(id) {
35
- console.log("[pageLoader] Loading:", {
36
- id,
37
- manifest: Object.keys(manifest),
38
- outDir,
39
- moduleBase
40
- });
41
- console.log("[pageLoader] Manifest:", manifest);
42
35
  // Try to find the entry directly or by source file
43
36
  const manifestEntry = manifest[id] ||
44
37
  Object.values(manifest).find(entry => entry.src === id);
@@ -1,4 +1,3 @@
1
- import "./assertServerCondition.js";
2
1
  export { reactServerPlugin } from "./react-server/plugin.js";
3
2
  export { reactClientPlugin } from "./react-client/plugin.js";
4
3
  export { reactTransformPlugin } from "./transformer/plugin.js";
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../plugin/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../plugin/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -1,4 +1,4 @@
1
- import "./assertServerCondition.js";
1
+ import { assertServerCondition } from "./assertServerCondition.js";
2
2
  export { reactServerPlugin } from "./react-server/plugin.js";
3
3
  export { reactClientPlugin } from "./react-client/plugin.js";
4
4
  export { reactTransformPlugin } from "./transformer/plugin.js";
@@ -6,3 +6,4 @@ export { reactPreservePlugin } from "./preserver/plugin.js";
6
6
  export { vitePluginReactServer } from "./react-server/index.js";
7
7
  // the main plugin is version is the server version, if you want the client version, use the `vite-plugin-react-server/client` import
8
8
  // this is because the workflow assumes main thread = react server condition
9
+ assertServerCondition(process);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../plugin/preserver/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIvD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,OAAO,MAAM,EAAE,MAAM,CAsGxF"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../plugin/preserver/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKvD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,OAAO,MAAM,EAAE,MAAM,CAsGxF"}
@@ -3,7 +3,8 @@
3
3
  * Copyright (c) Nico Brinkkemper
4
4
  * MIT License
5
5
  */
6
- import MagicString from '../../node_modules/magic-string/dist/magic-string.es.js';
6
+ import MagicString from 'magic-string';
7
+ import { DEFAULT_CONFIG } from '../config/defaults.js';
7
8
 
8
9
  const REACT_DIRECTIVES = /* @__PURE__ */ new Set(["use client", "use server"]);
9
10
  function reactPreservePlugin(_options) {
@@ -15,7 +16,7 @@ function reactPreservePlugin(_options) {
15
16
  order: "post",
16
17
  // Ensure this runs last in transform phase
17
18
  handler(code, id) {
18
- if (id.includes("node_modules") || id.includes("vite/dist")) {
19
+ if (id.includes("node_modules") || id.includes("vite/dist") || !id.match(DEFAULT_CONFIG.FILE_REGEX)) {
19
20
  return null;
20
21
  }
21
22
  let ast;