vite-plugin-react-server 1.1.13 → 1.1.14

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 (159) 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 +98 -61
  8. package/dist/plugin/config/resolveOptions.js.map +1 -1
  9. package/dist/plugin/error/toError.d.ts.map +1 -1
  10. package/dist/plugin/error/toError.js +0 -1
  11. package/dist/plugin/error/toError.js.map +1 -1
  12. package/dist/plugin/helpers/collectManifestCss.d.ts +1 -2
  13. package/dist/plugin/helpers/collectManifestCss.d.ts.map +1 -1
  14. package/dist/plugin/helpers/collectManifestCss.js +3 -5
  15. package/dist/plugin/helpers/collectManifestCss.js.map +1 -1
  16. package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +1 -1
  17. package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -1
  18. package/dist/plugin/helpers/collectViteModuleGraphCss.js +6 -2
  19. package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -1
  20. package/dist/plugin/helpers/createCssProps.d.ts +1 -1
  21. package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
  22. package/dist/plugin/helpers/createCssProps.js +11 -32
  23. package/dist/plugin/helpers/createCssProps.js.map +1 -1
  24. package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
  25. package/dist/plugin/helpers/createRscStream.js +1 -0
  26. package/dist/plugin/helpers/createRscStream.js.map +1 -1
  27. package/dist/plugin/loader/createDefaultLoader.d.ts.map +1 -1
  28. package/dist/plugin/loader/createDefaultLoader.js +68 -4
  29. package/dist/plugin/loader/css-loader.development.d.ts +2 -15
  30. package/dist/plugin/loader/css-loader.development.d.ts.map +1 -1
  31. package/dist/plugin/loader/css-loader.development.js +16 -15
  32. package/dist/plugin/loader/css-loader.development.js.map +1 -1
  33. package/dist/plugin/loader/css-loader.production.d.ts +1 -1
  34. package/dist/plugin/loader/css-loader.production.d.ts.map +1 -1
  35. package/dist/plugin/loader/css-loader.production.js +1 -1
  36. package/dist/plugin/loader/css-loader.production.js.map +1 -1
  37. package/dist/plugin/loader/env-loader.development.d.ts +1 -0
  38. package/dist/plugin/loader/env-loader.development.d.ts.map +1 -1
  39. package/dist/plugin/loader/env-loader.development.js +17 -9
  40. package/dist/plugin/loader/handleExports.d.ts +1 -0
  41. package/dist/plugin/loader/handleExports.d.ts.map +1 -1
  42. package/dist/plugin/loader/handleExports.js +27 -8
  43. package/dist/plugin/loader/handleExports.js.map +1 -1
  44. package/dist/plugin/loader/react-loader.server.d.ts +2 -2
  45. package/dist/plugin/loader/react-loader.server.d.ts.map +1 -1
  46. package/dist/plugin/loader/react-loader.server.js +88 -26
  47. package/dist/plugin/loader/transformModuleIfNeeded.d.ts.map +1 -1
  48. package/dist/plugin/loader/transformModuleIfNeeded.js +1 -1
  49. package/dist/plugin/loader/transformModuleIfNeeded.js.map +1 -1
  50. package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts.map +1 -1
  51. package/dist/plugin/loader/transformModuleWithPreservedFunctions.js +86 -13
  52. package/dist/plugin/loader/transformModuleWithPreservedFunctions.js.map +1 -1
  53. package/dist/plugin/plugin.client.d.ts.map +1 -1
  54. package/dist/plugin/plugin.client.js +0 -1
  55. package/dist/plugin/plugin.client.js.map +1 -1
  56. package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts.map +1 -1
  57. package/dist/plugin/react-client/configureWorkerRequestHandler.js +85 -6
  58. package/dist/plugin/react-client/configureWorkerRequestHandler.js.map +1 -1
  59. package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -1
  60. package/dist/plugin/react-client/createMessageHandlers.js +3 -0
  61. package/dist/plugin/react-client/createMessageHandlers.js.map +1 -1
  62. package/dist/plugin/react-client/createWorkerStream.d.ts +2 -2
  63. package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
  64. package/dist/plugin/react-client/createWorkerStream.js +13 -2
  65. package/dist/plugin/react-client/createWorkerStream.js.map +1 -1
  66. package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -1
  67. package/dist/plugin/react-client/handleWorkerRscStream.js +10 -3
  68. package/dist/plugin/react-client/handleWorkerRscStream.js.map +1 -1
  69. package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
  70. package/dist/plugin/react-client/restartWorker.js +2 -1
  71. package/dist/plugin/react-client/restartWorker.js.map +1 -1
  72. package/dist/plugin/react-server/configureReactServer.d.ts.map +1 -1
  73. package/dist/plugin/react-server/configureReactServer.js +1 -2
  74. package/dist/plugin/react-server/configureReactServer.js.map +1 -1
  75. package/dist/plugin/react-server/handleServerAction.d.ts.map +1 -1
  76. package/dist/plugin/react-server/handleServerAction.js +0 -16
  77. package/dist/plugin/react-server/handleServerAction.js.map +1 -1
  78. package/dist/plugin/react-static/createBuildLoader.d.ts.map +1 -0
  79. package/dist/plugin/react-static/createBuildLoader.js.map +1 -0
  80. package/dist/plugin/react-static/plugin.d.ts.map +1 -1
  81. package/dist/plugin/react-static/plugin.js +9 -12
  82. package/dist/plugin/react-static/plugin.js.map +1 -1
  83. package/dist/plugin/react-static/temporaryReferences.d.ts.map +1 -0
  84. package/dist/plugin/react-static/temporaryReferences.js.map +1 -0
  85. package/dist/plugin/transformer/plugin.server.js +2 -2
  86. package/dist/plugin/transformer/plugin.server.js.map +1 -1
  87. package/dist/plugin/types.d.ts +14 -3
  88. package/dist/plugin/types.d.ts.map +1 -1
  89. package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
  90. package/dist/plugin/worker/rsc/handleRender.js +1 -0
  91. package/dist/plugin/worker/rsc/handleRender.js.map +1 -1
  92. package/dist/plugin/worker/rsc/handlers.d.ts +3 -0
  93. package/dist/plugin/worker/rsc/handlers.d.ts.map +1 -0
  94. package/dist/plugin/worker/rsc/handlers.js +223 -0
  95. package/dist/plugin/worker/rsc/handlers.js.map +1 -0
  96. package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
  97. package/dist/plugin/worker/rsc/messageHandler.js +5 -110
  98. package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
  99. package/dist/plugin/worker/rsc/rsc-worker.development.js +13 -16
  100. package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
  101. package/dist/plugin/worker/rsc/state.d.ts +1 -2
  102. package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
  103. package/dist/plugin/worker/rsc/state.js +1 -2
  104. package/dist/plugin/worker/rsc/state.js.map +1 -1
  105. package/dist/plugin/worker/rsc/userOptions.d.ts +2 -0
  106. package/dist/plugin/worker/rsc/userOptions.d.ts.map +1 -0
  107. package/dist/plugin/worker/rsc/userOptions.js +17 -0
  108. package/dist/plugin/worker/rsc/userOptions.js.map +1 -0
  109. package/dist/plugin/worker/types.d.ts +2 -1
  110. package/dist/plugin/worker/types.d.ts.map +1 -1
  111. package/dist/tsconfig.tsbuildinfo +1 -1
  112. package/package.json +5 -1
  113. package/plugin/config/defaults.tsx +5 -2
  114. package/plugin/config/resolveOptions.ts +101 -67
  115. package/plugin/error/toError.ts +0 -2
  116. package/plugin/helpers/collectManifestCss.ts +2 -6
  117. package/plugin/helpers/collectViteModuleGraphCss.ts +6 -0
  118. package/plugin/helpers/createCssProps.tsx +17 -46
  119. package/plugin/helpers/createRscStream.tsx +1 -0
  120. package/plugin/loader/createDefaultLoader.ts +80 -4
  121. package/plugin/loader/css-loader.development.ts +17 -34
  122. package/plugin/loader/css-loader.production.ts +2 -4
  123. package/plugin/loader/env-loader.development.ts +38 -15
  124. package/plugin/loader/handleExports.ts +36 -13
  125. package/plugin/loader/react-loader.server.ts +110 -32
  126. package/plugin/loader/transformModuleIfNeeded.ts +2 -2
  127. package/plugin/loader/transformModuleWithPreservedFunctions.ts +128 -21
  128. package/plugin/plugin.client.ts +0 -2
  129. package/plugin/react-client/configureWorkerRequestHandler.ts +107 -4
  130. package/plugin/react-client/createMessageHandlers.ts +3 -0
  131. package/plugin/react-client/createWorkerStream.ts +15 -1
  132. package/plugin/react-client/handleWorkerRscStream.ts +12 -3
  133. package/plugin/react-client/restartWorker.ts +1 -0
  134. package/plugin/react-server/configureReactServer.ts +1 -2
  135. package/plugin/react-server/handleServerAction.ts +1 -19
  136. package/plugin/react-static/plugin.ts +9 -12
  137. package/plugin/transformer/plugin.server.ts +2 -2
  138. package/plugin/types.ts +25 -2
  139. package/plugin/worker/rsc/handleRender.ts +1 -0
  140. package/plugin/worker/rsc/handlers.ts +243 -0
  141. package/plugin/worker/rsc/messageHandler.tsx +4 -118
  142. package/plugin/worker/rsc/rsc-worker.development.ts +17 -20
  143. package/plugin/worker/rsc/state.ts +2 -6
  144. package/plugin/worker/rsc/userOptions.ts +8 -0
  145. package/plugin/worker/types.ts +2 -0
  146. package/dist/plugin/loader/createBuildLoader.d.ts.map +0 -1
  147. package/dist/plugin/loader/createBuildLoader.js.map +0 -1
  148. package/dist/plugin/loader/plugin.d.ts +0 -22
  149. package/dist/plugin/loader/plugin.d.ts.map +0 -1
  150. package/dist/plugin/loader/plugin.js +0 -27
  151. package/dist/plugin/loader/temporaryReferences.d.ts.map +0 -1
  152. package/dist/plugin/loader/temporaryReferences.js.map +0 -1
  153. package/plugin/loader/plugin.ts +0 -33
  154. /package/dist/plugin/{loader → react-static}/createBuildLoader.d.ts +0 -0
  155. /package/dist/plugin/{loader → react-static}/createBuildLoader.js +0 -0
  156. /package/dist/plugin/{loader → react-static}/temporaryReferences.d.ts +0 -0
  157. /package/dist/plugin/{loader → react-static}/temporaryReferences.js +0 -0
  158. /package/plugin/{loader → react-static}/createBuildLoader.ts +0 -0
  159. /package/plugin/{loader → react-static}/temporaryReferences.ts +0 -0
@@ -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,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,IAA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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;AAClC,UAAI,IAAA,IAAA,CAAK,SAAS,iBAAmB,EAAA;AACnC,YAAA,MAAM,YAAY,IAAK,CAAA,KAAA,CAAM,SAAS,YAAe,GAAA,IAAA,CAAK,MAAM,IAAO,GAAA,EAAA;AACvE,Y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AA;AAAA;AACtD;AAGF,IAAA,OAAA,GAAU,IAAK,CAAA,GAAA;AAAA;AAIjB,EAAI,IAAA,OAAA,GAAU,OAAO,MAAQ,EAAA;AAC3B,IAAM,MAAA,SAAA,GAAY,MAAO,CAAA,KAAA,CAAM,OAAO,CAAA;AACtC,IAAI,IAAA,SAAA,CAAU,MAAQ,EAAA;AAEpB,MAAA,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,4 +1,4 @@
1
- import type { LoaderContext } from "../types.js";
1
+ import type { LoaderContext, SerializedUserOptions } 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,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,gBAgE5E;AAED,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,GAAG,EACZ,WAAW,EAAE,GAAG,gBAGjB"}
1
+ {"version":3,"file":"react-loader.server.d.ts","sourceRoot":"","sources":["../../../plugin/loader/react-loader.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,qBAAqB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAUvD,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;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,EAAE,qBAAqB,CAAC;CACpC,iBAgBA;AAED,wBAAsB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,gBAmH5E;AAED,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,GAAG,EACZ,WAAW,EAAE,GAAG,gBAWjB"}
@@ -1,28 +1,73 @@
1
1
  import { transformModuleIfNeeded } from "./transformModuleIfNeeded.js";
2
- import { hydrateUserOptions } from "../helpers/index.js";
3
- import { resolveOptions } from "../config/index.js";
4
2
  import { fileURLToPath } from "node:url";
5
3
  import { join } from "node:path";
4
+ import { resolveOptions } from "../config/resolveOptions.js";
5
+ import { hydrateUserOptions } from "../helpers/index.js";
6
6
  let userOptions;
7
7
  let loaderPort;
8
8
  export async function initialize(data) {
9
- const userOptionsResult = resolveOptions(hydrateUserOptions(data.userOptions));
10
- loaderPort = data.port;
11
- loaderPort.postMessage({ type: "INITIALIZED_REACT_LOADER", id: data.id });
12
- if (userOptionsResult.type === "error") {
13
- throw userOptionsResult.error;
9
+ if (userOptions?.verbose) {
10
+ console.log("[react-loader] Initializing with options:", data.id);
11
+ }
12
+ const resolvedUserOptions = resolveOptions(hydrateUserOptions(data.userOptions));
13
+ if (resolvedUserOptions.type === "error") {
14
+ throw new Error(resolvedUserOptions.error.message);
14
15
  }
15
- userOptions = userOptionsResult.userOptions;
16
+ userOptions = resolvedUserOptions.userOptions;
17
+ loaderPort = data.port;
18
+ loaderPort.postMessage({
19
+ type: "INITIALIZED_REACT_LOADER",
20
+ id: data.id,
21
+ });
16
22
  }
17
23
  export async function load(url, context, nextLoad) {
24
+ if (userOptions?.verbose) {
25
+ console.log("[react-loader] Attempting to load:", url);
26
+ console.log("[react-loader] Context:", {
27
+ format: context.format,
28
+ conditions: context.conditions,
29
+ });
30
+ }
18
31
  const { format } = context;
19
- if (format === "module") {
32
+ if (format === "module" || format === "module-typescript") {
33
+ if (userOptions?.verbose) {
34
+ console.log("[react-loader] Loading module:", url);
35
+ }
20
36
  const result = await nextLoad(url, context);
21
- const source = typeof result.source === 'string' ? result.source :
22
- result.source instanceof Uint8Array ? new TextDecoder().decode(result.source) :
23
- String(result.source);
37
+ if (userOptions?.verbose) {
38
+ console.log("[react-loader] Next load result:", {
39
+ format: result.format,
40
+ shortCircuit: result.shortCircuit,
41
+ source: typeof result.source,
42
+ });
43
+ }
44
+ const source = typeof result.source === "string"
45
+ ? result.source
46
+ : result.source instanceof Uint8Array
47
+ ? new TextDecoder().decode(result.source)
48
+ : String(result.source);
49
+ const isServer = userOptions?.autoDiscover?.isServerFunctionCode(source);
50
+ const isClient = userOptions?.autoDiscover?.isClientComponentCode(source);
51
+ if (userOptions?.verbose) {
52
+ console.log("[react-loader] Module analysis:", {
53
+ url,
54
+ isServer,
55
+ isClient,
56
+ sourceLength: source.length,
57
+ sourcePreview: source.slice(0, 100) + "...",
58
+ });
59
+ }
60
+ if (!isServer && !isClient) {
61
+ if (userOptions?.verbose) {
62
+ console.log("[react-loader] Skipping non-server/non-client module:", url);
63
+ }
64
+ return result;
65
+ }
24
66
  // Handle file URLs
25
67
  const filePath = url.startsWith("file://") ? fileURLToPath(url) : url;
68
+ if (userOptions?.verbose) {
69
+ console.log("[react-loader] File path:", filePath);
70
+ }
26
71
  // Normalize the URL using the same logic as plugin.server.ts
27
72
  let moduleID = filePath;
28
73
  let finalID = filePath;
@@ -30,18 +75,22 @@ export async function load(url, context, nextLoad) {
30
75
  const [, value] = userOptions.normalizer(filePath);
31
76
  moduleID = join(userOptions.moduleBasePath, value);
32
77
  finalID = userOptions.moduleID(moduleID);
78
+ if (userOptions?.verbose) {
79
+ console.log("[react-loader] Normalized IDs:", { moduleID, finalID });
80
+ }
33
81
  }
82
+ const transformed = transformModuleIfNeeded(source, finalID, isServer, isClient, true // isServerEnvironment
83
+ );
34
84
  if (userOptions?.verbose) {
35
- console.log("[react-loader] moduleID:", moduleID);
36
- console.log("[react-loader] finalID:", finalID);
37
- }
38
- const transformed = transformModuleIfNeeded(source, finalID, userOptions?.autoDiscover?.isServerFunction(source), userOptions?.autoDiscover?.isClientComponent(source), true);
39
- if (userOptions?.verbose) {
40
- console.log("[react-loader] Transformed source:", transformed);
85
+ console.log("[react-loader] Transformation result:", {
86
+ originalLength: source.length,
87
+ transformedLength: transformed.length,
88
+ wasTransformed: source !== transformed,
89
+ });
41
90
  }
42
91
  if (loaderPort) {
43
92
  if (userOptions?.verbose) {
44
- console.log("[react-loader] Sending SERVER_MODULE message:", { id: finalID, url: filePath });
93
+ console.log("[react-loader] Sending SERVER_MODULE message");
45
94
  }
46
95
  loaderPort.postMessage({
47
96
  type: "SERVER_MODULE",
@@ -51,19 +100,32 @@ export async function load(url, context, nextLoad) {
51
100
  });
52
101
  }
53
102
  // If we have a source map, update it to point to the transformed source
54
- const map = result.map ? {
55
- ...result.map,
56
- sourcesContent: [transformed],
57
- mappings: result.map.mappings
58
- } : null;
103
+ const map = result.map
104
+ ? {
105
+ ...result.map,
106
+ sourcesContent: [transformed],
107
+ mappings: result.map.mappings,
108
+ }
109
+ : null;
59
110
  return {
60
111
  ...result,
61
112
  source: transformed,
62
- map
113
+ map,
63
114
  };
64
115
  }
116
+ if (userOptions?.verbose) {
117
+ console.log("[react-loader] Skipping non-module format:", format);
118
+ }
65
119
  return nextLoad(url, context);
66
120
  }
67
121
  export async function resolve(specifier, context, nextResolve) {
68
- return nextResolve(specifier, context);
122
+ if (userOptions?.verbose) {
123
+ console.log("[react-loader] Resolving:", specifier);
124
+ console.log("[react-loader] Resolve context:", context);
125
+ }
126
+ const result = await nextResolve(specifier, context);
127
+ if (userOptions?.verbose) {
128
+ console.log("[react-loader] Resolve result:", result);
129
+ }
130
+ return result;
69
131
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transformModuleIfNeeded.d.ts","sourceRoot":"","sources":["../../../plugin/loader/transformModuleIfNeeded.ts"],"names":[],"mappings":"AAKA,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,gBAAgB,GAAE,OAAO,GAAG,gBAAgB,GAAG,IAA4D,EAC3G,iBAAiB,GAAE,OAAO,GAAG,gBAAgB,GAAG,IAA6D,EAC7G,mBAAmB,UAAoC,UAsBxD"}
1
+ {"version":3,"file":"transformModuleIfNeeded.d.ts","sourceRoot":"","sources":["../../../plugin/loader/transformModuleIfNeeded.ts"],"names":[],"mappings":"AAKA,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,gBAAgB,GAAE,OAAO,GAAG,gBAAgB,GAAG,IAA0E,EACzH,iBAAiB,GAAE,OAAO,GAAG,gBAAgB,GAAG,IAAiE,EACjH,mBAAmB,UAAoC,UAsBxD"}
@@ -8,7 +8,7 @@ import { transformModuleWithPreservedFunctions } from './transformModuleWithPres
8
8
  import { parse } from './parse.js';
9
9
  import { DEFAULT_CONFIG } from '../config/defaults.js';
10
10
 
11
- function transformModuleIfNeeded(source, moduleId, isServerFunction = DEFAULT_CONFIG.AUTO_DISCOVER.isServerFunction(source), isClientComponent = DEFAULT_CONFIG.AUTO_DISCOVER.isClientComponent(source), isServerEnvironment = getCondition() === "react-server") {
11
+ function transformModuleIfNeeded(source, moduleId, isServerFunction = DEFAULT_CONFIG.AUTO_DISCOVER.isServerFunctionCode(source, moduleId), isClientComponent = DEFAULT_CONFIG.AUTO_DISCOVER.isClientComponentCode(source), isServerEnvironment = getCondition() === "react-server") {
12
12
  const ast = parse(source);
13
13
  if (isServerEnvironment && !isServerFunction && !isClientComponent || !isServerEnvironment && isClientComponent) {
14
14
  return source;
@@ -1 +1 @@
1
- {"version":3,"file":"transformModuleIfNeeded.js","sources":["../../../plugin/loader/transformModuleIfNeeded.ts"],"sourcesContent":["import { getCondition } from \"../config/getCondition.js\";\nimport { transformModuleWithPreservedFunctions } from \"./transformModuleWithPreservedFunctions.js\";\nimport { parse } from \"./parse.js\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\n\nexport function transformModuleIfNeeded(\n source: string,\n moduleId: string,\n isServerFunction: boolean | RegExpMatchArray | null = DEFAULT_CONFIG.AUTO_DISCOVER.isServerFunction(source),\n isClientComponent: boolean | RegExpMatchArray | null = DEFAULT_CONFIG.AUTO_DISCOVER.isClientComponent(source),\n isServerEnvironment = getCondition() === \"react-server\"\n) {\n // Parse source and handle source maps\n const ast = parse(source); \n\n // Handle environment-specific cases\n if (\n (isServerEnvironment && !isServerFunction && !isClientComponent) ||\n (!isServerEnvironment && isClientComponent)\n ) {\n return source\n }\n\n const result = transformModuleWithPreservedFunctions(\n source,\n moduleId,\n ast,\n isServerFunction,\n isClientComponent\n );\n\n return result\n}\n"],"names":[],"mappings":";;;;;;;;;;AAKO,SAAS,wBACd,MACA,EAAA,QAAA,EACA,mBAAsD,cAAe,CAAA,aAAA,CAAc,iBAAiB,MAAM,CAAA,EAC1G,iBAAuD,GAAA,cAAA,CAAe,cAAc,iBAAkB,CAAA,MAAM,GAC5G,mBAAsB,GAAA,YAAA,OAAmB,cACzC,EAAA;AAEA,EAAM,MAAA,GAAA,GAAM,MAAM,MAAM,CAAA;AAGxB,EAAA,IACG,uBAAuB,CAAC,gBAAA,IAAoB,CAAC,iBAC7C,IAAA,CAAC,uBAAuB,iBACzB,EAAA;AACA,IAAO,OAAA,MAAA;AAAA;AAGT,EAAA,MAAM,MAAS,GAAA,qCAAA;AAAA,IACb,MAAA;AAAA,IACA,QAAA;AAAA,IACA,GAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAO,OAAA,MAAA;AACT;;;;"}
1
+ {"version":3,"file":"transformModuleIfNeeded.js","sources":["../../../plugin/loader/transformModuleIfNeeded.ts"],"sourcesContent":["import { getCondition } from \"../config/getCondition.js\";\nimport { transformModuleWithPreservedFunctions } from \"./transformModuleWithPreservedFunctions.js\";\nimport { parse } from \"./parse.js\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\n\nexport function transformModuleIfNeeded(\n source: string,\n moduleId: string,\n isServerFunction: boolean | RegExpMatchArray | null = DEFAULT_CONFIG.AUTO_DISCOVER.isServerFunctionCode(source, moduleId),\n isClientComponent: boolean | RegExpMatchArray | null = DEFAULT_CONFIG.AUTO_DISCOVER.isClientComponentCode(source),\n isServerEnvironment = getCondition() === \"react-server\"\n) {\n // Parse source and handle source maps\n const ast = parse(source); \n\n // Handle environment-specific cases\n if (\n (isServerEnvironment && !isServerFunction && !isClientComponent) ||\n (!isServerEnvironment && isClientComponent)\n ) {\n return source\n }\n\n const result = transformModuleWithPreservedFunctions(\n source,\n moduleId,\n ast,\n isServerFunction,\n isClientComponent\n );\n\n return result\n}\n"],"names":[],"mappings":";;;;;;;;;;AAKO,SAAS,wBACd,MACA,EAAA,QAAA,EACA,mBAAsD,cAAe,CAAA,aAAA,CAAc,qBAAqB,MAAQ,EAAA,QAAQ,GACxH,iBAAuD,GAAA,cAAA,CAAe,cAAc,qBAAsB,CAAA,MAAM,GAChH,mBAAsB,GAAA,YAAA,OAAmB,cACzC,EAAA;AAEA,EAAM,MAAA,GAAA,GAAM,MAAM,MAAM,CAAA;AAGxB,EAAA,IACG,uBAAuB,CAAC,gBAAA,IAAoB,CAAC,iBAC7C,IAAA,CAAC,uBAAuB,iBACzB,EAAA;AACA,IAAO,OAAA,MAAA;AAAA;AAGT,EAAA,MAAM,MAAS,GAAA,qCAAA;AAAA,IACb,MAAA;AAAA,IACA,QAAA;AAAA,IACA,GAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAO,OAAA,MAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"transformModuleWithPreservedFunctions.d.ts","sourceRoot":"","sources":["../../../plugin/loader/transformModuleWithPreservedFunctions.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AASD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,EACnD,iBAAiB,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,GACnD,MAAM,CA2DR"}
1
+ {"version":3,"file":"transformModuleWithPreservedFunctions.d.ts","sourceRoot":"","sources":["../../../plugin/loader/transformModuleWithPreservedFunctions.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AASD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,EACnD,iBAAiB,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,GACnD,MAAM,CAqKR"}
@@ -4,48 +4,121 @@
4
4
  * MIT License
5
5
  */
6
6
  import { handleExports } from './handleExports.js';
7
+ import createMappingsSerializer from 'webpack-sources/lib/helpers/createMappingsSerializer.js';
7
8
 
8
9
  function createClientReferenceError(name) {
9
10
  return `Attempted to call ${name}() from the server but ${name} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;
10
11
  }
11
12
  function transformModuleWithPreservedFunctions(source, moduleId, program, isServerFunction, isClientComponent) {
12
- const { exportNames, exports } = handleExports(source, program, isServerFunction, isClientComponent);
13
+ let sourceWithoutDirective = source;
14
+ let directiveEnd = 0;
15
+ for (const node of program.body) {
16
+ if (node.type !== "ExpressionStatement") {
17
+ break;
18
+ }
19
+ let directive = null;
20
+ if ("directive" in node && typeof node.directive === "string") {
21
+ directive = node.directive;
22
+ } else if (node.expression.type === "Literal" && typeof node.expression.value === "string" && (node.expression.value === "use server" || node.expression.value === "use client")) {
23
+ directive = node.expression.value;
24
+ }
25
+ if (directive && "start" in node && "end" in node) {
26
+ directiveEnd = node.end;
27
+ }
28
+ }
29
+ if (directiveEnd > 0) {
30
+ sourceWithoutDirective = source.slice(directiveEnd).trim();
31
+ }
32
+ const { exportNames, exports } = handleExports(
33
+ sourceWithoutDirective,
34
+ program,
35
+ isServerFunction,
36
+ isClientComponent
37
+ );
13
38
  const moduleIdLiteral = JSON.stringify(moduleId);
14
- if (isServerFunction) {
15
- const imports = ['import { registerServerReference } from "react-server-dom-esm/server.node";'];
39
+ if (Boolean(isServerFunction)) {
40
+ const imports = [
41
+ 'import { registerServerReference } from "react-server-dom-esm/server.node";'
42
+ ];
16
43
  const registrations = [];
17
44
  for (const name of exportNames) {
18
45
  const exportInfo = exports.get(name);
19
46
  if (exportInfo) {
20
47
  const exportName = name === "default" && exportInfo.localName ? exportInfo.localName : name;
21
48
  registrations.push(
22
- `registerServerReference(${exportName}, ${moduleIdLiteral}, ${JSON.stringify(name)});`
49
+ `registerServerReference(${exportName}, ${moduleIdLiteral}, ${JSON.stringify(
50
+ name
51
+ )});`
23
52
  );
24
53
  }
25
54
  }
26
- const newSource = [...imports, source].join("\n\n");
27
- const finalSource = newSource + "\n\n" + registrations.join("\n");
28
- return finalSource;
55
+ const newSource = [...imports, sourceWithoutDirective, ...registrations].join("\n\n");
56
+ let mappings = "";
57
+ const createMapping = createMappingsSerializer();
58
+ let generatedLine = 1;
59
+ createMapping(generatedLine, 0, 0, 0, 0, -1);
60
+ generatedLine++;
61
+ for (let i = 0; i < registrations.length; i++) {
62
+ createMapping(generatedLine, 0, 0, 1, 0, -1);
63
+ generatedLine++;
64
+ }
65
+ const sourceLines = source.split("\n");
66
+ for (let i = 0; i < sourceLines.length; i++) {
67
+ createMapping(generatedLine, 0, 0, i + 1, 0, -1);
68
+ generatedLine++;
69
+ }
70
+ const sourceMap = {
71
+ version: 3,
72
+ file: moduleId,
73
+ sources: [moduleId],
74
+ sourcesContent: [newSource],
75
+ // Use transformed source content
76
+ mappings,
77
+ sourceRoot: "",
78
+ names: []
79
+ };
80
+ return newSource + "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + Buffer.from(JSON.stringify(sourceMap)).toString("base64");
29
81
  }
30
- if (isClientComponent) {
31
- const imports = ['import { registerClientReference } from "react-server-dom-esm/server.node";'];
82
+ if (!!isClientComponent) {
83
+ const imports = [
84
+ 'import { registerClientReference } from "react-server-dom-esm/server.node";'
85
+ ];
32
86
  const declarations = [];
33
87
  for (const name of exportNames) {
34
88
  const errorMessage = createClientReferenceError(name);
35
89
  if (name === "default") {
36
90
  declarations.push(`export default registerClientReference(function() {
37
- throw new Error("${errorMessage}");
91
+ throw new Error("${errorMessage}");
38
92
  }, ${moduleIdLiteral}, "default");`);
39
93
  } else {
40
94
  declarations.push(`export const ${name} = registerClientReference(function() {
41
- throw new Error("${errorMessage}");
95
+ throw new Error("${errorMessage}");
42
96
  }, ${moduleIdLiteral}, ${JSON.stringify(name)});`);
43
97
  }
44
98
  }
45
99
  const newSource = [...imports, ...declarations].join("\n\n");
46
- return newSource;
100
+ let mappings = "";
101
+ const createMapping = createMappingsSerializer();
102
+ let generatedLine = 1;
103
+ createMapping(generatedLine, 0, 0, 0, 0, -1);
104
+ generatedLine++;
105
+ for (let i = 0; i < declarations.length; i++) {
106
+ createMapping(generatedLine, 0, 0, 1, 0, -1);
107
+ generatedLine++;
108
+ }
109
+ const sourceMap = {
110
+ version: 3,
111
+ file: moduleId,
112
+ sources: [moduleId],
113
+ sourcesContent: [newSource],
114
+ // Use transformed source content
115
+ mappings,
116
+ sourceRoot: "",
117
+ names: []
118
+ };
119
+ return newSource + "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + Buffer.from(JSON.stringify(sourceMap)).toString("base64");
47
120
  }
48
- return source;
121
+ throw new Error("Invalid module type");
49
122
  }
50
123
 
51
124
  export { transformModuleWithPreservedFunctions };