vite-plugin-react-server 0.3.18 → 1.0.0

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 (246) hide show
  1. package/README.md +220 -141
  2. package/bin/patch.mjs +8 -2
  3. package/dist/package.json +15 -8
  4. package/dist/plugin/checkFilesExist.d.ts.map +1 -1
  5. package/dist/plugin/checkFilesExist.js +6 -2
  6. package/dist/plugin/checkFilesExist.js.map +1 -1
  7. package/dist/plugin/collect-manifest-client-files.d.ts +23 -0
  8. package/dist/plugin/collect-manifest-client-files.d.ts.map +1 -0
  9. package/dist/plugin/collect-manifest-client-files.js +131 -0
  10. package/dist/plugin/collect-manifest-client-files.js.map +1 -0
  11. package/dist/plugin/components.d.ts +3 -13
  12. package/dist/plugin/components.d.ts.map +1 -1
  13. package/dist/plugin/components.js +3 -13
  14. package/dist/plugin/config/defaults.d.ts +14 -6
  15. package/dist/plugin/config/defaults.d.ts.map +1 -1
  16. package/dist/plugin/config/defaults.js +9 -5
  17. package/dist/plugin/config/defaults.js.map +1 -1
  18. package/dist/plugin/config/getPaths.d.ts +0 -1
  19. package/dist/plugin/config/getPaths.d.ts.map +1 -1
  20. package/dist/plugin/config/getPaths.js +2 -7
  21. package/dist/plugin/config/getPaths.js.map +1 -1
  22. package/dist/plugin/config/mimeTypes.d.ts +2 -0
  23. package/dist/plugin/config/mimeTypes.d.ts.map +1 -0
  24. package/dist/plugin/config/mimeTypes.js +24 -0
  25. package/dist/plugin/config/mimeTypes.js.map +1 -0
  26. package/dist/plugin/config/resolveOptions.d.ts +2 -2
  27. package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
  28. package/dist/plugin/config/resolveOptions.js +47 -28
  29. package/dist/plugin/config/resolveOptions.js.map +1 -1
  30. package/dist/plugin/config/resolvePages.d.ts +1 -0
  31. package/dist/plugin/config/resolvePages.d.ts.map +1 -1
  32. package/dist/plugin/config/resolvePages.js +9 -5
  33. package/dist/plugin/config/resolvePages.js.map +1 -1
  34. package/dist/plugin/config/resolveUserConfig.d.ts +2 -1
  35. package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
  36. package/dist/plugin/config/resolveUserConfig.js +181 -147
  37. package/dist/plugin/config/resolveUserConfig.js.map +1 -1
  38. package/dist/plugin/copy-dir.js +23 -18
  39. package/dist/plugin/copy-dir.js.map +1 -0
  40. package/dist/plugin/css-collector-inline.d.ts +10 -0
  41. package/dist/plugin/css-collector-inline.d.ts.map +1 -0
  42. package/dist/plugin/css-collector-inline.js +55 -0
  43. package/dist/plugin/css-collector-inline.js.map +1 -0
  44. package/dist/plugin/css-collector.d.ts +14 -0
  45. package/dist/plugin/css-collector.d.ts.map +1 -0
  46. package/dist/plugin/css-collector.js +49 -0
  47. package/dist/plugin/css-collector.js.map +1 -0
  48. package/dist/plugin/helpers/createHandler.d.ts +17 -0
  49. package/dist/plugin/helpers/createHandler.d.ts.map +1 -0
  50. package/dist/plugin/helpers/createHandler.js +111 -0
  51. package/dist/plugin/helpers/createHandler.js.map +1 -0
  52. package/dist/plugin/helpers/createRscStream.d.ts +27 -0
  53. package/dist/plugin/helpers/createRscStream.d.ts.map +1 -0
  54. package/dist/plugin/helpers/createRscStream.js +80 -0
  55. package/dist/plugin/helpers/createRscStream.js.map +1 -0
  56. package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
  57. package/dist/plugin/helpers/getBundleManifest.js +12 -4
  58. package/dist/plugin/helpers/getBundleManifest.js.map +1 -1
  59. package/dist/plugin/html.d.ts +5 -0
  60. package/dist/plugin/html.d.ts.map +1 -0
  61. package/dist/plugin/html.js +11 -0
  62. package/dist/plugin/html.js.map +1 -0
  63. package/dist/plugin/loader/createBuildLoader.d.ts +1 -1
  64. package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
  65. package/dist/plugin/loader/createBuildLoader.js +8 -5
  66. package/dist/plugin/loader/createBuildLoader.js.map +1 -1
  67. package/dist/plugin/loader/css-loader.d.ts.map +1 -1
  68. package/dist/plugin/loader/css-loader.js.map +1 -1
  69. package/dist/plugin/loader/react-loader.js +2 -2
  70. package/dist/plugin/loader/react-loader.js.map +1 -1
  71. package/dist/plugin/preserver/plugin.d.ts.map +1 -1
  72. package/dist/plugin/preserver/plugin.js +49 -14
  73. package/dist/plugin/preserver/plugin.js.map +1 -1
  74. package/dist/plugin/react-client/plugin.d.ts.map +1 -1
  75. package/dist/plugin/react-client/plugin.js +21 -78
  76. package/dist/plugin/react-client/plugin.js.map +1 -1
  77. package/dist/plugin/react-server/index.d.ts.map +1 -1
  78. package/dist/plugin/react-server/index.js +2 -0
  79. package/dist/plugin/react-server/index.js.map +1 -1
  80. package/dist/plugin/react-server/plugin.d.ts +2 -1
  81. package/dist/plugin/react-server/plugin.d.ts.map +1 -1
  82. package/dist/plugin/react-server/plugin.js +92 -225
  83. package/dist/plugin/react-server/plugin.js.map +1 -1
  84. package/dist/plugin/react-static/index.d.ts +2 -0
  85. package/dist/plugin/react-static/index.d.ts.map +1 -0
  86. package/dist/plugin/react-static/index.js +1 -0
  87. package/dist/plugin/react-static/plugin.d.ts +7 -0
  88. package/dist/plugin/react-static/plugin.d.ts.map +1 -0
  89. package/dist/plugin/react-static/plugin.js +207 -0
  90. package/dist/plugin/react-static/plugin.js.map +1 -0
  91. package/dist/plugin/react-static/types.d.ts +2 -0
  92. package/dist/plugin/react-static/types.d.ts.map +1 -0
  93. package/dist/plugin/resolvePage.d.ts.map +1 -1
  94. package/dist/plugin/resolvePage.js +9 -0
  95. package/dist/plugin/resolvePage.js.map +1 -1
  96. package/dist/plugin/root.d.ts +2 -0
  97. package/dist/plugin/root.d.ts.map +1 -0
  98. package/dist/plugin/root.js +12 -0
  99. package/dist/plugin/root.js.map +1 -0
  100. package/dist/plugin/transformer/plugin.d.ts.map +1 -1
  101. package/dist/plugin/transformer/plugin.js +32 -23
  102. package/dist/plugin/transformer/plugin.js.map +1 -1
  103. package/dist/plugin/transformer/types.d.ts +1 -18
  104. package/dist/plugin/transformer/types.d.ts.map +1 -1
  105. package/dist/plugin/types.d.ts +70 -15
  106. package/dist/plugin/types.d.ts.map +1 -1
  107. package/dist/plugin/worker/createWorker.js +0 -1
  108. package/dist/plugin/worker/createWorker.js.map +1 -1
  109. package/dist/plugin/worker/html/html-worker.development.d.ts +30 -0
  110. package/dist/plugin/worker/html/html-worker.development.d.ts.map +1 -1
  111. package/dist/plugin/worker/html/html-worker.development.js +30 -2
  112. package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
  113. package/dist/plugin/worker/html/html-worker.production.js +3 -5
  114. package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
  115. package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
  116. package/dist/plugin/worker/html/messageHandler.js +12 -3
  117. package/dist/plugin/worker/html/messageHandler.js.map +1 -1
  118. package/dist/plugin/worker/html/renderPages.d.ts +13 -26
  119. package/dist/plugin/worker/html/renderPages.d.ts.map +1 -1
  120. package/dist/plugin/worker/html/renderPages.js +138 -86
  121. package/dist/plugin/worker/html/renderPages.js.map +1 -1
  122. package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
  123. package/dist/plugin/worker/rsc/messageHandler.js +104 -84
  124. package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
  125. package/dist/plugin/worker/rsc/rsc-worker.development.js +13 -18
  126. package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
  127. package/dist/plugin/worker/rsc/rsc-worker.production.js +4 -1
  128. package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
  129. package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
  130. package/dist/plugin/worker/rsc/state.js.map +1 -1
  131. package/dist/plugin/worker/types.d.ts +3 -0
  132. package/dist/plugin/worker/types.d.ts.map +1 -1
  133. package/dist/tsconfig.tsbuildinfo +1 -1
  134. package/package.json +14 -6
  135. package/plugin/checkFilesExist.ts +7 -3
  136. package/plugin/collect-manifest-client-files.ts +167 -0
  137. package/plugin/components.ts +3 -0
  138. package/plugin/config/defaults.tsx +70 -0
  139. package/plugin/config/getPaths.ts +1 -7
  140. package/plugin/config/mimeTypes.ts +17 -0
  141. package/plugin/config/resolveOptions.ts +58 -45
  142. package/plugin/config/resolvePages.ts +8 -4
  143. package/plugin/config/resolveUserConfig.ts +220 -176
  144. package/plugin/css-collector-inline.tsx +60 -0
  145. package/plugin/css-collector.tsx +62 -0
  146. package/plugin/helpers/createHandler.ts +135 -0
  147. package/plugin/helpers/createRscStream.ts +109 -0
  148. package/plugin/helpers/getBundleManifest.ts +14 -5
  149. package/plugin/html.tsx +9 -0
  150. package/plugin/loader/createBuildLoader.ts +9 -6
  151. package/plugin/loader/css-loader.ts +0 -2
  152. package/plugin/loader/react-loader.ts +2 -2
  153. package/plugin/preserver/plugin.ts +64 -17
  154. package/plugin/react-client/plugin.ts +23 -93
  155. package/plugin/react-server/index.ts +2 -0
  156. package/plugin/react-server/plugin.ts +111 -302
  157. package/plugin/react-static/index.ts +1 -0
  158. package/plugin/react-static/plugin.ts +256 -0
  159. package/plugin/react-static/types.ts +3 -0
  160. package/plugin/resolvePage.ts +9 -0
  161. package/plugin/root.ts +4 -0
  162. package/plugin/transformer/plugin.ts +40 -31
  163. package/plugin/transformer/types.ts +0 -19
  164. package/plugin/types.ts +77 -16
  165. package/plugin/worker/createWorker.ts +1 -1
  166. package/plugin/worker/html/README.md +63 -0
  167. package/plugin/worker/html/html-worker.development.tsx +89 -2
  168. package/plugin/worker/html/html-worker.production.tsx +8 -10
  169. package/plugin/worker/html/messageHandler.ts +12 -3
  170. package/plugin/worker/html/renderPages.ts +178 -138
  171. package/plugin/worker/rsc/README.md +58 -0
  172. package/plugin/worker/rsc/messageHandler.tsx +112 -113
  173. package/plugin/worker/rsc/rsc-worker.development.ts +12 -22
  174. package/plugin/worker/rsc/rsc-worker.production.ts +5 -1
  175. package/plugin/worker/rsc/state.ts +0 -3
  176. package/plugin/worker/types.ts +3 -0
  177. package/scripts/react+0.0.0-experimental-eda36a1c-20250228.patch +114 -12
  178. package/scripts/react-dom+0.0.0-experimental-eda36a1c-20250228.patch +10571 -121
  179. package/tsconfig.json +2 -2
  180. package/dist/plugin/collect-css-manifest.d.ts +0 -4
  181. package/dist/plugin/collect-css-manifest.d.ts.map +0 -1
  182. package/dist/plugin/collect-css-manifest.js +0 -65
  183. package/dist/plugin/collect-css-manifest.js.map +0 -1
  184. package/dist/plugin/config/createModuleIdGenerator.d.ts +0 -11
  185. package/dist/plugin/config/createModuleIdGenerator.d.ts.map +0 -1
  186. package/dist/plugin/config/createModuleIdGenerator.js +0 -44
  187. package/dist/plugin/config/createModuleIdGenerator.js.map +0 -1
  188. package/dist/plugin/getEnv.d.ts +0 -19
  189. package/dist/plugin/getEnv.d.ts.map +0 -1
  190. package/dist/plugin/getEnv.js +0 -107
  191. package/dist/plugin/loader/createCssLoader.d.ts +0 -30
  192. package/dist/plugin/loader/createCssLoader.d.ts.map +0 -1
  193. package/dist/plugin/loader/createCssLoader.js +0 -35
  194. package/dist/plugin/loader/createPageLoader.d.ts +0 -24
  195. package/dist/plugin/loader/createPageLoader.d.ts.map +0 -1
  196. package/dist/plugin/loader/createPageLoader.js +0 -50
  197. package/dist/plugin/loader/rsc/messageHandler.d.ts +0 -2
  198. package/dist/plugin/loader/rsc/messageHandler.d.ts.map +0 -1
  199. package/dist/plugin/loader/rsc/rsc-worker.development.d.ts +0 -2
  200. package/dist/plugin/loader/rsc/rsc-worker.development.d.ts.map +0 -1
  201. package/dist/plugin/loader/rsc/rsc-worker.development.js +0 -1
  202. package/dist/plugin/module-graph.d.ts +0 -10
  203. package/dist/plugin/module-graph.d.ts.map +0 -1
  204. package/dist/plugin/module-graph.js +0 -35
  205. package/dist/plugin/react-server/createHandler.d.ts +0 -17
  206. package/dist/plugin/react-server/createHandler.d.ts.map +0 -1
  207. package/dist/plugin/react-server/createHandler.js +0 -126
  208. package/dist/plugin/react-server/createHandler.js.map +0 -1
  209. package/dist/plugin/react-server/createRscStream.d.ts +0 -16
  210. package/dist/plugin/react-server/createRscStream.d.ts.map +0 -1
  211. package/dist/plugin/react-server/createRscStream.js +0 -70
  212. package/dist/plugin/react-server/createRscStream.js.map +0 -1
  213. package/dist/plugin/react-server/createSsrHandler.d.ts +0 -4
  214. package/dist/plugin/react-server/createSsrHandler.d.ts.map +0 -1
  215. package/dist/plugin/react-server/createSsrHandler.js +0 -95
  216. package/dist/plugin/utils/logger.d.ts +0 -9
  217. package/dist/plugin/utils/logger.d.ts.map +0 -1
  218. package/dist/plugin/utils/logger.js +0 -68
  219. package/dist/plugin/utils/logger.js.map +0 -1
  220. package/dist/plugin/worker/html/plugin.d.ts +0 -4
  221. package/dist/plugin/worker/html/plugin.d.ts.map +0 -1
  222. package/dist/plugin/worker/html/plugin.js +0 -94
  223. package/dist/plugin/worker/plugin.d.ts +0 -19
  224. package/dist/plugin/worker/plugin.d.ts.map +0 -1
  225. package/dist/plugin/worker/plugin.js +0 -23
  226. package/dist/plugin/worker/rsc/plugin.d.ts +0 -4
  227. package/dist/plugin/worker/rsc/plugin.d.ts.map +0 -1
  228. package/dist/plugin/worker/rsc/plugin.js +0 -76
  229. package/plugin/collect-css-manifest.ts +0 -82
  230. package/plugin/components.tsx +0 -14
  231. package/plugin/config/createModuleIdGenerator.ts +0 -52
  232. package/plugin/config/defaults.ts +0 -51
  233. package/plugin/getEnv.ts +0 -135
  234. package/plugin/loader/createCssLoader.ts +0 -73
  235. package/plugin/loader/createPageLoader.ts +0 -103
  236. package/plugin/loader/rsc/messageHandler.tsx +0 -1
  237. package/plugin/loader/rsc/rsc-worker.development.ts +0 -1
  238. package/plugin/module-graph.ts +0 -48
  239. package/plugin/react-server/createHandler.ts +0 -162
  240. package/plugin/react-server/createRscStream.ts +0 -86
  241. package/plugin/react-server/createSsrHandler.ts +0 -125
  242. package/plugin/utils/logger.ts +0 -52
  243. package/plugin/worker/html/plugin.ts +0 -101
  244. package/plugin/worker/plugin.ts +0 -26
  245. package/plugin/worker/rsc/plugin.ts +0 -84
  246. /package/dist/plugin/{loader/rsc/messageHandler.js → react-static/types.js} +0 -0
@@ -0,0 +1,131 @@
1
+ /**
2
+ * vite-plugin-react-server
3
+ * Copyright (c) Nico Brinkkemper
4
+ * MIT License
5
+ */
6
+ import { createInputNormalizer } from './helpers/inputNormalizer.js';
7
+ import { DEFAULT_CONFIG } from './config/defaults.js';
8
+
9
+ async function collectModuleGraphCss({
10
+ moduleGraph,
11
+ pagePath,
12
+ onCss,
13
+ parentUrl
14
+ }) {
15
+ if (!pagePath) return /* @__PURE__ */ new Map();
16
+ const cssFiles = /* @__PURE__ */ new Map();
17
+ const pageModule = await moduleGraph.getModuleByUrl(pagePath, true);
18
+ if (!pageModule) {
19
+ return /* @__PURE__ */ new Map();
20
+ }
21
+ const seen = /* @__PURE__ */ new Set();
22
+ const walkModule = (mod) => {
23
+ if (!mod?.id || seen.has(mod.id)) return;
24
+ seen.add(mod.id);
25
+ if (mod?.id?.endsWith(".css")) {
26
+ cssFiles.set(mod?.url, mod?.id);
27
+ }
28
+ mod?.importedModules?.forEach((imp) => walkModule(imp));
29
+ };
30
+ walkModule(pageModule);
31
+ return cssFiles;
32
+ }
33
+ function collectManifestClientFiles({
34
+ manifest,
35
+ root,
36
+ pagePath,
37
+ preserveModulesRoot,
38
+ moduleBase,
39
+ onCss,
40
+ onClientModule,
41
+ testClient = DEFAULT_CONFIG.AUTO_DISCOVER.clientComponents,
42
+ testJson = DEFAULT_CONFIG.AUTO_DISCOVER.jsonPattern
43
+ }) {
44
+ const normalizer = createInputNormalizer({
45
+ root,
46
+ removeExtension: true,
47
+ preserveModulesRoot: preserveModulesRoot ? moduleBase : undefined
48
+ });
49
+ const [_, value] = normalizer(pagePath);
50
+ const cssFiles = /* @__PURE__ */ new Map();
51
+ const clientFiles = /* @__PURE__ */ new Map();
52
+ const seen = /* @__PURE__ */ new Set();
53
+ const manifestValues = Object.values(manifest);
54
+ const possibleKeys = [
55
+ value
56
+ // Relative path
57
+ ];
58
+ const walkManifestEntry = (id, parentUrl) => {
59
+ if (seen.has(id)) return;
60
+ seen.add(id);
61
+ const entry = manifest[id] ?? manifestValues.find((e) => id === e.file);
62
+ if (!entry) {
63
+ const hasKey = Object.keys(manifest).find((key) => id === key);
64
+ if (hasKey) {
65
+ console.log(
66
+ `Manifest entry found for ${id}, but it is ${typeof entry}`
67
+ );
68
+ return;
69
+ } else {
70
+ console.log(
71
+ `No manifest entry found for ${id}, possible keys: ${Object.keys(
72
+ manifest
73
+ ).join(", ")}`
74
+ );
75
+ }
76
+ return;
77
+ }
78
+ if (typeof testClient === "function" && typeof onClientModule === "function" && testClient(entry.file) || typeof testJson === "function" && testJson(entry.file)) {
79
+ onClientModule?.(entry.file ?? "", parentUrl);
80
+ clientFiles.set(id, entry.name ?? "");
81
+ }
82
+ if (entry.css) {
83
+ entry.css.forEach((css) => {
84
+ cssFiles.set(css, css);
85
+ onCss?.(css, id);
86
+ onClientModule?.(css, id);
87
+ });
88
+ }
89
+ if (entry.imports) {
90
+ entry.imports.forEach(
91
+ (imp) => walkManifestEntry(imp, entry.file)
92
+ );
93
+ }
94
+ if (entry.dynamicImports) {
95
+ entry.dynamicImports.forEach(
96
+ (imp) => walkManifestEntry(imp, entry.file)
97
+ );
98
+ }
99
+ };
100
+ for (const possibleKey of possibleKeys) {
101
+ if (manifest[possibleKey]) {
102
+ walkManifestEntry(possibleKey, pagePath);
103
+ break;
104
+ }
105
+ }
106
+ if (cssFiles.size === 0) {
107
+ const entry = manifestValues.find(
108
+ (e) => possibleKeys.includes(e.file) || e.src && possibleKeys.includes(e.src) || e.name && possibleKeys.includes(e.name)
109
+ );
110
+ if (entry) {
111
+ walkManifestEntry(value, pagePath);
112
+ } else {
113
+ const hasKey = Object.keys(manifest).find((key) => value === key);
114
+ if (hasKey) {
115
+ console.warn(
116
+ `Manifest entry found for ${value}, but it is ${typeof manifest[hasKey]}`
117
+ );
118
+ } else {
119
+ console.warn(
120
+ `No manifest entry found for ${value} (tried all possible keys: ${possibleKeys.join(
121
+ ", "
122
+ )} for manifest keys: ${Object.keys(manifest).join(", ")})`
123
+ );
124
+ }
125
+ }
126
+ }
127
+ return { cssFiles, clientFiles };
128
+ }
129
+
130
+ export { collectManifestClientFiles, collectModuleGraphCss };
131
+ //# sourceMappingURL=collect-manifest-client-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collect-manifest-client-files.js","sources":["../../plugin/collect-manifest-client-files.ts"],"sourcesContent":["import type { Manifest, ModuleGraph } from \"vite\";\nimport { createInputNormalizer } from \"./helpers/inputNormalizer.js\";\nimport { DEFAULT_CONFIG } from \"./config/defaults.js\";\n\nexport async function collectModuleGraphCss({\n moduleGraph,\n pagePath,\n onCss,\n parentUrl,\n}: {\n moduleGraph: ModuleGraph;\n pagePath: string;\n onCss?: (path: string, parentUrl: string) => void;\n parentUrl?: string;\n}) {\n if (!pagePath) return new Map<string, string>();\n\n const cssFiles = new Map<string, string>();\n const pageModule = await moduleGraph.getModuleByUrl(pagePath, true);\n if (!pageModule) {\n return new Map<string, string>();\n }\n const seen = new Set<string>();\n const walkModule = (mod: any) => {\n if (!mod?.id || seen.has(mod.id)) return;\n seen.add(mod.id);\n if (mod?.id?.endsWith(\".css\")) {\n cssFiles.set(mod?.url, mod?.id);\n onCss?.(mod?.url, parentUrl ?? pagePath);\n }\n mod?.importedModules?.forEach((imp: any) => walkModule(imp));\n };\n walkModule(pageModule);\n return cssFiles;\n}\n\nexport function collectManifestClientFiles({\n manifest,\n root,\n pagePath,\n preserveModulesRoot,\n moduleBase,\n onCss,\n onClientModule,\n testClient = DEFAULT_CONFIG.AUTO_DISCOVER.clientComponents,\n testJson = DEFAULT_CONFIG.AUTO_DISCOVER.jsonPattern,\n}: {\n manifest: Manifest;\n root: string;\n pagePath: string;\n preserveModulesRoot?: boolean;\n moduleBase?: string;\n onCss?: (path: string, parentUrl: string) => void;\n onClientModule?: (path: string, parentUrl: string) => void;\n parentUrl?: string;\n testClient?: (id: string) => boolean;\n testJson?: (id: string) => boolean;\n}) {\n const normalizer = createInputNormalizer({\n root,\n removeExtension: true,\n preserveModulesRoot: preserveModulesRoot ? moduleBase : undefined,\n });\n const [_, value] = normalizer(pagePath);\n\n const cssFiles = new Map<string, string>();\n const clientFiles = new Map<string, string>();\n const seen = new Set<string>();\n const manifestValues = Object.values(manifest);\n\n // Try different variations of the path\n const possibleKeys = [\n value, // Relative path\n ];\n\n const walkManifestEntry = (id: string, parentUrl: string) => {\n if (seen.has(id)) return;\n seen.add(id);\n\n // Get the manifest entry\n const entry = manifest[id] ?? manifestValues.find((e) => id === e.file);\n if (!entry) {\n const hasKey = Object.keys(manifest).find((key) => id === key);\n if (hasKey) {\n console.log(\n `Manifest entry found for ${id}, but it is ${typeof entry}`\n );\n return;\n } else {\n console.log(\n `No manifest entry found for ${id}, possible keys: ${Object.keys(\n manifest\n ).join(\", \")}`\n );\n }\n return;\n }\n if (\n (typeof testClient === \"function\" &&\n typeof onClientModule === \"function\" &&\n testClient(entry.file)) ||\n (typeof testJson === \"function\" && testJson(entry.file))\n ) {\n onClientModule?.(entry.file ?? \"\", parentUrl);\n clientFiles.set(id, entry.name ?? \"\");\n }\n\n // Add direct CSS from the css array\n if (entry.css) {\n entry.css.forEach((css: string) => {\n cssFiles.set(css, css);\n onCss?.(css, id);\n onClientModule?.(css, id);\n });\n }\n\n // Walk imports recursively\n if (entry.imports) {\n entry.imports.forEach((imp: string) =>\n walkManifestEntry(imp, entry.file)\n );\n }\n\n // Also check dynamicImports\n if (entry.dynamicImports) {\n entry.dynamicImports.forEach((imp: string) =>\n walkManifestEntry(imp, entry.file)\n );\n }\n };\n\n // Try all possible keys\n for (const possibleKey of possibleKeys) {\n if (manifest[possibleKey]) {\n walkManifestEntry(possibleKey, pagePath);\n break;\n }\n }\n\n // If no entry found by key, try matching by file\n if (cssFiles.size === 0) {\n const entry = manifestValues.find(\n (e) =>\n possibleKeys.includes(e.file) ||\n (e.src && possibleKeys.includes(e.src)) ||\n (e.name && possibleKeys.includes(e.name))\n );\n if (entry) {\n walkManifestEntry(value, pagePath);\n } else {\n const hasKey = Object.keys(manifest).find((key) => value === key);\n if (hasKey) {\n console.warn(\n `Manifest entry found for ${value}, but it is ${typeof manifest[hasKey]}`\n );\n } else {\n console.warn(\n `No manifest entry found for ${value} (tried all possible keys: ${possibleKeys.join(\n \", \"\n )} for manifest keys: ${Object.keys(manifest).join(\", \")})`\n );\n }\n }\n }\n\n return { cssFiles, clientFiles };\n}\n"],"names":[],"mappings":";;;;;;;;AAIA,eAAsB,qBAAsB,CAAA;AAAA,EAC1C,WAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAKG,EAAA;AACD,EAAA,IAAI,CAAC,QAAA,EAAiB,uBAAA,IAAI,GAAoB,EAAA;AAE9C,EAAM,MAAA,QAAA,uBAAe,GAAoB,EAAA;AACzC,EAAA,MAAM,UAAa,GAAA,MAAM,WAAY,CAAA,cAAA,CAAe,UAAU,IAAI,CAAA;AAClE,EAAA,IAAI,CAAC,UAAY,EAAA;AACf,IAAA,2BAAW,GAAoB,EAAA;AAAA;AAEjC,EAAM,MAAA,IAAA,uBAAW,GAAY,EAAA;AAC7B,EAAM,MAAA,UAAA,GAAa,CAAC,GAAa,KAAA;AAC/B,IAAA,IAAI,CAAC,GAAK,EAAA,EAAA,IAAM,KAAK,GAAI,CAAA,GAAA,CAAI,EAAE,CAAG,EAAA;AAClC,IAAK,IAAA,CAAA,GAAA,CAAI,IAAI,EAAE,CAAA;AACf,IAAA,IAAI,GAAK,EAAA,EAAA,EAAI,QAAS,CAAA,MAAM,CAAG,EAAA;AAC7B,MAAA,QAAA,CAAS,GAAI,CAAA,GAAA,EAAK,GAAK,EAAA,GAAA,EAAK,EAAE,CAAA;AACS;AAEzC,IAAA,GAAA,EAAK,iBAAiB,OAAQ,CAAA,CAAC,GAAa,KAAA,UAAA,CAAW,GAAG,CAAC,CAAA;AAAA,GAC7D;AACA,EAAA,UAAA,CAAW,UAAU,CAAA;AACrB,EAAO,OAAA,QA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@ -1,14 +1,4 @@
1
- /**
2
- * A component that emits <link> tags for CSS files during streaming.
3
- * The high precedence ensures they bubble up to the document head.
4
- */
5
- export declare function CssCollector({ url, moduleBasePath }: {
6
- url: string;
7
- moduleBasePath: string;
8
- }): import("react").DetailedReactHTMLElement<{
9
- key: string;
10
- rel: string;
11
- href: string;
12
- precedence: string;
13
- }, HTMLElement>;
1
+ export { Html } from "./html.js";
2
+ export { CssCollector } from "./css-collector.js";
3
+ export { InlineCssCollector } from "./css-collector-inline.js";
14
4
  //# sourceMappingURL=components.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../plugin/components.tsx"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,GAAG,EAAE,cAAc,EAAE,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE;;;;;gBAO5F"}
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../plugin/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -1,13 +1,3 @@
1
- import { createElement } from 'react';
2
- /**
3
- * A component that emits <link> tags for CSS files during streaming.
4
- * The high precedence ensures they bubble up to the document head.
5
- */
6
- export function CssCollector({ url, moduleBasePath }) {
7
- return createElement('link', {
8
- key: url,
9
- rel: 'stylesheet',
10
- href: url,
11
- precedence: 'high'
12
- });
13
- }
1
+ export { Html } from "./html.js";
2
+ export { CssCollector } from "./css-collector.js";
3
+ export { InlineCssCollector } from "./css-collector-inline.js";
@@ -1,25 +1,28 @@
1
+ import { CssCollector } from "../css-collector.js";
1
2
  export declare const DEFAULT_CONFIG: {
2
3
  readonly FILE_REGEX: RegExp;
3
4
  readonly CLIENT_ASSETS_DIR: "assets";
4
5
  readonly RSC_DIR: "rsc";
5
6
  readonly MODULE_BASE: "src";
6
- readonly MODULE_BASE_PATH: "/src";
7
- readonly MODULE_BASE_URL: "/src";
7
+ readonly MODULE_BASE_PATH: "";
8
+ readonly MODULE_BASE_URL: "";
8
9
  readonly PAGE: "src/page/page.tsx";
9
10
  readonly PROPS: "src/page/props.ts";
10
11
  readonly CLIENT_ENTRY: "src/client.tsx";
11
12
  readonly SERVER_ENTRY: "src/server.tsx";
12
13
  readonly PAGE_EXPORT_NAME: "Page";
13
14
  readonly PROPS_EXPORT_NAME: "props";
14
- readonly HTML_WORKER_PATH: "node_modules/vite-plugin-react-server/dist/plugin/worker/html/html-worker.production.js" | "node_modules/vite-plugin-react-server/dist/plugin/worker/html/html-worker.development.js";
15
- readonly RSC_WORKER_PATH: "node_modules/vite-plugin-react-server/dist/plugin/worker/rsc/rsc-worker.production.js" | "node_modules/vite-plugin-react-server/dist/plugin/worker/rsc/rsc-worker.development.js";
16
- readonly LOADER_PATH: "node_modules/vite-plugin-react-server/dist/plugin/worker/loader.js";
15
+ readonly HTML_WORKER_PATH: "worker/html/html-worker.production.js" | "worker/html/html-worker.development.js";
16
+ readonly RSC_WORKER_PATH: "worker/rsc/rsc-worker.production.js" | "worker/rsc/rsc-worker.development.js";
17
+ readonly LOADER_PATH: "worker/loader.js";
17
18
  readonly RSC_EXTENSION: ".rsc";
19
+ readonly CSS_COLLECTOR: typeof CssCollector;
18
20
  readonly HTML: ({ children }: {
19
21
  children: any;
20
- }) => any;
22
+ }) => import("react").JSX.Element;
21
23
  readonly COLLECT_CSS: true;
22
24
  readonly COLLECT_ASSETS: true;
25
+ readonly INLINE_CSS: true;
23
26
  readonly DEV_PORT: 5173;
24
27
  readonly PREVIEW_PORT: 4173;
25
28
  readonly DEV_HOST: "localhost";
@@ -36,6 +39,11 @@ export declare const DEFAULT_CONFIG: {
36
39
  readonly hash: "hash";
37
40
  readonly preserveModulesRoot: true;
38
41
  };
42
+ readonly CSS: {
43
+ readonly inlineThreshold: 4096;
44
+ readonly inlinePatterns: readonly [RegExp];
45
+ readonly linkPatterns: readonly [RegExp];
46
+ };
39
47
  readonly MODULE_BASE_EXCEPTIONS: string[];
40
48
  readonly AUTO_DISCOVER: {
41
49
  readonly modulePattern: (n: string) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../plugin/config/defaults.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;kCAiBJ;QAAE,QAAQ,EAAE,GAAG,CAAA;KAAE;;;;;;;;;;;;;;;;;;;qCAmBR,MAAM,EAAE;;oCAEjB,MAAM;kCACR,MAAM;mCACL,MAAM;uCACF,MAAM;sCACP,MAAM;iCACX,MAAM;uCACA,MAAM;oCACT,MAAM;kCACR,MAAM;kCACN,MAAM;;6BAET,MAAM;CACd,CAAC"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../plugin/config/defaults.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCA+CK,MAAM,EAAE;;oCAEjB,MAAM;kCACR,MAAM;mCAEL,MAAM;uCAEF,MAAM;sCAEP,MAAM;iCAEX,MAAM;uCACA,MAAM;oCACT,MAAM;kCAGR,MAAM;kCACN,MAAM;;6BAET,MAAM;CACd,CAAC"}
@@ -3,23 +3,27 @@
3
3
  * Copyright (c) Nico Brinkkemper
4
4
  * MIT License
5
5
  */
6
+ import { Html } from '../html.js';
7
+
6
8
  const DEFAULT_CONFIG = {
7
9
  FILE_REGEX: /\.(m|c)?(j|t)sx?$/,
8
10
  CLIENT_ASSETS_DIR: "assets",
9
11
  MODULE_BASE: "src",
10
- MODULE_BASE_URL: "/src",
12
+ MODULE_BASE_PATH: "",
13
+ MODULE_BASE_URL: "",
11
14
  PAGE: "src/page/page.tsx",
12
15
  PROPS: "src/page/props.ts",
13
16
  CLIENT_ENTRY: "src/client.tsx",
14
17
  SERVER_ENTRY: "src/server.tsx",
15
18
  PAGE_EXPORT_NAME: "Page",
16
19
  PROPS_EXPORT_NAME: "props",
17
- HTML_WORKER_PATH: `node_modules/vite-plugin-react-server/dist/plugin/worker/html/html-worker.${process.env["NODE_ENV"] === "development" ? "development" : "production"}.js`,
18
- RSC_WORKER_PATH: `node_modules/vite-plugin-react-server/dist/plugin/worker/rsc/rsc-worker.${process.env["NODE_ENV"] === "development" ? "development" : "production"}.js`,
19
- LOADER_PATH: "node_modules/vite-plugin-react-server/dist/plugin/worker/loader.js",
20
- HTML: ({ children }) => children,
20
+ HTML_WORKER_PATH: `worker/html/html-worker.${process.env["NODE_ENV"] === "development" ? "development" : "production"}.js`,
21
+ RSC_WORKER_PATH: `worker/rsc/rsc-worker.${process.env["NODE_ENV"] === "development" ? "development" : "production"}.js`,
22
+ LOADER_PATH: "worker/loader.js",
23
+ HTML: Html,
21
24
  COLLECT_CSS: true,
22
25
  COLLECT_ASSETS: true,
26
+ INLINE_CSS: true,
23
27
  BUILD: {
24
28
  pages: () => ["/"],
25
29
  client: "client",
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.js","sources":["../../../plugin/config/defaults.ts"],"sourcesContent":["export const DEFAULT_CONFIG = {\n FILE_REGEX: /\\.(m|c)?(j|t)sx?$/,\n CLIENT_ASSETS_DIR: \"assets\",\n RSC_DIR: \"rsc\",\n MODULE_BASE: \"src\",\n MODULE_BASE_PATH: \"/src\",\n MODULE_BASE_URL: \"/src\",\n PAGE: \"src/page/page.tsx\",\n PROPS: \"src/page/props.ts\",\n CLIENT_ENTRY: \"src/client.tsx\",\n SERVER_ENTRY: \"src/server.tsx\",\n PAGE_EXPORT_NAME: \"Page\",\n PROPS_EXPORT_NAME: \"props\",\n HTML_WORKER_PATH: `node_modules/vite-plugin-react-server/dist/plugin/worker/html/html-worker.${process.env['NODE_ENV'] === 'development' ? 'development' : 'production'}.js`,\n RSC_WORKER_PATH: `node_modules/vite-plugin-react-server/dist/plugin/worker/rsc/rsc-worker.${process.env['NODE_ENV'] === 'development' ? 'development' : 'production'}.js`,\n LOADER_PATH: 'node_modules/vite-plugin-react-server/dist/plugin/worker/loader.js',\n RSC_EXTENSION: \".rsc\",\n HTML: ({ children }: { children: any }) => children,\n COLLECT_CSS: true,\n COLLECT_ASSETS: true,\n DEV_PORT: 5173,\n PREVIEW_PORT: 4173,\n DEV_HOST: \"localhost\",\n PREVIEW_HOST: \"localhost\",\n ENV_PREFIX: \"VITE_\",\n BUILD: {\n pages: () => [\"/\"],\n client: \"client\",\n server: \"server\",\n static: \"static\",\n api: \"api\",\n outDir: \"dist\",\n assetsDir: \"assets\",\n hash: \"hash\",\n preserveModulesRoot: true,\n },\n MODULE_BASE_EXCEPTIONS: [] as string[],\n AUTO_DISCOVER: {\n modulePattern: (n: string) => DEFAULT_CONFIG.FILE_REGEX.test(n),\n pagePattern: (n: string) => n.toLowerCase().endsWith('/page') || n.toLowerCase() === 'page',\n propsPattern: (n: string) => n.toLowerCase().endsWith('/props') || n.toLowerCase() === 'props',\n clientComponents: (n: string) => n.toLowerCase().endsWith('.client') || n.toLowerCase() === 'client',\n serverFunctions: (n: string) => n.toLowerCase().endsWith('.server') || n.toLowerCase() === 'server',\n cssPattern: (n: string) => n.toLowerCase().endsWith('.css'),\n cssModulePattern: (n: string) => n.toLowerCase().endsWith('.css.js'),\n vendorPattern: (n: string) => n.toLowerCase().startsWith('node_modules') || n.toLowerCase().startsWith('_virtual'),\n htmlPattern: (n: string) => n.toLowerCase().endsWith('.html'),\n jsonPattern: (n: string) => n.toLowerCase().endsWith('.json'),\n },\n MODULE_ID: (id: string) => id,\n} as const; "],"names":[],"mappings":";;;;;AAAO,MAAM,cAAiB,GAAA;AAAA,EAC5B,UAAY,EAAA,mBAAA;AAAA,EACZ,iBAAmB,EAAA,QAAA;AAAA,EA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AAc,CAAA,QAAA,CAAS,QAAQ,CAAA,IAAK,CAAE,CAAA,WAAA,EAAkB,KAAA,OAAA;AAAA,IACvF,gBAAA,EAAkB,CAAC,CAAA,KAAc,CAAE,CAAA,WAAA,EAAc,CAAA,QAAA,CAAS,SAAS,CAAA,IAAK,CAAE,CAAA,WAAA,EAAkB,KAAA,QAAA;AAAA,IAC5F,eAAA,EAAiB,CAAC,CAAA,KAAc,CAAE,CAAA,WAAA,EAAc,CAAA,QAAA,CAAS,SAAS,CAAA,IAAK,CAAE,CAAA,WAAA,EAAkB,KAAA,QAAA;AAAA,IAC3F,YAAY,CAAC,CAAA,KAAc,EAAE,WAAY,EAAA,CAAE,SAAS,MAAM,CAAA;AAAA,IAC1D,kBAAkB,CAAC,CAAA,KAAc,EAAE,WAAY,EAAA,CAAE,SAAS,SAAS,CAAA;AAAA,IACnE,aAAe,EAAA,CAAC,CAAc,KAAA,CAAA,CAAE,WAAY,EAAA,CAAE,UAAW,CAAA,cAAc,CAAK,IAAA,CAAA,CAAE,WAAY,EAAA,CAAE,WAAW,UAAU,CAAA;AAAA,IACjH,aAAa,CAAC,CAAA,KAAc,EAAE,WAAY,EAAA,CAAE,SAAS,OAAO,CAAA;AAAA,IAC5D,aAAa,CAAC,CAAA,KAAc,EAAE,WAAY,EAAA,CAAE,SAAS,OAAO;AAAA,GAGhE;;;;"}
1
+ {"version":3,"file":"defaults.js","sources":["../../../plugin/config/defaults.tsx"],"sourcesContent":["import { CssCollector } from \"../css-collector.js\";\nimport { Html } from \"../html.js\";\nexport const DEFAULT_CONFIG = {\n FILE_REGEX: /\\.(m|c)?(j|t)sx?$/,\n CLIENT_ASSETS_DIR: \"assets\",\n RSC_DIR: \"rsc\",\n MODULE_BASE: \"src\",\n MODULE_BASE_PATH: \"\",\n MODULE_BASE_URL: \"\",\n PAGE: \"src/page/page.tsx\",\n PROPS: \"src/page/props.ts\",\n CLIENT_ENTRY: \"src/client.tsx\",\n SERVER_ENTRY: \"src/server.tsx\",\n PAGE_EXPORT_NAME: \"Page\",\n PROPS_EXPORT_NAME: \"props\",\n HTML_WORKER_PATH: `worker/html/html-worker.${\n process.env[\"NODE_ENV\"] === \"development\" ? \"development\" : \"production\"\n }.js`,\n RSC_WORKER_PATH: `worker/rsc/rsc-worker.${\n process.env[\"NODE_ENV\"] === \"development\" ? \"development\" : \"production\"\n }.js`,\n LOADER_PATH: \"worker/loader.js\",\n RSC_EXTENSION: \".rsc\",\n CSS_COLLECTOR: CssCollector,\n HTML: Html,\n COLLECT_CSS: true,\n COLLECT_ASSETS: true,\n INLINE_CSS: true,\n DEV_PORT: 5173,\n PREVIEW_PORT: 4173,\n DEV_HOST: \"localhost\",\n PREVIEW_HOST: \"localhost\",\n ENV_PREFIX: \"VITE_\",\n BUILD: {\n pages: () => [\"/\"],\n client: \"client\",\n server: \"server\",\n static: \"static\",\n api: \"api\",\n outDir: \"dist\",\n assetsDir: \"assets\",\n hash: \"hash\",\n preserveModulesRoot: true,\n },\n CSS: {\n inlineThreshold: 4096, // 4KB\n inlinePatterns: [/\\.module\\.css$/], // Always inline CSS modules\n linkPatterns: [/node_modules/], // Always link node_modules CSS\n },\n MODULE_BASE_EXCEPTIONS: [] as string[],\n AUTO_DISCOVER: {\n modulePattern: (n: string) => DEFAULT_CONFIG.FILE_REGEX.test(n),\n pagePattern: (n: string) =>\n n.toLowerCase().endsWith(\"/page\") || n.toLowerCase() === \"page\",\n propsPattern: (n: string) =>\n n.toLowerCase().endsWith(\"/props\") || n.toLowerCase() === \"props\",\n clientComponents: (n: string) =>\n n.toLowerCase().endsWith(\".client\") || n.toLowerCase() === \"client\",\n serverFunctions: (n: string) =>\n n.toLowerCase().endsWith(\".server\") || n.toLowerCase() === \"server\",\n cssPattern: (n: string) => n.toLowerCase().endsWith(\".css\"),\n cssModulePattern: (n: string) => n.toLowerCase().endsWith(\".css.js\"),\n vendorPattern: (n: string) =>\n n.toLowerCase().startsWith(\"node_modules\") ||\n n.toLowerCase().startsWith(\"_virtual\"),\n htmlPattern: (n: string) => n.toLowerCase().endsWith(\".html\"),\n jsonPattern: (n: string) => n.toLowerCase().endsWith(\".json\"),\n },\n MODULE_ID: (id: string) => id,\n} as const;\n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,cAAiB,GAAA;AAAA,EAC5B,UAAY,EAAA,mBAAA;AAAA,EACZ,iBAAmB,EAAA,QAAA;AAAA,EAEnB,WAAa,EAAA,KAAA;AAAA,EACb,gBAAkB,EAAA,EAAA;AAAA,EAClB,eAAiB,EAAA,EAAA;AAAA,EACjB,IAAM,EAAA,mBAAA;AAAA,EACN,KAAO,EAAA,mBAAA;AAAA,EACP,YAAc,EAAA,gBAAA;AAAA,EACd,YAAc,EAAA,gBAAA;AAAA,EACd,gBAAkB,EAAA,MAAA;AAAA,EAClB,iBAAmB,EAAA,OAAA;AAAA,EACnB,gBAAA,EAAkB,2BAChB,OAAQ,CAAA,GAAA,CAAI,UAAU,CAAM,KAAA,aAAA,GAAgB,gBAAgB,YAC9D,CAAA,GAAA,CAAA;AAAA,EACA,eAAA,EAAiB,yBACf,OAAQ,CAAA,GAAA,CAAI,UAAU,CAAM,KAAA,aAAA,GAAgB,gBAAgB,YAC9D,CAAA,GAAA,CAAA;AAAA,EACA,WAAa,EAAA,kBAAA;AAAA,EAGb,IAAM,EAAA,IAAA;AAAA,EACN,WAAa,EAAA,IAAA;AAAA,EACb,cAAgB,EAAA,IAAA;AAAA,EAChB,UAAY,EAAA,IAAA;AAAA,EAMZ,KAAO,EAAA;AAAA,IACL,KAAA,EAAO,MAAM,CAAC,GAAG,CAAA;AAAA,IACjB,MAAQ,EAAA,QAAA;AAAA,IACR,MAAQ,EAAA,QAAA;AAAA,IACR,MAAQ,EAAA,QAAA;AAAA,IACR,GAAK,EAAA,KAAA;AAAA,IACL,MAAQ,EAAA,MAAA;AAAA,IAER,IAAM,EAAA,MAAA;AAAA,IACN,mBAAqB,EAAA;AAAA,GACvB;AAAA,EAOA,aAAe,EAAA;AAAA,IACb,eAAe,CAAC,CAAA,KAAc,cAAe,CAAA,UAAA,CAAW,KAAK,CAAC,CAAA;AAAA,IAC9D,WAAA,EAAa,CAAC,CAAA,KACZ,CAAE,CAAA,WAAA,EAAc,CAAA,QAAA,CAAS,OAAO,CAAA,IAAK,CAAE,CAAA,WAAA,EAAkB,KAAA,MAAA;AAAA,IAC3D,YAAA,EAAc,CAAC,CAAA,KACb,CAAE,CAAA,WAAA,EAAc,CAAA,QAAA,CAAS,QAAQ,CAAA,IAAK,CAAE,CAAA,WAAA,EAAkB,KAAA,OAAA;AAAA,IAC5D,gBAAA,EAAkB,CAAC,CAAA,KACjB,CAAE,CAAA,WAAA,EAAc,CAAA,QAAA,CAAS,SAAS,CAAA,IAAK,CAAE,CAAA,WAAA,EAAkB,KAAA,QAAA;AAAA,IAC7D,eAAA,EAAiB,CAAC,CAAA,KAChB,CAAE,CAAA,WAAA,EAAc,CAAA,QAAA,CAAS,SAAS,CAAA,IAAK,CAAE,CAAA,WAAA,EAAkB,KAAA,QAAA;AAAA,IAC7D,YAAY,CAAC,CAAA,KAAc,EAAE,WAAY,EAAA,CAAE,SAAS,MAAM,CAAA;AAAA,IAC1D,kBAAkB,CAAC,CAAA,KAAc,EAAE,WAAY,EAAA,CAAE,SAAS,SAAS,CAAA;AAAA,IACnE,aAAe,EAAA,CAAC,CACd,KAAA,CAAA,CAAE,WAAY,EAAA,CAAE,UAAW,CAAA,cAAc,CACzC,IAAA,CAAA,CAAE,WAAY,EAAA,CAAE,WAAW,UAAU,CAAA;AAAA,IACvC,aAAa,CAAC,CAAA,KAAc,EAAE,WAAY,EAAA,CAAE,SAAS,OAAO,CAAA;AAAA,IAC5D,aAAa,CAAC,CAAA,KAAc,EAAE,WAAY,EAAA,CAAE,SAAS,OAAO;AAAA,GAGhE;;;;"}
@@ -1,5 +1,4 @@
1
1
  export declare const getNodePath: (root?: string) => string;
2
- export declare const getPluginRoot: () => string;
3
2
  export declare const getMode: () => "production" | "development" | "test";
4
3
  export declare const getDistDir: (mode: "production" | "development" | "test") => string;
5
4
  //# sourceMappingURL=getPaths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getPaths.d.ts","sourceRoot":"","sources":["../../../plugin/config/getPaths.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,UAAU,MAAM,KAAmB,MAE1D,CAAA;AAED,eAAO,MAAM,aAAa,QAAO,MAGhC,CAAA;AAED,eAAO,MAAM,OAAO,QAAO,YAAY,GAAG,aAAa,GAAG,MAMzD,CAAA;AAED,eAAO,MAAM,UAAU,SAAU,YAAY,GAAG,aAAa,GAAG,MAAM,KAAG,MAIxE,CAAA"}
1
+ {"version":3,"file":"getPaths.d.ts","sourceRoot":"","sources":["../../../plugin/config/getPaths.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,UAAU,MAAM,KAAmB,MAE1D,CAAA;AAED,eAAO,MAAM,OAAO,QAAO,YAAY,GAAG,aAAa,GAAG,MAMzD,CAAA;AAED,eAAO,MAAM,UAAU,SAAU,YAAY,GAAG,aAAa,GAAG,MAAM,KAAG,MAIxE,CAAA"}
@@ -3,19 +3,14 @@
3
3
  * Copyright (c) Nico Brinkkemper
4
4
  * MIT License
5
5
  */
6
- import { dirname, join } from 'node:path';
7
- import { fileURLToPath } from 'node:url';
6
+ import { join } from 'node:path';
8
7
 
9
8
  const getNodePath = (root = process.cwd()) => {
10
9
  return process.env["module_root"] ?? join(root, "node_modules");
11
10
  };
12
- const getPluginRoot = () => {
13
- const __dirname = dirname(fileURLToPath(import.meta.url));
14
- return join(__dirname, "..");
15
- };
16
11
  const getMode = () => {
17
12
  return process.env["NODE_ENV"] === "development" ? "development" : process.env["NODE_ENV"] === "test" ? "test" : "production";
18
13
  };
19
14
 
20
- export { getMode, getNodePath, getPluginRoot };
15
+ export { getMode, getNodePath };
21
16
  //# sourceMappingURL=getPaths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getPaths.js","sources":["../../../plugin/config/getPaths.ts"],"sourcesContent":["import { join, dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nexport const getNodePath = (root: string = process.cwd()): string => {\n return process.env['module_root'] ?? join(root, \"node_modules\");\n}\n\nexport const getPluginRoot = (): string => {\n const __dirname = dirname(fileURLToPath(import.meta.url));\n return join(__dirname, '..');\n}\n\nexport const getMode = (): \"production\" | \"development\" | \"test\" => {\n return process.env['NODE_ENV'] === \"development\" \n ? \"development\" \n : process.env['NODE_ENV'] === \"test\" \n ? \"test\" \n : \"production\";\n}\n\nexport const getDistDir = (mode: \"production\" | \"development\" | \"test\"): string => {\n return mode === 'production' \n ? join(process.cwd(), 'dist') \n : join(process.cwd(), 'test/fixtures/dist');\n} \n"],"names":[],"mappings":";;;;;;;;AAGO,MAAM,WAAc,GAAA,CAAC,IAAe,GAAA,OAAA,CAAQ,KAAkB,KAAA;AACnE,EAAA,OAAO,QAAQ,GAAI,CAAA,aAAa,CAAK,IAAA,IAAA,CAAK,MAAM,cAAc,CAAA;AAChE;AAEO,MAAM,gBAAgB,MAAc;AACzC,EAAA,MAAM,SAAY,GAAA,OAAA,CAAQ,aAAc,CAAA,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AACxD,EAAO,OAAA,IAAA,CAAK,WAAW,IAAI,CAAA;AAC7B;AAEO,MAAM,UAAU,MAA6C;AAClE,EAAO,OAAA,OAAA,CAAQ,GAAI,CAAA,UAAU,CAAM,KAAA,aAAA,GAC/B,aACA,GAAA,OAAA,CAAQ,GAAI,CAAA,UAAU,CAAM,KAAA,MAAA,GAC1B,MACA,GAAA,YAAA;AACR;;;;"}
1
+ {"version":3,"file":"getPaths.js","sources":["../../../plugin/config/getPaths.ts"],"sourcesContent":["import { join } from 'node:path';\n\nexport const getNodePath = (root: string = process.cwd()): string => {\n return process.env['module_root'] ?? join(root, \"node_modules\");\n}\n\nexport const getMode = (): \"production\" | \"development\" | \"test\" => {\n return process.env['NODE_ENV'] === \"development\" \n ? \"development\" \n : process.env['NODE_ENV'] === \"test\" \n ? \"test\" \n : \"production\";\n}\n\nexport const getDistDir = (mode: \"production\" | \"development\" | \"test\"): string => {\n return mode === 'production' \n ? join(process.cwd(), 'dist') \n : join(process.cwd(), 'test/fixtures/dist');\n} \n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,WAAc,GAAA,CAAC,IAAe,GAAA,OAAA,CAAQ,KAAkB,KAAA;AACnE,EAAA,OAAO,QAAQ,GAAI,CAAA,aAAa,CAAK,IAAA,IAAA,CAAK,MAAM,cAAc,CAAA;AAChE;AAEO,MAAM,UAAU,MAA6C;AAClE,EAAO,OAAA,OAAA,CAAQ,GAAI,CAAA,UAAU,CAAM,KAAA,aAAA,GAC/B,aACA,GAAA,OAAA,CAAQ,GAAI,CAAA,UAAU,CAAM,KAAA,MAAA,GAC1B,MACA,GAAA,YAAA;AACR;;;;"}
@@ -0,0 +1,2 @@
1
+ export declare const MIME_TYPES: Record<string, string>;
2
+ //# sourceMappingURL=mimeTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mimeTypes.d.ts","sourceRoot":"","sources":["../../../plugin/config/mimeTypes.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAe3C,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * vite-plugin-react-server
3
+ * Copyright (c) Nico Brinkkemper
4
+ * MIT License
5
+ */
6
+ const MIME_TYPES = {
7
+ ".html": "text/html",
8
+ ".css": "text/css",
9
+ ".js": "application/javascript",
10
+ ".json": "application/json",
11
+ ".png": "image/png",
12
+ ".jpg": "image/jpeg",
13
+ ".jpeg": "image/jpeg",
14
+ ".gif": "image/gif",
15
+ ".svg": "image/svg+xml",
16
+ ".ico": "image/x-icon",
17
+ ".woff": "font/woff",
18
+ ".woff2": "font/woff2",
19
+ ".ttf": "font/ttf",
20
+ ".rsc": "text/x-component"
21
+ };
22
+
23
+ export { MIME_TYPES };
24
+ //# sourceMappingURL=mimeTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mimeTypes.js","sources":["../../../plugin/config/mimeTypes.ts"],"sourcesContent":["\nexport const MIME_TYPES: Record<string, string> = {\n '.html': 'text/html',\n '.css': 'text/css',\n '.js': 'application/javascript',\n '.json': 'application/json',\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.gif': 'image/gif',\n '.svg': 'image/svg+xml',\n '.ico': 'image/x-icon',\n '.woff': 'font/woff',\n '.woff2': 'font/woff2',\n '.ttf': 'font/ttf',\n '.rsc': 'text/x-component'\n };"],"names":[],"mappings":";;;;;AACO,MAAM,UAAqC,GAAA;AAAA,EAC9C,OAAS,EAAA,WAAA;AAAA,EACT,MAAQ,EAAA,UAAA;AAAA,EACR,KAAO,EAAA,wBAAA;AAAA,EACP,OAAS,EAAA,kBAAA;AAAA,EACT,MAAQ,EAAA,WAAA;AAAA,EACR,MAAQ,EAAA,YAAA;AAAA,EACR,OAAS,EAAA,YAAA;AAAA,EACT,MAAQ,EAAA,WAAA;AAAA,EACR,MAAQ,EAAA,eAAA;AAAA,EACR,MAAQ,EAAA,cAAA;AAAA,EACR,OAAS,EAAA,WAAA;AAAA,EACT,QAAU,EAAA,YAAA;AAAA,EACV,MAAQ,EAAA,UAAA;AAAA,EACR,MAAQ,EAAA;AACV;;;;"}
@@ -1,7 +1,7 @@
1
1
  import type { StreamPluginOptions, ResolvedUserOptions } from "../types.js";
2
- export declare const resolveOptions: (options: StreamPluginOptions, isClient?: boolean) => {
2
+ export declare const resolveOptions: <InlineCSS extends boolean = boolean>(options: StreamPluginOptions<InlineCSS>, isClient: boolean) => {
3
3
  type: "success";
4
- userOptions: ResolvedUserOptions;
4
+ userOptions: ResolvedUserOptions<InlineCSS>;
5
5
  } | {
6
6
  type: "error";
7
7
  error: Error;
@@ -1 +1 @@
1
- {"version":3,"file":"resolveOptions.d.ts","sourceRoot":"","sources":["../../../plugin/config/resolveOptions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAoD5E,eAAO,MAAM,cAAc,YAChB,mBAAmB,aAClB,OAAO,KAEf;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,mBAAmB,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CA8ShC,CAAC"}
1
+ {"version":3,"file":"resolveOptions.d.ts","sourceRoot":"","sources":["../../../plugin/config/resolveOptions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAA8C,MAAM,aAAa,CAAC;AAsDxH,eAAO,MAAM,cAAc,GAAI,SAAS,SAAS,OAAO,qBAC7C,mBAAmB,CAAC,SAAS,CAAC,YAC7B,OAAO,KAEf;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAA;CAAE,GAChE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAyThC,CAAC"}
@@ -4,8 +4,10 @@
4
4
  * MIT License
5
5
  */
6
6
  import { DEFAULT_CONFIG } from './defaults.js';
7
- import { createModuleIdGenerator } from './createModuleIdGenerator.js';
8
- import 'vite';
7
+ import { join } from 'node:path';
8
+ import { pluginRoot } from '../root.js';
9
+ import { InlineCssCollector } from '../css-collector-inline.js';
10
+ import { CssCollector } from '../css-collector.js';
9
11
 
10
12
  const resolveAutoDiscoverMatcher = (options, fallback) => {
11
13
  if (!options) {
@@ -37,10 +39,10 @@ const handleSearchQuery = (path) => {
37
39
  const filename = path.split("/").pop();
38
40
  return `${folder}/${filename}?${searchQuery}`;
39
41
  };
40
- const applyPattern = (path, pattern, fallback) => {
42
+ const applyPattern = (path, _pattern, _fallback) => {
41
43
  return path;
42
44
  };
43
- const resolveOptions = (options, isClient = false) => {
45
+ const resolveOptions = (options, isClient) => {
44
46
  const projectRoot = options.projectRoot ?? process.cwd();
45
47
  const {
46
48
  pageExportName = DEFAULT_CONFIG.PAGE_EXPORT_NAME,
@@ -111,6 +113,21 @@ const resolveOptions = (options, isClient = false) => {
111
113
  );
112
114
  const preserveModulesRoot = options.build?.preserveModulesRoot ?? DEFAULT_CONFIG.BUILD.preserveModulesRoot;
113
115
  const hashOption = typeof options.build?.hash === "string" ? options.build.hash : DEFAULT_CONFIG.BUILD.hash;
116
+ const hashString = hashOption === "" ? "" : `-[${hashOption}]`;
117
+ const hash = (n) => {
118
+ if (!n) return "";
119
+ if (hashString === "" || !isClient && !n.endsWith(".css") && !n.endsWith(".json")) {
120
+ return n;
121
+ }
122
+ const extensionIndex = n.lastIndexOf(".");
123
+ if (extensionIndex !== -1) {
124
+ const extension = n.slice(extensionIndex);
125
+ const filename = n.slice(0, extensionIndex);
126
+ return filename + hashString + extension;
127
+ } else {
128
+ return n + hashString;
129
+ }
130
+ };
114
131
  const getOutputPath = (n) => {
115
132
  if (!n) return "";
116
133
  let path = handleSearchQuery(n);
@@ -119,13 +136,17 @@ const resolveOptions = (options, isClient = false) => {
119
136
  return path;
120
137
  }
121
138
  if (testCssModule(path)) {
122
- return applyPattern(path, options.autoDiscover?.cssModulePattern);
139
+ return applyPattern(
140
+ path,
141
+ options.autoDiscover?.cssModulePattern);
123
142
  }
124
143
  if (testCss(path)) {
125
144
  return applyPattern(path, options.autoDiscover?.cssPattern);
126
145
  }
127
146
  if (testClientComponents(path)) {
128
- return applyPattern(path, options.autoDiscover?.clientComponents);
147
+ return applyPattern(
148
+ path,
149
+ options.autoDiscover?.clientComponents);
129
150
  }
130
151
  if (testHtml(path)) {
131
152
  return applyPattern(path, options.autoDiscover?.htmlPattern);
@@ -148,7 +169,9 @@ const resolveOptions = (options, isClient = false) => {
148
169
  );
149
170
  }
150
171
  if (testServerFunctions(path)) {
151
- return applyPattern(path, options.autoDiscover?.serverFunctions);
172
+ return applyPattern(
173
+ path,
174
+ options.autoDiscover?.serverFunctions);
152
175
  }
153
176
  if (testModulePattern(path)) {
154
177
  return path;
@@ -159,18 +182,18 @@ const resolveOptions = (options, isClient = false) => {
159
182
  if (testVendor(n.name)) {
160
183
  const search = n.facadeModuleId?.split("?")[1];
161
184
  if (search) {
162
- return `${n.name}.${search}.js`;
185
+ return hash(`${n.name}.${search}.js`);
163
186
  } else {
164
- return n.name + ".js";
187
+ return hash(`${n.name}.js`);
165
188
  }
166
189
  }
167
- return addJS(getOutputPath(ensureModuleBase(ensureNoRoot(n.name))));
190
+ return hash(addJS(getOutputPath(ensureModuleBase(ensureNoRoot(n.name)))));
168
191
  };
169
192
  const chunkFile = (n) => {
170
- return addJS(getOutputPath(ensureModuleBase(ensureNoRoot("_" + n.name))));
193
+ return hash(addJS(getOutputPath(ensureModuleBase(ensureNoRoot("_" + n.name)))));
171
194
  };
172
195
  const assetFile = (n) => {
173
- return getOutputPath(ensureModuleBase(ensureNoRoot(n.names[0])));
196
+ return hash(getOutputPath(ensureModuleBase(ensureNoRoot(n.names[0]))));
174
197
  };
175
198
  const build = typeof options.build === "object" && options.build !== null ? {
176
199
  pages,
@@ -200,8 +223,11 @@ const resolveOptions = (options, isClient = false) => {
200
223
  assetFile
201
224
  };
202
225
  const moduleBase = typeof options.moduleBase === "string" ? options.moduleBase : DEFAULT_CONFIG.MODULE_BASE;
203
- const moduleBasePath = typeof options.moduleBasePath === "string" ? options.moduleBasePath : options.moduleBase.startsWith("/") ? options.moduleBase : "/" + options.moduleBase;
204
- const moduleBaseURL = typeof options.moduleBaseURL === "string" ? options.moduleBaseURL : moduleBasePath ?? DEFAULT_CONFIG.MODULE_BASE_URL;
226
+ const moduleBasePath = typeof options.moduleBasePath === "string" ? options.moduleBasePath : DEFAULT_CONFIG.MODULE_BASE_PATH;
227
+ const moduleBaseURL = typeof options.moduleBaseURL === "string" ? options.moduleBaseURL : DEFAULT_CONFIG.MODULE_BASE_URL;
228
+ const rscWorkerPath = typeof options.rscWorkerPath === "string" ? join(projectRoot, options.rscWorkerPath) : join(pluginRoot, DEFAULT_CONFIG.RSC_WORKER_PATH);
229
+ const htmlWorkerPath = typeof options.htmlWorkerPath === "string" ? join(projectRoot, options.htmlWorkerPath) : join(pluginRoot, DEFAULT_CONFIG.HTML_WORKER_PATH);
230
+ const loaderPath = typeof options.loaderPath === "string" ? join(projectRoot, options.loaderPath) : join(pluginRoot, DEFAULT_CONFIG.LOADER_PATH);
205
231
  const autoDiscover = {
206
232
  modulePattern: testModulePattern,
207
233
  cssPattern: testCss,
@@ -213,22 +239,13 @@ const resolveOptions = (options, isClient = false) => {
213
239
  cssModulePattern: testCssModule,
214
240
  vendorPattern: testVendor
215
241
  };
216
- const moduleId = typeof options.moduleId === "function" ? options.moduleId : createModuleIdGenerator({
217
- isProduction: process.env["NODE_ENV"] === "production",
218
- inputRoot: projectRoot,
219
- client,
220
- server,
221
- moduleBase,
222
- preserveModulesRoot,
223
- removeExtension: DEFAULT_CONFIG.FILE_REGEX,
224
- imports: {}
225
- });
242
+ const inlineCss = options.inlineCss;
243
+ const InlineOrLinkCssCollector = options.CssCollector ?? inlineCss ? InlineCssCollector : CssCollector;
226
244
  try {
227
245
  return {
228
246
  type: "success",
229
247
  userOptions: {
230
248
  projectRoot,
231
- moduleId,
232
249
  moduleBase,
233
250
  moduleBasePath,
234
251
  moduleBaseURL,
@@ -236,13 +253,15 @@ const resolveOptions = (options, isClient = false) => {
236
253
  Page: options.Page ?? DEFAULT_CONFIG.PAGE,
237
254
  props: options.props ?? DEFAULT_CONFIG.PROPS,
238
255
  Html: options.Html ?? DEFAULT_CONFIG.HTML,
256
+ CssCollector: InlineOrLinkCssCollector,
239
257
  pageExportName,
240
258
  propsExportName,
241
259
  collectCss: options.collectCss ?? DEFAULT_CONFIG.COLLECT_CSS,
242
260
  collectAssets: options.collectAssets ?? DEFAULT_CONFIG.COLLECT_ASSETS,
243
- htmlWorkerPath: options.htmlWorkerPath ?? DEFAULT_CONFIG.HTML_WORKER_PATH,
244
- rscWorkerPath: options.rscWorkerPath ?? DEFAULT_CONFIG.RSC_WORKER_PATH,
245
- loaderPath: options.loaderPath ?? DEFAULT_CONFIG.LOADER_PATH,
261
+ inlineCss: options.inlineCss ?? DEFAULT_CONFIG.INLINE_CSS,
262
+ htmlWorkerPath,
263
+ rscWorkerPath,
264
+ loaderPath,
246
265
  clientEntry: options.clientEntry ?? DEFAULT_CONFIG.CLIENT_ENTRY,
247
266
  serverEntry: options.serverEntry ?? DEFAULT_CONFIG.SERVER_ENTRY,
248
267
  moduleBaseExceptions: options.moduleBaseExceptions ?? [],