vite-plugin-react-server 1.1.13 → 1.1.15

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 (171) hide show
  1. package/dist/package.json +3 -1
  2. package/dist/plugin/config/defaults.d.ts +2 -2
  3. package/dist/plugin/config/defaults.d.ts.map +1 -1
  4. package/dist/plugin/config/defaults.js +2 -2
  5. package/dist/plugin/config/defaults.js.map +1 -1
  6. package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
  7. package/dist/plugin/config/resolveOptions.js +101 -75
  8. package/dist/plugin/config/resolveOptions.js.map +1 -1
  9. package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
  10. package/dist/plugin/config/resolveUserConfig.js +27 -5
  11. package/dist/plugin/config/resolveUserConfig.js.map +1 -1
  12. package/dist/plugin/error/toError.d.ts.map +1 -1
  13. package/dist/plugin/error/toError.js +0 -1
  14. package/dist/plugin/error/toError.js.map +1 -1
  15. package/dist/plugin/helpers/collectManifestCss.d.ts +1 -2
  16. package/dist/plugin/helpers/collectManifestCss.d.ts.map +1 -1
  17. package/dist/plugin/helpers/collectManifestCss.js +3 -5
  18. package/dist/plugin/helpers/collectManifestCss.js.map +1 -1
  19. package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +1 -1
  20. package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -1
  21. package/dist/plugin/helpers/collectViteModuleGraphCss.js +6 -2
  22. package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -1
  23. package/dist/plugin/helpers/createCssProps.d.ts +1 -1
  24. package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
  25. package/dist/plugin/helpers/createCssProps.js +11 -32
  26. package/dist/plugin/helpers/createCssProps.js.map +1 -1
  27. package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
  28. package/dist/plugin/helpers/createRscStream.js +1 -0
  29. package/dist/plugin/helpers/createRscStream.js.map +1 -1
  30. package/dist/plugin/helpers/inputNormalizer.d.ts +1 -8
  31. package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
  32. package/dist/plugin/helpers/inputNormalizer.js +2 -5
  33. package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
  34. package/dist/plugin/loader/createDefaultLoader.d.ts.map +1 -1
  35. package/dist/plugin/loader/createDefaultLoader.js +68 -4
  36. package/dist/plugin/loader/css-loader.development.d.ts +2 -15
  37. package/dist/plugin/loader/css-loader.development.d.ts.map +1 -1
  38. package/dist/plugin/loader/css-loader.development.js +16 -15
  39. package/dist/plugin/loader/css-loader.development.js.map +1 -1
  40. package/dist/plugin/loader/css-loader.production.d.ts +1 -1
  41. package/dist/plugin/loader/css-loader.production.d.ts.map +1 -1
  42. package/dist/plugin/loader/css-loader.production.js +1 -1
  43. package/dist/plugin/loader/css-loader.production.js.map +1 -1
  44. package/dist/plugin/loader/env-loader.development.d.ts +1 -0
  45. package/dist/plugin/loader/env-loader.development.d.ts.map +1 -1
  46. package/dist/plugin/loader/env-loader.development.js +17 -9
  47. package/dist/plugin/loader/handleExports.d.ts +1 -0
  48. package/dist/plugin/loader/handleExports.d.ts.map +1 -1
  49. package/dist/plugin/loader/handleExports.js +27 -8
  50. package/dist/plugin/loader/handleExports.js.map +1 -1
  51. package/dist/plugin/loader/react-loader.server.d.ts +2 -2
  52. package/dist/plugin/loader/react-loader.server.d.ts.map +1 -1
  53. package/dist/plugin/loader/react-loader.server.js +88 -26
  54. package/dist/plugin/loader/sourceMap.d.ts.map +1 -1
  55. package/dist/plugin/loader/sourceMap.js +1 -1
  56. package/dist/plugin/loader/transformModuleIfNeeded.d.ts.map +1 -1
  57. package/dist/plugin/loader/transformModuleIfNeeded.js +1 -1
  58. package/dist/plugin/loader/transformModuleIfNeeded.js.map +1 -1
  59. package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts.map +1 -1
  60. package/dist/plugin/loader/transformModuleWithPreservedFunctions.js +86 -13
  61. package/dist/plugin/loader/transformModuleWithPreservedFunctions.js.map +1 -1
  62. package/dist/plugin/plugin.client.d.ts.map +1 -1
  63. package/dist/plugin/plugin.client.js +0 -1
  64. package/dist/plugin/plugin.client.js.map +1 -1
  65. package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts.map +1 -1
  66. package/dist/plugin/react-client/configureWorkerRequestHandler.js +81 -5
  67. package/dist/plugin/react-client/configureWorkerRequestHandler.js.map +1 -1
  68. package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -1
  69. package/dist/plugin/react-client/createMessageHandlers.js +3 -0
  70. package/dist/plugin/react-client/createMessageHandlers.js.map +1 -1
  71. package/dist/plugin/react-client/createWorkerStream.d.ts +2 -2
  72. package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
  73. package/dist/plugin/react-client/createWorkerStream.js +13 -2
  74. package/dist/plugin/react-client/createWorkerStream.js.map +1 -1
  75. package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -1
  76. package/dist/plugin/react-client/handleWorkerRscStream.js +10 -3
  77. package/dist/plugin/react-client/handleWorkerRscStream.js.map +1 -1
  78. package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
  79. package/dist/plugin/react-client/restartWorker.js +2 -1
  80. package/dist/plugin/react-client/restartWorker.js.map +1 -1
  81. package/dist/plugin/react-server/configureReactServer.d.ts.map +1 -1
  82. package/dist/plugin/react-server/configureReactServer.js +1 -2
  83. package/dist/plugin/react-server/configureReactServer.js.map +1 -1
  84. package/dist/plugin/react-server/handleServerAction.d.ts.map +1 -1
  85. package/dist/plugin/react-server/handleServerAction.js +0 -16
  86. package/dist/plugin/react-server/handleServerAction.js.map +1 -1
  87. package/dist/plugin/react-static/createBuildLoader.d.ts.map +1 -0
  88. package/dist/plugin/react-static/createBuildLoader.js.map +1 -0
  89. package/dist/plugin/react-static/plugin.d.ts.map +1 -1
  90. package/dist/plugin/react-static/plugin.js +9 -12
  91. package/dist/plugin/react-static/plugin.js.map +1 -1
  92. package/dist/plugin/react-static/temporaryReferences.d.ts.map +1 -0
  93. package/dist/plugin/react-static/temporaryReferences.js.map +1 -0
  94. package/dist/plugin/transformer/plugin.server.js +2 -2
  95. package/dist/plugin/transformer/plugin.server.js.map +1 -1
  96. package/dist/plugin/types.d.ts +20 -3
  97. package/dist/plugin/types.d.ts.map +1 -1
  98. package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
  99. package/dist/plugin/worker/rsc/handleRender.js +1 -0
  100. package/dist/plugin/worker/rsc/handleRender.js.map +1 -1
  101. package/dist/plugin/worker/rsc/handlers.d.ts +3 -0
  102. package/dist/plugin/worker/rsc/handlers.d.ts.map +1 -0
  103. package/dist/plugin/worker/rsc/handlers.js +225 -0
  104. package/dist/plugin/worker/rsc/handlers.js.map +1 -0
  105. package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
  106. package/dist/plugin/worker/rsc/messageHandler.js +4 -110
  107. package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
  108. package/dist/plugin/worker/rsc/rsc-worker.development.js +14 -16
  109. package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
  110. package/dist/plugin/worker/rsc/state.d.ts +1 -2
  111. package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
  112. package/dist/plugin/worker/rsc/state.js +1 -2
  113. package/dist/plugin/worker/rsc/state.js.map +1 -1
  114. package/dist/plugin/worker/rsc/userOptions.d.ts +2 -0
  115. package/dist/plugin/worker/rsc/userOptions.d.ts.map +1 -0
  116. package/dist/plugin/worker/rsc/userOptions.js +17 -0
  117. package/dist/plugin/worker/rsc/userOptions.js.map +1 -0
  118. package/dist/plugin/worker/types.d.ts +2 -1
  119. package/dist/plugin/worker/types.d.ts.map +1 -1
  120. package/dist/tsconfig.tsbuildinfo +1 -1
  121. package/package.json +5 -1
  122. package/plugin/config/defaults.tsx +5 -2
  123. package/plugin/config/resolveOptions.ts +106 -91
  124. package/plugin/config/resolveUserConfig.ts +29 -5
  125. package/plugin/error/toError.ts +0 -2
  126. package/plugin/helpers/collectManifestCss.ts +2 -6
  127. package/plugin/helpers/collectViteModuleGraphCss.ts +6 -0
  128. package/plugin/helpers/createCssProps.tsx +17 -46
  129. package/plugin/helpers/createRscStream.tsx +1 -0
  130. package/plugin/helpers/inputNormalizer.ts +4 -13
  131. package/plugin/loader/createDefaultLoader.ts +80 -4
  132. package/plugin/loader/css-loader.development.ts +17 -34
  133. package/plugin/loader/css-loader.production.ts +2 -4
  134. package/plugin/loader/env-loader.development.ts +38 -15
  135. package/plugin/loader/handleExports.ts +36 -13
  136. package/plugin/loader/react-loader.server.ts +110 -32
  137. package/plugin/loader/sourceMap.ts +1 -1
  138. package/plugin/loader/transformModuleIfNeeded.ts +2 -2
  139. package/plugin/loader/transformModuleWithPreservedFunctions.ts +128 -21
  140. package/plugin/plugin.client.ts +0 -2
  141. package/plugin/react-client/configureWorkerRequestHandler.ts +104 -4
  142. package/plugin/react-client/createMessageHandlers.ts +3 -0
  143. package/plugin/react-client/createWorkerStream.ts +15 -1
  144. package/plugin/react-client/handleWorkerRscStream.ts +12 -3
  145. package/plugin/react-client/restartWorker.ts +1 -0
  146. package/plugin/react-server/configureReactServer.ts +1 -2
  147. package/plugin/react-server/handleServerAction.ts +1 -19
  148. package/plugin/react-static/plugin.ts +9 -12
  149. package/plugin/transformer/plugin.server.ts +2 -2
  150. package/plugin/types.ts +31 -2
  151. package/plugin/worker/rsc/handleRender.ts +1 -0
  152. package/plugin/worker/rsc/handlers.ts +246 -0
  153. package/plugin/worker/rsc/messageHandler.tsx +3 -118
  154. package/plugin/worker/rsc/rsc-worker.development.ts +18 -20
  155. package/plugin/worker/rsc/state.ts +2 -6
  156. package/plugin/worker/rsc/userOptions.ts +8 -0
  157. package/plugin/worker/types.ts +2 -0
  158. package/dist/plugin/loader/createBuildLoader.d.ts.map +0 -1
  159. package/dist/plugin/loader/createBuildLoader.js.map +0 -1
  160. package/dist/plugin/loader/plugin.d.ts +0 -22
  161. package/dist/plugin/loader/plugin.d.ts.map +0 -1
  162. package/dist/plugin/loader/plugin.js +0 -27
  163. package/dist/plugin/loader/temporaryReferences.d.ts.map +0 -1
  164. package/dist/plugin/loader/temporaryReferences.js.map +0 -1
  165. package/plugin/loader/plugin.ts +0 -33
  166. /package/dist/plugin/{loader → react-static}/createBuildLoader.d.ts +0 -0
  167. /package/dist/plugin/{loader → react-static}/createBuildLoader.js +0 -0
  168. /package/dist/plugin/{loader → react-static}/temporaryReferences.d.ts +0 -0
  169. /package/dist/plugin/{loader → react-static}/temporaryReferences.js +0 -0
  170. /package/plugin/{loader → react-static}/createBuildLoader.ts +0 -0
  171. /package/plugin/{loader → react-static}/temporaryReferences.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"createDefaultLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createDefaultLoader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,YAAY,CAAC;CACrE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CA6C3D"}
1
+ {"version":3,"file":"createDefaultLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createDefaultLoader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,YAAY,CAAC;CACrE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAuH3D"}
@@ -1,5 +1,7 @@
1
1
  import { readFileSync } from "fs";
2
2
  import * as esbuild from "esbuild";
3
+ import { transformModuleIfNeeded } from "./transformModuleIfNeeded.js";
4
+ import { createMappingsSerializer } from "../source-map/createMappingsSerializer.js";
3
5
  /**
4
6
  * Creates a default loader function that either uses provided source or reads from file
5
7
  */
@@ -14,9 +16,40 @@ export function createDefaultLoader(source) {
14
16
  sourcemap: true,
15
17
  sourcefile: id,
16
18
  });
19
+ // Transform the code for RSC boundaries
20
+ const transformed = transformModuleIfNeeded(result.code, id, null, // isServerFunction
21
+ null, // isClientComponent
22
+ true // isServerEnvironment
23
+ );
24
+ // Create a new source map with proper mappings
25
+ const map = result.map ? {
26
+ version: 3,
27
+ sources: [id],
28
+ sourcesContent: [transformed],
29
+ mappings: (() => {
30
+ const serializer = createMappingsSerializer();
31
+ let mappings = '';
32
+ // Map each line of the transformed code to its corresponding line in the original source
33
+ const transformedLines = transformed.split('\n');
34
+ for (let i = 0; i < transformedLines.length; i++) {
35
+ if (i > 0)
36
+ mappings += ';';
37
+ // For the import and registration lines, map to the first line of the original source
38
+ if (transformedLines[i].includes('import {') || transformedLines[i].includes('registerServerReference')) {
39
+ mappings += serializer(i + 1, 0, 0, 1, 0, 0);
40
+ }
41
+ else {
42
+ // For the actual code, map to the corresponding line in the original source
43
+ const originalLine = Math.max(1, i - 1); // Adjust for the import line
44
+ mappings += serializer(i + 1, 0, 0, originalLine, 0, 0);
45
+ }
46
+ }
47
+ return mappings;
48
+ })()
49
+ } : null;
17
50
  return {
18
- source: result.code,
19
- map: result.map ? JSON.parse(result.map) : null,
51
+ source: transformed,
52
+ map
20
53
  };
21
54
  };
22
55
  }
@@ -32,9 +65,40 @@ export function createDefaultLoader(source) {
32
65
  sourcemap: true,
33
66
  sourcefile: id,
34
67
  });
68
+ // Transform the code for RSC boundaries
69
+ const transformed = transformModuleIfNeeded(result.code, id, null, // isServerFunction
70
+ null, // isClientComponent
71
+ true // isServerEnvironment
72
+ );
73
+ // Create a new source map with proper mappings
74
+ const map = result.map ? {
75
+ version: 3,
76
+ sources: [id],
77
+ sourcesContent: [transformed],
78
+ mappings: (() => {
79
+ const serializer = createMappingsSerializer();
80
+ let mappings = '';
81
+ // Map each line of the transformed code to its corresponding line in the original source
82
+ const transformedLines = transformed.split('\n');
83
+ for (let i = 0; i < transformedLines.length; i++) {
84
+ if (i > 0)
85
+ mappings += ';';
86
+ // For the import and registration lines, map to the first line of the original source
87
+ if (transformedLines[i].includes('import {') || transformedLines[i].includes('registerServerReference')) {
88
+ mappings += serializer(i + 1, 0, 0, 1, 0, 0);
89
+ }
90
+ else {
91
+ // For the actual code, map to the corresponding line in the original source
92
+ const originalLine = Math.max(1, i - 1); // Adjust for the import line
93
+ mappings += serializer(i + 1, 0, 0, originalLine, 0, 0);
94
+ }
95
+ }
96
+ return mappings;
97
+ })()
98
+ } : null;
35
99
  return {
36
- source: result.code,
37
- map: result.map ? JSON.parse(result.map) : null,
100
+ source: transformed,
101
+ map
38
102
  };
39
103
  };
40
104
  }
@@ -1,6 +1,6 @@
1
1
  import { type MessagePort } from "node:worker_threads";
2
2
  import type { LoadHookContext } from "node:module";
3
- import type { LoaderContext, SerializedUserConfig } from "../types.js";
3
+ import type { LoaderContext, SerializedUserConfig, SerializedUserOptions } from "../types.js";
4
4
  /**
5
5
  * Global port for communication between the main thread and the CSS loader.
6
6
  * This port is used to send CSS file requests and receive responses.
@@ -17,21 +17,8 @@ export declare function initialize(data: {
17
17
  id: string;
18
18
  port: MessagePort;
19
19
  resolvedConfig: SerializedUserConfig;
20
+ userOptions: SerializedUserOptions;
20
21
  }): Promise<void>;
21
- /**
22
- * Sets the current page being processed.
23
- * Used to track which CSS files are associated with which pages.
24
- *
25
- * @param page - The URL of the current page, or null if no page is active
26
- */
27
- export declare function setCurrentPage(page: string | null): void;
28
- /**
29
- * Retrieves all CSS files associated with a specific page.
30
- *
31
- * @param page - The URL of the page
32
- * @returns An array of CSS file paths used by the page
33
- */
34
- export declare function getCssFilesForPage(page: string): string[];
35
22
  /**
36
23
  * Vite's load hook implementation for CSS files.
37
24
  * Handles CSS file loading requests and returns a placeholder module.
@@ -1 +1 @@
1
- {"version":3,"file":"css-loader.development.d.ts","sourceRoot":"","sources":["../../../plugin/loader/css-loader.development.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AASvE;;;GAGG;AACH,eAAO,IAAI,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;AAY/C;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAC;IAAC,cAAc,EAAE,oBAAoB,CAAA;CAAE,iBAI7G;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,QAEjD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzD;AA2DD;;;;;;;;;GASG;AACH,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,GAAG,aAAa,GAAG;IAAE,cAAc,EAAE,oBAAoB,CAAA;CAAE,EACnF,WAAW,EAAE,GAAG,gBAQjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,OAE3E"}
1
+ {"version":3,"file":"css-loader.development.d.ts","sourceRoot":"","sources":["../../../plugin/loader/css-loader.development.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAuB,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAUnH;;;GAGG;AACH,eAAO,IAAI,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;AAK/C;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAC;IAAC,cAAc,EAAE,oBAAoB,CAAC;IAAC,WAAW,EAAE,qBAAqB,CAAA;CAAE,iBASjJ;AA+DD;;;;;;;;;GASG;AACH,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,GAAG,aAAa,GAAG;IAAE,cAAc,EAAE,oBAAoB,CAAA;CAAE,EACnF,WAAW,EAAE,GAAG,gBAQjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,OAE3E"}
@@ -7,28 +7,32 @@ import 'node:worker_threads';
7
7
  import { fileURLToPath } from 'node:url';
8
8
  import { preprocessCSS } from 'vite';
9
9
  import { readFile } from 'node:fs/promises';
10
- import { join } from 'node:path';
11
10
  import { env } from '../utils/env.js';
11
+ import { resolveOptions } from '../config/resolveOptions.js';
12
+ import { hydrateUserOptions } from '../helpers/serializeUserOptions.js';
12
13
 
13
14
  let loaderPort;
14
- const cssFilesByPage = /* @__PURE__ */ new Map();
15
- let currentPage = null;
16
15
  let resolvedConfig;
16
+ let userOptions;
17
17
  async function initialize(data) {
18
18
  loaderPort = data.port;
19
19
  resolvedConfig = data.resolvedConfig;
20
+ const resolvedUserOptions = resolveOptions(hydrateUserOptions(data.userOptions));
21
+ if (resolvedUserOptions.type === "error") {
22
+ throw new Error(resolvedUserOptions.error.message);
23
+ }
24
+ userOptions = resolvedUserOptions.userOptions;
20
25
  data.port.postMessage({ type: "INITIALIZED_CSS_LOADER", id: data.id });
21
26
  }
22
- function setCurrentPage(page) {
23
- currentPage = page;
24
- }
25
- function getCssFilesForPage(page) {
26
- return Array.from(cssFilesByPage.get(page) || []);
27
- }
28
27
  async function processCssFile(filePath, config, inline) {
29
28
  try {
30
29
  const path = filePath.startsWith("file://") ? fileURLToPath(filePath) : filePath;
31
30
  const source = await readFile(path, "utf-8");
31
+ let moduleID = path;
32
+ if (userOptions?.normalizer) {
33
+ let [, value] = userOptions.normalizer(path);
34
+ moduleID = userOptions.moduleID(value || path);
35
+ }
32
36
  const processed = await preprocessCSS(source, path, {
33
37
  ...config,
34
38
  env
@@ -36,11 +40,8 @@ async function processCssFile(filePath, config, inline) {
36
40
  if (loaderPort) {
37
41
  loaderPort.postMessage({
38
42
  type: "CSS_FILE",
39
- id: currentPage ? join(path, "?page=" + currentPage) : path,
40
- path,
41
- content: processed.code,
42
- modules: processed.modules || {},
43
- inline
43
+ id: moduleID,
44
+ content: processed.code
44
45
  });
45
46
  }
46
47
  if (inline) {
@@ -71,5 +72,5 @@ function resolve(specifier, context, defaultResolve) {
71
72
  return defaultResolve(specifier, context, defaultResolve);
72
73
  }
73
74
 
74
- export { getCssFilesForPage, initialize, load, loaderPort, resolve, setCurrentPage };
75
+ export { initialize, load, loaderPort, resolve };
75
76
  //# sourceMappingURL=css-loader.development.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"css-loader.development.js","sources":["../../../plugin/loader/css-loader.development.ts"],"sourcesContent":["import { type MessagePort } from \"node:worker_threads\";\nimport type { LoadHookContext } from \"node:module\";\nimport type { LoaderContext, SerializedUserConfig } from \"../types.js\";\nimport { fileURLToPath } from \"node:url\";\nimport { preprocessCSS } from \"vite\";\nimport type { ResolvedConfig } from \"vite\";\nimport { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { env } from \"../utils/env.js\";\nimport type { InitializedCssLoaderMessage } from \"../worker/types.js\";\n\n/**\n * Global port for communication between the main thread and the CSS loader.\n * This port is used to send CSS file requests and receive responses.\n */\nexport let loaderPort: MessagePort | undefined;\n\n/**\n * Tracks CSS files used by each page.\n * Maps page URLs to sets of CSS file paths that are used by that page.\n */\nconst cssFilesByPage = new Map<string, Set<string>>();\n\nlet currentPage: string | null = null;\nlet resolvedConfig: ResolvedConfig | undefined;\n\n\n/**\n * Initializes the CSS loader with the necessary communication channels.\n * Sets up message handlers for CSS file requests and responses.\n *\n * @param data - Configuration data for the CSS loader\n * @param data.port - The message port for communication\n */\nexport async function initialize(data: { id: string, port: MessagePort, resolvedConfig: SerializedUserConfig }) {\n loaderPort = data.port;\n resolvedConfig = data.resolvedConfig;\n data.port.postMessage({ type: \"INITIALIZED_CSS_LOADER\", id: data.id } satisfies InitializedCssLoaderMessage);\n}\n\n/**\n * Sets the current page being processed.\n * Used to track which CSS files are associated with which pages.\n *\n * @param page - The URL of the current page, or null if no page is active\n */\nexport function setCurrentPage(page: string | null) {\n currentPage = page;\n}\n\n/**\n * Retrieves all CSS files associated with a specific page.\n *\n * @param page - The URL of the page\n * @returns An array of CSS file paths used by the page\n */\nexport function getCssFilesForPage(page: string): string[] {\n return Array.from(cssFilesByPage.get(page) || []);\n}\n\n/**\n * Processes a CSS file request.\n * Sends a request to the main thread and waits for the processed CSS.\n *\n * @param filePath - The file system path of the CSS file\n * @param config - The Vite config\n * @returns A promise that resolves to the processed CSS content\n */\nasync function processCssFile(\n filePath: string,\n config: ResolvedConfig,\n inline: boolean\n): Promise<{ format: string; source: string; shortCircuit: boolean }> {\n try {\n // Convert file URL to path if needed\n const path = filePath.startsWith(\"file://\")\n ? fileURLToPath(filePath)\n : filePath;\n\n // Process CSS using Vite's preprocessCSS\n const source = await readFile(path, \"utf-8\");\n const processed = await preprocessCSS(source, path, {\n ...config,\n env: env\n });\n\n // If we're processing CSS for a specific page, notify the message handler\n if (loaderPort) {\n loaderPort.postMessage({\n type: \"CSS_FILE\",\n id: currentPage ? join(path, \"?page=\" + currentPage) : path,\n path: path,\n content: processed.code,\n modules: processed.modules || {},\n inline,\n });\n }\n\n // Return a module that can be used by React components\n if (inline) {\n return {\n format: \"module\",\n source: processed.code,\n shortCircuit: true,\n };\n }\n return {\n format: \"module\",\n source: `export default ${JSON.stringify(processed.modules || {})};`,\n shortCircuit: true,\n };\n } catch (error) {\n console.error(`[css-loader] Error processing CSS file: ${error}`);\n throw error;\n }\n}\n\n/**\n * Vite's load hook implementation for CSS files.\n * Handles CSS file loading requests and returns a placeholder module.\n * The actual CSS content is processed in the main thread.\n *\n * @param url - The URL of the module to load\n * @param context - The load hook context\n * @param defaultLoad - The default load function\n * @returns A promise that resolves to the module content\n */\nexport async function load(\n url: string,\n context: LoadHookContext & LoaderContext & { resolvedConfig: SerializedUserConfig },\n defaultLoad: any\n) {\n const [name, query] = url.split(\"?\");\n if (name.endsWith(\".css\")) {\n return processCssFile(url, resolvedConfig as ResolvedConfig, query === \"inline\");\n }\n\n return defaultLoad(url, context, defaultLoad);\n}\n\n/**\n * Vite's resolve hook implementation.\n * Handles module resolution during development.\n *\n * @param specifier - The module specifier to resolve\n * @param context - The resolve hook context\n * @param defaultResolve - The default resolve function\n * @returns A promise that resolves to the resolved module\n */\nexport function resolve(specifier: string, context: any, defaultResolve: any) {\n return defaultResolve(specifier, context, defaultResolve);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAeW,IAAA;AAMX,MAAM,cAAA,uBAAqB,GAAyB,EAAA;AAEpD,IAAI,WAA6B,GAAA,IAAA;AACjC,IAAI,cAAA;AAUJ,eAAsB,WAAW,IAA+E,EAAA;AAC9G,EAAA,UAAA,GAAa,IAAK,CAAA,IAAA;AAClB,EAAA,cAAA,GAAiB,IAAK,CAAA,cAAA;AACtB,EAAK,IAAA,CAAA,IAAA,CAAK,YAAY,EAAE,IA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IAAA,EAAE,CAAC,CAAA,CAAA,CAAA;AAAA,MACjE,YAAc,EAAA;AAAA,KAChB;AAAA,WACO,KAAO,EAAA;AACd,IAAQ,OAAA,CAAA,KAAA,CAAM,CAA2C,wCAAA,EAAA,KAAK,CAAE,CAAA,CAAA;AAChE,IAAM,MAAA,KAAA;AAAA;AAEV;AAYA,eAAsB,IAAA,CACpB,GACA,EAAA,OAAA,EACA,WACA,EAAA;AACA,EAAA,MAAM,CAAC,IAAM,EAAA,KAAK,CAAI,GAAA,GAAA,CAAI,MAAM,GAAG,CAAA;AACnC,EAAI,IAAA,IAAA,CAAK,QAAS,CAAA,MAAM,CAAG,EAAA;AACzB,IAAA,OAAO,cAAe,CAAA,GAAA,EAAK,cAAkC,EAAA,KAAA,KAAU,QAAQ,CAAA;AAAA;AAGjF,EAAO,OAAA,WAAA,CAAY,GAAK,EAAA,OAAA,EAAS,WAAW,CAAA;AAC9C;AAWO,SAAS,OAAA,CAAQ,SAAmB,EAAA,OAAA,EAAc,cAAqB,EAAA;AAC5E,EAAO,OAAA,cAAA,CAAe,SAAW,EAAA,OAAA,EAAS,cAAc,CAAA;AAC1D;;;;"}
1
+ {"version":3,"file":"css-loader.development.js","sources":["../../../plugin/loader/css-loader.development.ts"],"sourcesContent":["import { type MessagePort } from \"node:worker_threads\";\nimport type { LoadHookContext } from \"node:module\";\nimport type { LoaderContext, ResolvedUserOptions, SerializedUserConfig, SerializedUserOptions } from \"../types.js\";\nimport { fileURLToPath } from \"node:url\";\nimport { preprocessCSS } from \"vite\";\nimport type { ResolvedConfig } from \"vite\";\nimport { readFile } from \"node:fs/promises\";\nimport { env } from \"../utils/env.js\";\nimport type { InitializedCssLoaderMessage } from \"../worker/types.js\";\nimport { resolveOptions } from \"../config/resolveOptions.js\";\nimport { hydrateUserOptions } from \"../helpers/index.js\";\n\n/**\n * Global port for communication between the main thread and the CSS loader.\n * This port is used to send CSS file requests and receive responses.\n */\nexport let loaderPort: MessagePort | undefined;\n\nlet resolvedConfig: ResolvedConfig | undefined;\nlet userOptions: ResolvedUserOptions | undefined; \n\n/**\n * Initializes the CSS loader with the necessary communication channels.\n * Sets up message handlers for CSS file requests and responses.\n *\n * @param data - Configuration data for the CSS loader\n * @param data.port - The message port for communication\n */\nexport async function initialize(data: { id: string, port: MessagePort, resolvedConfig: SerializedUserConfig, userOptions: SerializedUserOptions }) {\n loaderPort = data.port;\n resolvedConfig = data.resolvedConfig;\n const resolvedUserOptions = resolveOptions(hydrateUserOptions(data.userOptions));\n if(resolvedUserOptions.type === \"error\") {\n throw new Error(resolvedUserOptions.error.message);\n }\n userOptions = resolvedUserOptions.userOptions;\n data.port.postMessage({ type: \"INITIALIZED_CSS_LOADER\", id: data.id } satisfies InitializedCssLoaderMessage);\n}\n\n\n\n/**\n * Processes a CSS file request.\n * Sends a request to the main thread and waits for the processed CSS.\n *\n * @param filePath - The file system path of the CSS file\n * @param config - The Vite config\n * @returns A promise that resolves to the processed CSS content\n */\nasync function processCssFile(\n filePath: string,\n config: ResolvedConfig,\n inline: boolean\n): Promise<{ format: string; source: string; shortCircuit: boolean }> {\n try {\n // Convert file URL to path if needed\n const path = filePath.startsWith(\"file://\")\n ? fileURLToPath(filePath)\n : filePath;\n\n // Process CSS using Vite's preprocessCSS\n const source = await readFile(path, \"utf-8\");\n let moduleID = path;\n if(userOptions?.normalizer) {\n let [,value] = userOptions.normalizer(path);\n moduleID = userOptions.moduleID(value || path);\n }\n const processed = await preprocessCSS(source, path, {\n ...config,\n env: env\n });\n\n // If we're processing CSS for a specific page, notify the message handler\n if (loaderPort) {\n loaderPort.postMessage({\n type: \"CSS_FILE\",\n id: moduleID,\n content: processed.code\n });\n }\n\n // Return a module that can be used by React components\n if (inline) {\n return {\n format: \"module\",\n source: processed.code,\n shortCircuit: true,\n };\n }\n return {\n format: \"module\",\n source: `export default ${JSON.stringify(processed.modules || {})};`,\n shortCircuit: true,\n };\n } catch (error) {\n console.error(`[css-loader] Error processing CSS file: ${error}`);\n throw error;\n }\n}\n\n/**\n * Vite's load hook implementation for CSS files.\n * Handles CSS file loading requests and returns a placeholder module.\n * The actual CSS content is processed in the main thread.\n *\n * @param url - The URL of the module to load\n * @param context - The load hook context\n * @param defaultLoad - The default load function\n * @returns A promise that resolves to the module content\n */\nexport async function load(\n url: string,\n context: LoadHookContext & LoaderContext & { resolvedConfig: SerializedUserConfig },\n defaultLoad: any\n) {\n const [name, query] = url.split(\"?\");\n if (name.endsWith(\".css\")) {\n return processCssFile(url, resolvedConfig as ResolvedConfig, query === \"inline\");\n }\n\n return defaultLoad(url, context, defaultLoad);\n}\n\n/**\n * Vite's resolve hook implementation.\n * Handles module resolution during development.\n *\n * @param specifier - The module specifier to resolve\n * @param context - The resolve hook context\n * @param defaultResolve - The default resolve function\n * @returns A promise that resolves to the resolved module\n */\nexport function resolve(specifier: string, context: any, defaultResolve: any) {\n return defaultResolve(specifier, context, defaultResolve);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgBW,IAAA;AAEX,IAAI,cAAA;AACJ,IAAI,WAAA;AASJ,eAAsB,WAAW,IAAmH,EAAA;AAClJ,EAAA,UAAA,GAAa,IAAK,CAAA,IAAA;AAClB,EAAA,cAAA,GAAiB,IAAK,CAAA,cAAA;AACtB,EAAA,MAAM,mBAAsB,GAAA,cAAA,CAAe,kBAAmB,CAAA,IAAA,CAAK,WAAW,CAAC,CAAA;AAC/E,EAAG,IAAA,mBAAA,CAAoB,SAAS,OAAS,EAAA;AACvC,IAAA,MAAM,IAAI,KAAA,CAAM,mBAAoB,CAAA,KAAA,CAAM,OAAO,CAAA;AAAA;AAEnD,EAAA,WAAA,GAAc,mBAAoB,CAAA,WAAA;AAClC,EAAK,IAAA,CAAA,IAAA,CAAK,YAAY,EAAE,IAAA,EAAM,0BAA0B,EAAI,EAAA,IAAA,CAAK,IAA0C,CAAA;AAC7G;AAYA,eAAe,cAAA,CACb,QACA,EAAA,MAAA,EACA,MACoE,EAAA;AACpE,EAAI,IAAA;AAEF,IAAA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EAAA;AACA,EAAA,MAAM,CAAC,IAAM,EAAA,KAAK,CAAI,GAAA,GAAA,CAAI,MAAM,GAAG,CAAA;AACnC,EAAI,IAAA,IAAA,CAAK,QAAS,CAAA,MAAM,CAAG,EAAA;AACzB,IAAA,OAAO,cAAe,CAAA,GAAA,EAAK,cAAkC,EAAA,KAAA,KAAU,QAAQ,CAAA;AAAA;AAGjF,EAAO,OAAA,WAAA,CAAY,GAAK,EAAA,OAAA,EAAS,WAAW,CAAA;AAC9C;AAWO,SAAS,OAAA,CAAQ,SAAmB,EAAA,OAAA,EAAc,cAAqB,EAAA;AAC5E,EAAO,OAAA,cAAA,CAAe,SAAW,EAAA,OAAA,EAAS,cAAc,CAAA;AAC1D;;;;"}
@@ -12,9 +12,9 @@ export declare let loaderPort: MessagePort | undefined;
12
12
  *
13
13
  * @param data - Configuration data for the CSS loader
14
14
  * @param data.port - The message port for communication
15
- * @param data.server - The Vite dev server instance
16
15
  */
17
16
  export declare function initialize(data: {
17
+ id: string;
18
18
  port: MessagePort;
19
19
  }): Promise<void>;
20
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"css-loader.production.d.ts","sourceRoot":"","sources":["../../../plugin/loader/css-loader.production.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD;;;GAGG;AACH,eAAO,IAAI,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;AAI/C;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,iBAG3D;AAsCD;;;;;;;;;GASG;AACH,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,GAAG,aAAa,EACxC,WAAW,EAAE,GAAG,gBASjB"}
1
+ {"version":3,"file":"css-loader.production.d.ts","sourceRoot":"","sources":["../../../plugin/loader/css-loader.production.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD;;;GAGG;AACH,eAAO,IAAI,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;AAI/C;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,iBAGvE;AAqCD;;;;;;;;;GASG;AACH,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,GAAG,aAAa,EACxC,WAAW,EAAE,GAAG,gBASjB"}
@@ -10,7 +10,7 @@ let loaderPort;
10
10
  let stashedCssFiles = /* @__PURE__ */ new Map();
11
11
  async function initialize(data) {
12
12
  loaderPort = data.port;
13
- data.port.postMessage({ type: "INITIALIZED_CSS_LOADER" });
13
+ data.port.postMessage({ type: "INITIALIZED_CSS_LOADER", id: data.id });
14
14
  }
15
15
  async function processCssFile(filePath) {
16
16
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"css-loader.production.js","sources":["../../../plugin/loader/css-loader.production.ts"],"sourcesContent":["import type { MessagePort } from \"node:worker_threads\";\nimport type { LoadHookContext } from \"node:module\";\nimport type { LoaderContext } from \"../types.js\";\nimport { fileURLToPath } from \"node:url\";\nimport { readFile } from \"node:fs/promises\";\n\n/**\n * Global port for communication between the main thread and the CSS loader.\n * This port is used to send CSS file requests and receive responses.\n */\nexport let loaderPort: MessagePort | undefined;\n\nlet stashedCssFiles = new Map();\n\n/**\n * Initializes the CSS loader with the necessary communication channels.\n * Sets up message handlers for CSS file requests and responses.\n *\n * @param data - Configuration data for the CSS loader\n * @param data.port - The message port for communication\n * @param data.server - The Vite dev server instance\n */\nexport async function initialize(data: { port: MessagePort }) {\n loaderPort = data.port;\n data.port.postMessage({ type: \"INITIALIZED_CSS_LOADER\" });\n}\n\n/**\n * Processes a CSS file request.\n * Sends a request to the main thread and waits for the processed CSS.\n *\n * @param filePath - The file system path of the CSS file\n * @param config - The Vite config\n * @returns A promise that resolves to the processed CSS content\n */\nasync function processCssFile(\n filePath: string\n): Promise<{ format: string; source: string; shortCircuit: boolean }> {\n try {\n // Convert file URL to path if needed\n const path = filePath.startsWith(\"file://\")\n ? fileURLToPath(filePath)\n : filePath;\n if (stashedCssFiles.has(filePath)) {\n return {\n format: \"module\",\n source: stashedCssFiles.get(filePath),\n shortCircuit: true,\n };\n }\n // Process CSS using Vite's preprocessCSS\n const source = await readFile(path, \"utf-8\");\n stashedCssFiles.set(path, source);\n return {\n format: \"module\",\n source: source,\n shortCircuit: true,\n };\n } catch (error) {\n throw error;\n }\n}\n\n/**\n * Vite's load hook implementation for CSS files.\n * Handles CSS file loading requests and returns a placeholder module.\n * The actual CSS content is processed in the main thread.\n *\n * @param url - The URL of the module to load\n * @param context - The load hook context\n * @param defaultLoad - The default load function\n * @returns A promise that resolves to the module content\n */\nexport async function load(\n url: string,\n context: LoadHookContext & LoaderContext,\n defaultLoad: any\n) {\n // Handle CSS files\n const [name] = url.split(\"?\");\n if (name.endsWith(\".css\")) {\n return processCssFile(url);\n }\n\n return defaultLoad(url, context, defaultLoad);\n}\n"],"names":[],"mappings":";;;;;;;;AAUW,IAAA;AAEX,IAAI,eAAA,uBAAsB,GAAI,EAAA;AAU9B,eAAsB,WAAW,IAA6B,EAAA;AAC5D,EAAA,UAAA,GAAa,IAAK,CAAA,IAAA;AAClB,EAAA,IAAA,CAAK,IAAK,CAAA,WAAA,CAAY,EAAE,IAAA,EAAM,0BAA0B,CAAA;AAC1D;AAUA,eAAe,eACb,QACoE,EAAA;AACpE,EAAI,IAAA;AAEF,IAAA,MAAM,OAAO,QAAS,CAAA,UAAA,CAAW,SAAS,CACtC,GAAA,aAAA,CAAc,QAAQ,CACtB,GAAA,QAAA;AACJ,IAAI,IAAA,eAAA,CAAgB,GAAI,CAAA,QAAQ,CAAG,EAAA;AACjC,MAAO,OAAA;AAAA,QACL,MAAQ,EAAA,QAAA;AAAA,QACR,MAAA,EAAQ,eAAgB,CAAA,GAAA,CAAI,QAAQ,CAAA;AAAA,QACpC,YAAc,EAAA;AAAA,OAChB;AAAA;AAGF,IAAA,MAAM,MAAS,GAAA,MAAM,QAAS,CAAA,IAAA,EAAM,OAAO,CAAA;AAC3C,IAAgB,eAAA,CAAA,GAAA,CAAI,MAAM,MAAM,CAAA;AAChC,IAAO,OAAA;AAAA,MACL,MAAQ,EAAA,QAAA;AAAA,MACR,MAAA;AAAA,MACA,YAAc,EAAA;AAAA,KAChB;AAAA,WACO,KAAO,EAAA;AACd,IAAM,MAAA,KAAA;AAAA;AAEV;AAYA,eAAsB,IAAA,CACpB,GACA,EAAA,OAAA,EACA,WACA,EAAA;AAEA,EAAA,MAAM,CAAC,IAAI,CAAI,GAAA,GAAA,CAAI,MAAM,GAAG,CAAA;AAC5B,EAAI,IAAA,IAAA,CAAK,QAAS,CAAA,MAAM,CAAG,EAAA;AACzB,IAAA,OAAO,eAAe,GAAG,CAAA;AAAA;AAG3B,EAAO,OAAA,WAAA,CAAY,GAAK,EAAA,OAAA,EAAS,WAAW,CAAA;AAC9C;;;;"}
1
+ {"version":3,"file":"css-loader.production.js","sources":["../../../plugin/loader/css-loader.production.ts"],"sourcesContent":["import type { MessagePort } from \"node:worker_threads\";\nimport type { LoadHookContext } from \"node:module\";\nimport type { LoaderContext } from \"../types.js\";\nimport { fileURLToPath } from \"node:url\";\nimport { readFile } from \"node:fs/promises\";\n\n/**\n * Global port for communication between the main thread and the CSS loader.\n * This port is used to send CSS file requests and receive responses.\n */\nexport let loaderPort: MessagePort | undefined;\n\nlet stashedCssFiles = new Map();\n\n/**\n * Initializes the CSS loader with the necessary communication channels.\n * Sets up message handlers for CSS file requests and responses.\n *\n * @param data - Configuration data for the CSS loader\n * @param data.port - The message port for communication\n */\nexport async function initialize(data: { id: string, port: MessagePort }) {\n loaderPort = data.port;\n data.port.postMessage({ type: \"INITIALIZED_CSS_LOADER\", id: data.id });\n}\n\n/**\n * Processes a CSS file request.\n * Sends a request to the main thread and waits for the processed CSS.\n *\n * @param filePath - The file system path of the CSS file\n * @returns A promise that resolves to the processed CSS content\n */\nasync function processCssFile(\n filePath: string\n): Promise<{ format: string; source: string; shortCircuit: boolean }> {\n try {\n // Convert file URL to path if needed\n const path = filePath.startsWith(\"file://\")\n ? fileURLToPath(filePath)\n : filePath;\n if (stashedCssFiles.has(filePath)) {\n return {\n format: \"module\",\n source: stashedCssFiles.get(filePath),\n shortCircuit: true,\n };\n }\n // Process CSS using Vite's preprocessCSS\n const source = await readFile(path, \"utf-8\");\n stashedCssFiles.set(path, source);\n return {\n format: \"module\",\n source: source,\n shortCircuit: true,\n };\n } catch (error) {\n throw error;\n }\n}\n\n/**\n * Vite's load hook implementation for CSS files.\n * Handles CSS file loading requests and returns a placeholder module.\n * The actual CSS content is processed in the main thread.\n *\n * @param url - The URL of the module to load\n * @param context - The load hook context\n * @param defaultLoad - The default load function\n * @returns A promise that resolves to the module content\n */\nexport async function load(\n url: string,\n context: LoadHookContext & LoaderContext,\n defaultLoad: any\n) {\n // Handle CSS files\n const [name] = url.split(\"?\");\n if (name.endsWith(\".css\")) {\n return processCssFile(url);\n }\n\n return defaultLoad(url, context, defaultLoad);\n}\n"],"names":[],"mappings":";;;;;;;;AAUW,IAAA;AAEX,IAAI,eAAA,uBAAsB,GAAI,EAAA;AAS9B,eAAsB,WAAW,IAAyC,EAAA;AACxE,EAAA,UAAA,GAAa,IAAK,CAAA,IAAA;AAClB,EAAK,IAAA,CAAA,IAAA,CAAK,YAAY,EAAE,IAAA,EAAM,0BAA0B,EAAI,EAAA,IAAA,CAAK,IAAI,CAAA;AACvE;AASA,eAAe,eACb,QACoE,EAAA;AACpE,EAAI,IAAA;AAEF,IAAA,MAAM,OAAO,QAAS,CAAA,UAAA,CAAW,SAAS,CACtC,GAAA,aAAA,CAAc,QAAQ,CACtB,GAAA,QAAA;AACJ,IAAI,IAAA,eAAA,CAAgB,GAAI,CAAA,QAAQ,CAAG,EAAA;AACjC,MAAO,OAAA;AAAA,QACL,MAAQ,EAAA,QAAA;AAAA,QACR,MAAA,EAAQ,eAAgB,CAAA,GAAA,CAAI,QAAQ,CAAA;AAAA,QACpC,YAAc,EAAA;AAAA,OAChB;AAAA;AAGF,IAAA,MAAM,MAAS,GAAA,MAAM,QAAS,CAAA,IAAA,EAAM,OAAO,CAAA;AAC3C,IAAgB,eAAA,CAAA,GAAA,CAAI,MAAM,MAAM,CAAA;AAChC,IAAO,OAAA;AAAA,MACL,MAAQ,EAAA,QAAA;AAAA,MACR,MAAA;AAAA,MACA,YAAc,EAAA;AAAA,KAChB;AAAA,WACO,KAAO,EAAA;AACd,IAAM,MAAA,KAAA;AAAA;AAEV;AAYA,eAAsB,IAAA,CACpB,GACA,EAAA,OAAA,EACA,WACA,EAAA;AAEA,EAAA,MAAM,CAAC,IAAI,CAAI,GAAA,GAAA,CAAI,MAAM,GAAG,CAAA;AAC5B,EAAI,IAAA,IAAA,CAAK,QAAS,CAAA,MAAM,CAAG,EAAA;AACzB,IAAA,OAAO,eAAe,GAAG,CAAA;AAAA;AAG3B,EAAO,OAAA,WAAA,CAAY,GAAK,EAAA,OAAA,EAAS,WAAW,CAAA;AAC9C;;;;"}
@@ -4,6 +4,7 @@ import type { MessagePort } from "node:worker_threads";
4
4
  import type { ResolvedConfig } from "vite";
5
5
  export declare let loaderPort: MessagePort | undefined;
6
6
  export declare function initialize(data: {
7
+ id: string;
7
8
  port: MessagePort;
8
9
  resolvedConfig: ResolvedConfig;
9
10
  }): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"env-loader.development.d.ts","sourceRoot":"","sources":["../../../plugin/loader/env-loader.development.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE3C,eAAO,IAAI,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;AAI/C,wBAAsB,UAAU,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,cAAc,EAAE,cAAc,CAAA;CAAE,iBAI3F;AAGD,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,GAAG,aAAa,EACxC,QAAQ,EAAE,GAAG,gBAsDd;AAGD,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,EACZ,sBAAsB,EAAE,GAAG,gBAI5B"}
1
+ {"version":3,"file":"env-loader.development.d.ts","sourceRoot":"","sources":["../../../plugin/loader/env-loader.development.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAG3C,eAAO,IAAI,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;AAI/C,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,cAAc,EAAE,cAAc,CAAC;CAChC,iBAQA;AAGD,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,GAAG,aAAa,EACxC,QAAQ,EAAE,GAAG,gBAgEd;AAGD,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,EACZ,sBAAsB,EAAE,GAAG,gBAQ5B"}
@@ -4,7 +4,11 @@ let resolvedConfig;
4
4
  export async function initialize(data) {
5
5
  loaderPort = data.port;
6
6
  resolvedConfig = data.resolvedConfig;
7
- data.port.postMessage({ type: "INITIALIZED_ENV_LOADER" });
7
+ data.port.postMessage({
8
+ type: "INITIALIZED_ENV_LOADER",
9
+ id: data.id,
10
+ env: {},
11
+ });
8
12
  }
9
13
  // Load hook
10
14
  export async function load(url, context, nextLoad) {
@@ -14,7 +18,7 @@ export async function load(url, context, nextLoad) {
14
18
  return result;
15
19
  }
16
20
  // Skip node internals and hidden files
17
- if (url.startsWith('node:') || url.includes('/.')) {
21
+ if (url.startsWith("node:") || url.includes("/.")) {
18
22
  return result;
19
23
  }
20
24
  // Convert source to string if it's a Buffer or Uint8Array
@@ -22,7 +26,8 @@ export async function load(url, context, nextLoad) {
22
26
  if (typeof result.source === "string") {
23
27
  sourceStr = result.source;
24
28
  }
25
- else if (result.source instanceof Uint8Array || Buffer.isBuffer(result.source)) {
29
+ else if (result.source instanceof Uint8Array ||
30
+ Buffer.isBuffer(result.source)) {
26
31
  sourceStr = result.source.toString("utf-8");
27
32
  }
28
33
  else {
@@ -33,24 +38,27 @@ export async function load(url, context, nextLoad) {
33
38
  const define = resolvedConfig?.define || {};
34
39
  // Create the env object with Vite's default environment variables
35
40
  const envObject = {
36
- MODE: resolvedConfig?.mode || 'development',
37
- BASE_URL: resolvedConfig?.base || '/',
41
+ MODE: resolvedConfig?.mode || "development",
42
+ BASE_URL: resolvedConfig?.base || "/",
38
43
  PROD: resolvedConfig?.isProduction ? true : false,
39
44
  DEV: resolvedConfig?.isProduction ? false : true,
40
45
  SSR: true,
41
46
  ...Object.fromEntries(Object.entries(define)
42
- .filter(([key]) => key.startsWith('import.meta.env.'))
43
- .map(([key, value]) => [key.replace('import.meta.env.', ''), JSON.parse(value)]))
47
+ .filter(([key]) => key.startsWith("import.meta.env."))
48
+ .map(([key, value]) => [
49
+ key.replace("import.meta.env.", ""),
50
+ JSON.parse(value),
51
+ ])),
44
52
  };
45
53
  // Replace environment variable references in the source
46
54
  let newSource = sourceStr;
47
55
  // Check if we need to handle import.meta.env
48
- if (newSource.includes('import.meta.env')) {
56
+ if (newSource.includes("import.meta.env")) {
49
57
  newSource = `Object.defineProperty(import.meta, "env", { value: ${JSON.stringify(envObject)}, writable: false, configurable: false });\n${newSource}`;
50
58
  }
51
59
  return {
52
60
  ...result,
53
- source: newSource
61
+ source: newSource,
54
62
  };
55
63
  }
56
64
  // Transform hook
@@ -28,6 +28,7 @@ export declare function handleExports(source: string, program: Program, isServer
28
28
  before?: string[];
29
29
  after?: string[];
30
30
  isAsync?: boolean;
31
+ isServerAction?: boolean;
31
32
  }>;
32
33
  };
33
34
  //# sourceMappingURL=handleExports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleExports.d.ts","sourceRoot":"","sources":["../../../plugin/loader/handleExports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,EACnD,iBAAiB,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,GACnD;IACD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,GAAG,CACV,MAAM,EACN;QACE,IAAI,EAAE,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK,CAAC;QAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CACF,CAAC;CACH,CA0OA"}
1
+ {"version":3,"file":"handleExports.d.ts","sourceRoot":"","sources":["../../../plugin/loader/handleExports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,EACnD,iBAAiB,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,GACnD;IACD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,GAAG,CACV,MAAM,EACN;QACE,IAAI,EAAE,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK,CAAC;QAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,CACF,CAAC;CACH,CAgQA"}
@@ -18,7 +18,26 @@ function handleExports(source, program, isServerFunction, isClientComponent) {
18
18
  }
19
19
  }
20
20
  if (node.type === "ImportDeclaration") {
21
+ const importSource = node.source.value;
22
+ const isServerImport = importSource.includes(".server.");
21
23
  imports.push(source.slice(node.start, node.end));
24
+ if (isServerImport) {
25
+ for (const spec of node.specifiers) {
26
+ if (spec.type === "ImportSpecifier") {
27
+ const localName = spec.local.type === "Identifier" ? spec.local.name : "";
28
+ const importedName = spec.imported.type === "Identifier" ? spec.imported.name : "";
29
+ if (localName && importedName) {
30
+ exports.set(localName, {
31
+ type: "function",
32
+ localName,
33
+ isServerAction: true,
34
+ before: [...currentBefore]
35
+ });
36
+ exportNames.push(localName);
37
+ }
38
+ }
39
+ }
40
+ }
22
41
  } else if (node.type === "ExportAllDeclaration") {
23
42
  exports.set("*", {
24
43
  type: "all",
@@ -34,8 +53,8 @@ function handleExports(source, program, isServerFunction, isClientComponent) {
34
53
  type: "function",
35
54
  declaration: source.slice(node.declaration.start, node.declaration.end),
36
55
  before: [...currentBefore],
37
- // Copy the current before array
38
- isAsync: node.declaration.async
56
+ isAsync: node.declaration.async,
57
+ isServerAction: isServerFunction === true
39
58
  });
40
59
  exportNames.push(name);
41
60
  currentBefore = [];
@@ -45,7 +64,6 @@ function handleExports(source, program, isServerFunction, isClientComponent) {
45
64
  type: "class",
46
65
  declaration: source.slice(node.declaration.start, node.declaration.end),
47
66
  before: [...currentBefore]
48
- // Copy the current before array
49
67
  });
50
68
  exportNames.push(name);
51
69
  currentBefore = [];
@@ -60,8 +78,8 @@ function handleExports(source, program, isServerFunction, isClientComponent) {
60
78
  type: isFunction ? "function" : "variable",
61
79
  declaration: source.slice(decl.start, decl.end),
62
80
  before: [...currentBefore],
63
- // Copy the current before array
64
- isAsync: isAsync || false
81
+ isAsync: isAsync || false,
82
+ isServerAction: isFunction != null && isServerFunction === true
65
83
  });
66
84
  exportNames.push(name);
67
85
  currentBefore = [];
@@ -83,7 +101,8 @@ function handleExports(source, program, isServerFunction, isClientComponent) {
83
101
  localName,
84
102
  declaration: source.slice(functionDecl.start, functionDecl.end),
85
103
  before: [...currentBefore],
86
- isAsync: functionDecl.async
104
+ isAsync: functionDecl.async,
105
+ isServerAction: isServerFunction === true
87
106
  });
88
107
  exportNames.push(exportedName);
89
108
  } else {
@@ -103,7 +122,8 @@ function handleExports(source, program, isServerFunction, isClientComponent) {
103
122
  localName,
104
123
  declaration: source.slice(decl.start, decl.end),
105
124
  before: [...currentBefore],
106
- isAsync
125
+ isAsync,
126
+ isServerAction: isServerFunction === true
107
127
  });
108
128
  exportNames.push(exportedName);
109
129
  }
@@ -119,7 +139,6 @@ function handleExports(source, program, isServerFunction, isClientComponent) {
119
139
  }
120
140
  }
121
141
  }
122
- currentBefore = [];
123
142
  }
124
143
  } else if (node.type === "ExportDefaultDeclaration") {
125
144
  if (node.declaration && node.declaration.type === "FunctionDeclaration" && node.declaration.id) {
@@ -1 +1 @@
1
- {"version":3,"file":"handleExports.js","sources":["../../../plugin/loader/handleExports.ts"],"sourcesContent":["import type { Program } from \"./types.js\";\nimport type { FunctionDeclaration, VariableDeclaration, VariableDeclarator } from \"acorn\";\n\n/**\n * Collects and organizes export information from a module.\n *\n * For all modules:\n * - Collects import statements\n * - Collects export names\n * - Collects declarations\n *\n * The actual transformation of exports (like wrapping with registerServerReference)\n * happens in transformModuleWithPreservedFunctions.\n *\n * @param source - The source code of the module\n * @param url - The URL of the module\n * @param program - The parsed AST program\n * @param isServerFunction - Whether this is a server module\n * @param isClientComponent - Whether this is a client module\n * @returns Object containing imports, declarations, and export names\n */\nexport function handleExports(\n source: string,\n program: Program,\n isServerFunction: boolean | RegExpMatchArray | null,\n isClientComponent: boolean | RegExpMatchArray | null\n): {\n imports: string[];\n declarations: string[];\n exportNames: string[];\n exports: Map<\n string,\n {\n type: \"function\" | \"class\" | \"variable\" | \"default\" | \"all\";\n declaration?: string;\n localName?: string;\n before?: string[];\n after?: string[];\n isAsync?: boolean;\n }\n >;\n} {\n const imports: string[] = [];\n const declarations: string[] = [];\n const exportNames: string[] = [];\n // Track exports and their types\n const exports = new Map<\n string,\n {\n type: \"function\" | \"class\" | \"variable\" | \"default\" | \"all\";\n declaration?: string;\n localName?: string;\n before?: string[];\n after?: string[];\n isAsync?: boolean;\n }\n >();\n\n let lastEnd = 0;\n let currentBefore: string[] = [];\n let foundFirstExport = false;\n\n // First pass: collect all exports and code between them\n for (const node of program.body) {\n // Add any code before this node\n if (node.start > lastEnd) {\n const beforeCode = source.slice(lastEnd, node.start);\n if (beforeCode.trim()) {\n currentBefore.push(beforeCode);\n }\n }\n\n if (node.type === \"ImportDeclaration\") {\n imports.push(source.slice(node.start, node.end));\n } else if (node.type === \"ExportAllDeclaration\") {\n // For export * from './other', just add the * export\n exports.set(\"*\", {\n type: \"all\",\n before: [...currentBefore],\n });\n currentBefore = [];\n exportNames.push(\"*\");\n } else if (node.type === \"ExportNamedDeclaration\") {\n if (!foundFirstExport) {\n // This is the first export, so all code before it goes into its before array\n foundFirstExport = true;\n }\n\n if (node.declaration) {\n if (\n node.declaration.type === \"FunctionDeclaration\" &&\n node.declaration.id\n ) {\n const name = node.declaration.id.name;\n exports.set(name, {\n type: \"function\",\n declaration: source.slice(node.declaration.start, node.declaration.end),\n before: [...currentBefore], // Copy the current before array\n isAsync: node.declaration.async,\n });\n exportNames.push(name);\n currentBefore = []; // Reset for next export\n } else if (\n node.declaration.type === \"ClassDeclaration\" &&\n node.declaration.id\n ) {\n const name = node.declaration.id.name;\n exports.set(name, {\n type: \"class\",\n declaration: source.slice(node.declaration.start, node.declaration.end),\n before: [...currentBefore], // Copy the current before array\n });\n exportNames.push(name);\n currentBefore = []; // Reset for next export\n } else if (node.declaration.type === \"VariableDeclaration\") {\n for (const decl of node.declaration.declarations) {\n if (decl.id && decl.id.type === \"Identifier\") {\n const name = decl.id.name;\n // Check if the declaration is a function expression or arrow function\n const init = decl.init;\n const isFunction = init && (\n init.type === \"FunctionExpression\" ||\n init.type === \"ArrowFunctionExpression\"\n );\n // For function expressions and arrow functions, we want to mark them as async\n // if they are explicitly marked as async\n const isAsync = isFunction && (\n (init.type === \"FunctionExpression\" && init.async === true) ||\n (init.type === \"ArrowFunctionExpression\" && init.async === true)\n );\n exports.set(name, {\n type: isFunction ? \"function\" : \"variable\",\n declaration: source.slice(decl.start, decl.end),\n before: [...currentBefore], // Copy the current before array\n isAsync: isAsync || false\n });\n exportNames.push(name);\n currentBefore = []; // Reset for next export\n }\n }\n }\n } else if (node.specifiers) {\n // For named exports (export { a, b, c })\n for (const spec of node.specifiers) {\n if (spec.type === \"ExportSpecifier\") {\n const localName = spec.local.type === \"Identifier\" ? spec.local.name : \"\";\n const exportedName = spec.exported.type === \"Identifier\" ? spec.exported.name : \"\";\n if (localName && exportedName) {\n // Find the function declaration in the AST\n const functionDecl = program.body.find(\n (node): node is FunctionDeclaration =>\n node.type === \"FunctionDeclaration\" &&\n node.id?.name === localName\n );\n\n if (functionDecl) {\n exports.set(exportedName, {\n type: \"function\",\n localName,\n declaration: source.slice(functionDecl.start, functionDecl.end),\n before: [...currentBefore],\n isAsync: functionDecl.async\n });\n exportNames.push(exportedName);\n } else {\n // If we can't find a function declaration, check if it's a variable declaration\n const varDecl = program.body.find(\n (node): node is VariableDeclaration =>\n node.type === \"VariableDeclaration\" &&\n node.declarations.some(\n (decl) =>\n decl.id.type === \"Identifier\" &&\n decl.id.name === localName &&\n decl.init &&\n (decl.init.type === \"FunctionExpression\" ||\n decl.init.type === \"ArrowFunctionExpression\")\n )\n );\n\n if (varDecl) {\n const decl = varDecl.declarations.find(\n (d: VariableDeclarator) => d.id.type === \"Identifier\" && d.id.name === localName\n );\n if (decl && decl.init) {\n const isAsync = decl.init.type === \"FunctionExpression\" ? decl.init.async :\n decl.init.type === \"ArrowFunctionExpression\" ? decl.init.async : false;\n exports.set(exportedName, {\n type: \"function\",\n localName,\n declaration: source.slice(decl.start, decl.end),\n before: [...currentBefore],\n isAsync\n });\n exportNames.push(exportedName);\n }\n } else {\n exports.set(exportedName, {\n type: \"variable\",\n localName,\n before: [...currentBefore],\n });\n exportNames.push(exportedName);\n }\n }\n }\n }\n }\n currentBefore = []; // Reset for next export\n }\n } else if (node.type === \"ExportDefaultDeclaration\") {\n if (node.declaration && node.declaration.type === \"FunctionDeclaration\" && node.declaration.id) {\n exports.set(\"default\", {\n type: \"default\",\n before: [...currentBefore],\n localName: node.declaration.id.name, // Capture the function name\n isAsync: node.declaration.async\n });\n } else {\n exports.set(\"default\", {\n type: \"default\",\n before: [...currentBefore]\n });\n }\n currentBefore = []; // Reset for next export\n } else if (\n node.type === \"FunctionDeclaration\" ||\n node.type === \"VariableDeclaration\" ||\n node.type === \"ClassDeclaration\"\n ) {\n // For non-exported declarations:\n // - Keep all declarations for server functions\n // - Remove function declarations for client components\n if (\n isServerFunction ||\n !isClientComponent ||\n node.type !== \"FunctionDeclaration\"\n ) {\n declarations.push(source.slice(node.start, node.end));\n }\n }\n\n lastEnd = node.end;\n }\n\n // Add any remaining code after the last node\n if (lastEnd < source.length) {\n const afterCode = source.slice(lastEnd);\n if (afterCode.trim()) {\n // Add to the last export's after array\n const lastExport = Array.from(exports.values()).pop();\n if (lastExport) {\n lastExport.after = [afterCode];\n }\n }\n }\n\n // Second pass: generate transformed exports\n // Process all exports regardless of environment - the actual transformation\n // happens in transformModuleWithPreservedFunctions\n for (const [name, info] of exports) {\n if (info.before) {\n declarations.push(...info.before);\n }\n if (info.declaration) {\n declarations.push(info.declaration);\n }\n if (info.after) {\n declarations.push(...info.after);\n }\n if (!exportNames.includes(name)) {\n exportNames.push(name);\n }\n }\n\n return { imports, declarations, exportNames, exports };\n}\n"],"names":["node"],"mappings":";;;;;AAqBO,SAAS,aACd,CAAA,MAAA,EACA,OACA,EAAA,gBAAA,EACA,iBAgBA,EAAA;AACA,EAAA,MAAM,UAAoB,EAAC;AAC3B,EAAA,MAAM,eAAyB,EAAC;AAChC,EAAA,MAAM,cAAwB,EAAC;AAE/B,EAAM,MAAA,OAAA,uBAAc,GAUlB,EAAA;AAEF,EAAA,IAAI,OAAU,GAAA,CAAA;AACd,EAAA,IAAI,gBAA0B,EAAC;AAI/B,EAAW,KAAA,MAAA,IAAA,IAAQ,QAAQ,IAAM,EAAA;AAE/B,IAAI,IAAA,IAAA,CAAK,QAAQ,OAAS,EAAA;AACxB,MAAA,MAAM,UAAa,GAAA,MAAA,CAAO,KAAM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MAAM,aAAa,KAAM,CAAA,IAAA,CAAK,QAAQ,MAAO,EAAC,EAAE,GAAI,EAAA;AACpD,MAAA,IAAI,UAAY,EAAA;AACd,QAAW,UAAA,CAAA,KAAA,GAAQ,CAAC,SAAS,CAAA;AAAA;AAC/B;AACF;AAMF,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,IAAI,CAAA,IAAK,OAAS,EAAA;AAClC,IAAA,IAAI,KAAK,MAAQ,EAAA;AACf,MAAa,YAAA,CAAA,IAAA,CAAK,GAAG,IAAA,CAAK,MAAM,CAAA;AAAA;AAElC,IAAA,IAAI,KAAK,WAAa,EAAA;AACpB,MAAa,YAAA,CAAA,IAAA,CAAK,KAAK,WAAW,CAAA;AAAA;AAEpC,IAAA,IAAI,KAAK,KAAO,EAAA;AACd,MAAa,YAAA,CAAA,IAAA,CAAK,GAAG,IAAA,CAAK,KAAK,CAAA;AAAA;AAEjC,IAAA,IAAI,CAAC,WAAA,CAAY,QAAS,CAAA,IAAI,CAAG,EAAA;AAC/B,MAAA,WAAA,CAAY,KAAK,IAAI,CAAA;AAAA;AACvB;AAGF,EAAA,OAAO,EAAE,OAAA,EAAS,YAAc,EAAA,WAAA,EAAa,OAAQ,EAAA;AACvD;;;;"}
1
+ {"version":3,"file":"handleExports.js","sources":["../../../plugin/loader/handleExports.ts"],"sourcesContent":["import type { Program } from \"./types.js\";\nimport type { FunctionDeclaration, VariableDeclaration, VariableDeclarator } from \"acorn\";\n\n/**\n * Collects and organizes export information from a module.\n *\n * For all modules:\n * - Collects import statements\n * - Collects export names\n * - Collects declarations\n *\n * The actual transformation of exports (like wrapping with registerServerReference)\n * happens in transformModuleWithPreservedFunctions.\n *\n * @param source - The source code of the module\n * @param url - The URL of the module\n * @param program - The parsed AST program\n * @param isServerFunction - Whether this is a server module\n * @param isClientComponent - Whether this is a client module\n * @returns Object containing imports, declarations, and export names\n */\nexport function handleExports(\n source: string,\n program: Program,\n isServerFunction: boolean | RegExpMatchArray | null,\n isClientComponent: boolean | RegExpMatchArray | null\n): {\n imports: string[];\n declarations: string[];\n exportNames: string[];\n exports: Map<\n string,\n {\n type: \"function\" | \"class\" | \"variable\" | \"default\" | \"all\";\n declaration?: string;\n localName?: string;\n before?: string[];\n after?: string[];\n isAsync?: boolean;\n isServerAction?: boolean;\n }\n >;\n} {\n const imports: string[] = [];\n const declarations: string[] = [];\n const exportNames: string[] = [];\n // Track exports and their types\n const exports = new Map<\n string,\n {\n type: \"function\" | \"class\" | \"variable\" | \"default\" | \"all\";\n declaration?: string;\n localName?: string;\n before?: string[];\n after?: string[];\n isAsync?: boolean;\n isServerAction?: boolean;\n }\n >();\n\n let lastEnd = 0;\n let currentBefore: string[] = [];\n let foundFirstExport = false;\n\n // First pass: collect all exports and code between them\n for (const node of program.body) {\n // Add any code before this node\n if (node.start > lastEnd) {\n const beforeCode = source.slice(lastEnd, node.start);\n if (beforeCode.trim()) {\n currentBefore.push(beforeCode);\n }\n }\n\n if (node.type === \"ImportDeclaration\") {\n const importSource = node.source.value as string;\n const isServerImport = importSource.includes(\".server.\");\n imports.push(source.slice(node.start, node.end));\n\n // If this is a server import, mark all imported functions as server actions\n if (isServerImport) {\n for (const spec of node.specifiers) {\n if (spec.type === \"ImportSpecifier\") {\n const localName = spec.local.type === \"Identifier\" ? spec.local.name : \"\";\n const importedName = spec.imported.type === \"Identifier\" ? spec.imported.name : \"\";\n if (localName && importedName) {\n exports.set(localName, {\n type: \"function\",\n localName,\n isServerAction: true,\n before: [...currentBefore],\n });\n exportNames.push(localName);\n }\n }\n }\n }\n } else if (node.type === \"ExportAllDeclaration\") {\n // For export * from './other', just add the * export\n exports.set(\"*\", {\n type: \"all\",\n before: [...currentBefore],\n });\n currentBefore = [];\n exportNames.push(\"*\");\n } else if (node.type === \"ExportNamedDeclaration\") {\n if (!foundFirstExport) {\n // This is the first export, so all code before it goes into its before array\n foundFirstExport = true;\n }\n\n if (node.declaration) {\n if (\n node.declaration.type === \"FunctionDeclaration\" &&\n node.declaration.id\n ) {\n const name = node.declaration.id.name;\n exports.set(name, {\n type: \"function\",\n declaration: source.slice(node.declaration.start, node.declaration.end),\n before: [...currentBefore],\n isAsync: node.declaration.async,\n isServerAction: isServerFunction === true,\n });\n exportNames.push(name);\n currentBefore = [];\n } else if (\n node.declaration.type === \"ClassDeclaration\" &&\n node.declaration.id\n ) {\n const name = node.declaration.id.name;\n exports.set(name, {\n type: \"class\",\n declaration: source.slice(node.declaration.start, node.declaration.end),\n before: [...currentBefore],\n });\n exportNames.push(name);\n currentBefore = [];\n } else if (node.declaration.type === \"VariableDeclaration\") {\n for (const decl of node.declaration.declarations) {\n if (decl.id && decl.id.type === \"Identifier\") {\n const name = decl.id.name;\n const init = decl.init;\n const isFunction = init && (\n init.type === \"FunctionExpression\" ||\n init.type === \"ArrowFunctionExpression\"\n );\n const isAsync = isFunction && (\n (init.type === \"FunctionExpression\" && init.async === true) ||\n (init.type === \"ArrowFunctionExpression\" && init.async === true)\n );\n exports.set(name, {\n type: isFunction ? \"function\" : \"variable\",\n declaration: source.slice(decl.start, decl.end),\n before: [...currentBefore],\n isAsync: isAsync || false,\n isServerAction: isFunction != null && isServerFunction === true,\n });\n exportNames.push(name);\n currentBefore = [];\n }\n }\n }\n } else if (node.specifiers) {\n // For named exports (export { a, b, c })\n for (const spec of node.specifiers) {\n if (spec.type === \"ExportSpecifier\") {\n const localName = spec.local.type === \"Identifier\" ? spec.local.name : \"\";\n const exportedName = spec.exported.type === \"Identifier\" ? spec.exported.name : \"\";\n if (localName && exportedName) {\n // Find the function declaration in the AST\n const functionDecl = program.body.find(\n (node): node is FunctionDeclaration =>\n node.type === \"FunctionDeclaration\" &&\n node.id?.name === localName\n );\n\n if (functionDecl) {\n exports.set(exportedName, {\n type: \"function\",\n localName,\n declaration: source.slice(functionDecl.start, functionDecl.end),\n before: [...currentBefore],\n isAsync: functionDecl.async,\n isServerAction: isServerFunction === true,\n });\n exportNames.push(exportedName);\n } else {\n // If we can't find a function declaration, check if it's a variable declaration\n const varDecl = program.body.find(\n (node): node is VariableDeclaration =>\n node.type === \"VariableDeclaration\" &&\n node.declarations.some(\n (decl) =>\n decl.id.type === \"Identifier\" &&\n decl.id.name === localName &&\n decl.init &&\n (decl.init.type === \"FunctionExpression\" ||\n decl.init.type === \"ArrowFunctionExpression\")\n )\n );\n\n if (varDecl) {\n const decl = varDecl.declarations.find(\n (d: VariableDeclarator) => d.id.type === \"Identifier\" && d.id.name === localName\n );\n if (decl && decl.init) {\n const isAsync = decl.init.type === \"FunctionExpression\" ? decl.init.async :\n decl.init.type === \"ArrowFunctionExpression\" ? decl.init.async : false;\n exports.set(exportedName, {\n type: \"function\",\n localName,\n declaration: source.slice(decl.start, decl.end),\n before: [...currentBefore],\n isAsync,\n isServerAction: isServerFunction === true,\n });\n exportNames.push(exportedName);\n }\n } else {\n exports.set(exportedName, {\n type: \"variable\",\n localName,\n before: [...currentBefore],\n });\n exportNames.push(exportedName);\n }\n }\n }\n }\n }\n }\n } else if (node.type === \"ExportDefaultDeclaration\") {\n if (node.declaration && node.declaration.type === \"FunctionDeclaration\" && node.declaration.id) {\n exports.set(\"default\", {\n type: \"default\",\n before: [...currentBefore],\n localName: node.declaration.id.name, // Capture the function name\n isAsync: node.declaration.async\n });\n } else {\n exports.set(\"default\", {\n type: \"default\",\n before: [...currentBefore]\n });\n }\n currentBefore = []; // Reset for next export\n } else if (\n node.type === \"FunctionDeclaration\" ||\n node.type === \"VariableDeclaration\" ||\n node.type === \"ClassDeclaration\"\n ) {\n // For non-exported declarations:\n // - Keep all declarations for server functions\n // - Remove function declarations for client components\n if (\n isServerFunction ||\n !isClientComponent ||\n node.type !== \"FunctionDeclaration\"\n ) {\n declarations.push(source.slice(node.start, node.end));\n }\n }\n\n lastEnd = node.end;\n }\n\n // Add any remaining code after the last node\n if (lastEnd < source.length) {\n const afterCode = source.slice(lastEnd);\n if (afterCode.trim()) {\n // Add to the last export's after array\n const lastExport = Array.from(exports.values()).pop();\n if (lastExport) {\n lastExport.after = [afterCode];\n }\n }\n }\n\n // Second pass: generate transformed exports\n // Process all exports regardless of environment - the actual transformation\n // happens in transformModuleWithPreservedFunctions\n for (const [name, info] of exports) {\n if (info.before) {\n declarations.push(...info.before);\n }\n if (info.declaration) {\n declarations.push(info.declaration);\n }\n if (info.after) {\n declarations.push(...info.after);\n }\n if (!exportNames.includes(name)) {\n exportNames.push(name);\n }\n }\n\n return { imports, declarations, exportNames, exports };\n}\n"],"names":["node"],"mappings":";;;;;AAqBO,SAAS,aACd,CAAA,MAAA,EACA,OACA,EAAA,gBAAA,EACA,iBAiBA,EAAA;AACA,EAAA,MAAM,UAAoB,EAAC;AAC3B,EAAA,MAAM,eAAyB,EAAC;AAChC,EAAA,MAAM,cAAwB,EAAC;AAE/B,EAAM,MAAA,OAAA,uBAAc,GAWlB,EAAA;AAEF,EAAA,IAAI,OAAU,GAAA,CAAA;AACd,EAAA,IAAI,gBAA0B,EAAC;AAI/B,EAAW,KAAA,MAAA,IAAA,IAAQ,QAAQ,IAAM,EAAA;AAE/B,IAAI,IAAA,IAAA,CAAK,QAAQ,OAAS,EAAA;AACxB,MAAA,MAAM,UAAa,GAAA,MAAA,CAAO,KAAM,CAAA,OAAA,EAAS,KAAK,KAAK,CAAA;AACnD,MAAI,IAAA,UAAA,CAAW,MAAQ,EAAA;AACrB,QAAA,aAAA,CAAc,KAAK,UAAU,CAAA;AAAA;AAC/B;AAGF,IAAI,IAAA,IAAA,CAAK,SAAS,mBAAqB,EAAA;AACrC,MAAM,MAAA,YAAA,GAAe,KAAK,MAAO,CAAA,KAAA;AACjC,MAAM,MAAA,cAAA,GAAiB,YAAa,CAAA,QAAA,CAAS,UAAU,CAAA;AACvD,MAAA,OAAA,CAAQ,KAAK,MAAO,CAAA,KAAA,CAAM,KAAK,KAAO,EAAA,IAAA,CAAK,GAAG,CAAC,CAAA;AAG/C,MAAA,IAAI,cAAgB,EAAA;AAClB,QAAW,KAAA,MAAA,IAAA,IAAQ,KAAK,UAAY,EAAA;AA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UserOptions } from "../types.js";
2
2
  import type { ModuleInfo } from "rollup";
3
3
  import type { MessagePort } from "node:worker_threads";
4
4
  export interface LoaderOptions {
@@ -14,7 +14,7 @@ export type LoaderFunction = (options: LoaderOptions) => Promise<ModuleInfo>;
14
14
  export declare function initialize(data: {
15
15
  id: string;
16
16
  port: MessagePort;
17
- userOptions: any;
17
+ userOptions: SerializedUserOptions;
18
18
  }): Promise<void>;
19
19
  export declare function load(url: string, context: LoaderContext, nextLoad: any): Promise<any>;
20
20
  export declare function resolve(specifier: string, context: any, nextResolve: any): Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"react-loader.server.d.ts","sourceRoot":"","sources":["../../../plugin/loader/react-loader.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAuB,MAAM,aAAa,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOvD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAI7E,wBAAsB,UAAU,CAAC,IAAI,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,GAAG,CAAA;CAAE,iBAQzF;AAED,wBAAsB,IAAI,CAAC,GA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