@octanejs/tanstack-start 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +52 -0
  3. package/THIRD_PARTY_NOTICES.md +11 -0
  4. package/package.json +149 -0
  5. package/src/client-only.d.ts +1 -0
  6. package/src/client-only.js +0 -0
  7. package/src/client-rpc.d.ts +1 -0
  8. package/src/client-rpc.js +1 -0
  9. package/src/client.d.ts +3 -0
  10. package/src/client.js +2 -0
  11. package/src/default-entry/client.js +12 -0
  12. package/src/default-entry/server.js +13 -0
  13. package/src/default-entry/start.js +1 -0
  14. package/src/default-entry-paths.d.ts +5 -0
  15. package/src/default-entry-paths.js +11 -0
  16. package/src/index.d.ts +11 -0
  17. package/src/index.js +22 -0
  18. package/src/internal/README.md +15 -0
  19. package/src/internal/router-generator/config.d.ts +255 -0
  20. package/src/internal/router-generator/config.js +134 -0
  21. package/src/internal/router-generator/filesystem/physical/getRouteNodes.d.ts +53 -0
  22. package/src/internal/router-generator/filesystem/physical/getRouteNodes.js +335 -0
  23. package/src/internal/router-generator/filesystem/physical/rootPathId.d.ts +1 -0
  24. package/src/internal/router-generator/filesystem/physical/rootPathId.js +4 -0
  25. package/src/internal/router-generator/filesystem/virtual/config.d.ts +3 -0
  26. package/src/internal/router-generator/filesystem/virtual/config.js +36 -0
  27. package/src/internal/router-generator/filesystem/virtual/getRouteNodes.d.ts +31 -0
  28. package/src/internal/router-generator/filesystem/virtual/getRouteNodes.js +272 -0
  29. package/src/internal/router-generator/filesystem/virtual/loadConfigFile.d.ts +1 -0
  30. package/src/internal/router-generator/filesystem/virtual/loadConfigFile.js +10 -0
  31. package/src/internal/router-generator/generator.d.ts +119 -0
  32. package/src/internal/router-generator/generator.js +1080 -0
  33. package/src/internal/router-generator/index.d.ts +40 -0
  34. package/src/internal/router-generator/index.js +49 -0
  35. package/src/internal/router-generator/logger.d.ts +8 -0
  36. package/src/internal/router-generator/logger.js +30 -0
  37. package/src/internal/router-generator/plugin/types.d.ts +37 -0
  38. package/src/internal/router-generator/template.d.ts +38 -0
  39. package/src/internal/router-generator/template.js +220 -0
  40. package/src/internal/router-generator/transform/transform.d.ts +8 -0
  41. package/src/internal/router-generator/transform/transform.js +385 -0
  42. package/src/internal/router-generator/transform/types.d.ts +34 -0
  43. package/src/internal/router-generator/types.d.ts +73 -0
  44. package/src/internal/router-generator/utils.d.ts +270 -0
  45. package/src/internal/router-generator/utils.js +864 -0
  46. package/src/internal/router-generator/validate-route-params.d.ts +13 -0
  47. package/src/internal/router-generator/validate-route-params.js +75 -0
  48. package/src/internal/router-plugin/context.d.ts +2 -0
  49. package/src/internal/router-plugin/context.js +2 -0
  50. package/src/internal/router-plugin/core/code-splitter/compilers.d.ts +69 -0
  51. package/src/internal/router-plugin/core/code-splitter/compilers.js +1042 -0
  52. package/src/internal/router-plugin/core/code-splitter/framework-options.d.ts +11 -0
  53. package/src/internal/router-plugin/core/code-splitter/framework-options.js +41 -0
  54. package/src/internal/router-plugin/core/code-splitter/plugins/framework-plugins.d.ts +12 -0
  55. package/src/internal/router-plugin/core/code-splitter/plugins/framework-plugins.js +35 -0
  56. package/src/internal/router-plugin/core/code-splitter/plugins/octane-hmr-split-route-components.d.ts +5 -0
  57. package/src/internal/router-plugin/core/code-splitter/plugins/octane-hmr-split-route-components.js +106 -0
  58. package/src/internal/router-plugin/core/code-splitter/plugins/octane-split-route-components.d.ts +8 -0
  59. package/src/internal/router-plugin/core/code-splitter/plugins/octane-split-route-components.js +85 -0
  60. package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-ignored-route-exports.d.ts +2 -0
  61. package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-ignored-route-exports.js +55 -0
  62. package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-route-components.d.ts +2 -0
  63. package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-route-components.js +50 -0
  64. package/src/internal/router-plugin/core/code-splitter/plugins/react-stable-hmr-split-route-components.d.ts +5 -0
  65. package/src/internal/router-plugin/core/code-splitter/plugins/react-stable-hmr-split-route-components.js +54 -0
  66. package/src/internal/router-plugin/core/code-splitter/plugins.d.ts +62 -0
  67. package/src/internal/router-plugin/core/code-splitter/types.d.ts +9 -0
  68. package/src/internal/router-plugin/core/config.d.ts +294 -0
  69. package/src/internal/router-plugin/core/config.js +56 -0
  70. package/src/internal/router-plugin/core/constants.d.ts +12 -0
  71. package/src/internal/router-plugin/core/constants.js +13 -0
  72. package/src/internal/router-plugin/core/framework-plugin-order.d.ts +8 -0
  73. package/src/internal/router-plugin/core/framework-plugin-order.js +78 -0
  74. package/src/internal/router-plugin/core/hmr/handle-route-update.d.ts +1 -0
  75. package/src/internal/router-plugin/core/hmr/handle-route-update.js +126 -0
  76. package/src/internal/router-plugin/core/hmr/index.d.ts +5 -0
  77. package/src/internal/router-plugin/core/hmr/select-adapter.d.ts +17 -0
  78. package/src/internal/router-plugin/core/hmr/select-adapter.js +24 -0
  79. package/src/internal/router-plugin/core/hmr/vite-adapter.d.ts +18 -0
  80. package/src/internal/router-plugin/core/hmr/vite-adapter.js +73 -0
  81. package/src/internal/router-plugin/core/hmr/webpack-adapter.d.ts +22 -0
  82. package/src/internal/router-plugin/core/hmr/webpack-adapter.js +78 -0
  83. package/src/internal/router-plugin/core/router-code-splitter-plugin.d.ts +10 -0
  84. package/src/internal/router-plugin/core/router-code-splitter-plugin.js +244 -0
  85. package/src/internal/router-plugin/core/router-composed-plugin.d.ts +5 -0
  86. package/src/internal/router-plugin/core/router-composed-plugin.js +62 -0
  87. package/src/internal/router-plugin/core/router-generator-plugin.d.ts +10 -0
  88. package/src/internal/router-plugin/core/router-generator-plugin.js +125 -0
  89. package/src/internal/router-plugin/core/router-hmr-plugin.d.ts +13 -0
  90. package/src/internal/router-plugin/core/router-hmr-plugin.js +101 -0
  91. package/src/internal/router-plugin/core/router-plugin-context.d.ts +5 -0
  92. package/src/internal/router-plugin/core/router-plugin-context.js +6 -0
  93. package/src/internal/router-plugin/core/utils.d.ts +17 -0
  94. package/src/internal/router-plugin/core/utils.js +47 -0
  95. package/src/internal/router-plugin/esbuild.d.ts +197 -0
  96. package/src/internal/router-plugin/esbuild.js +58 -0
  97. package/src/internal/router-plugin/index.d.ts +19 -0
  98. package/src/internal/router-plugin/index.js +17 -0
  99. package/src/internal/router-plugin/rspack.d.ts +61 -0
  100. package/src/internal/router-plugin/rspack.js +92 -0
  101. package/src/internal/router-plugin/vite.d.ts +201 -0
  102. package/src/internal/router-plugin/vite.js +62 -0
  103. package/src/internal/router-plugin/webpack.d.ts +50 -0
  104. package/src/internal/router-plugin/webpack.js +77 -0
  105. package/src/internal/start-plugin-core/build-sitemap.d.ts +34 -0
  106. package/src/internal/start-plugin-core/build-sitemap.js +125 -0
  107. package/src/internal/start-plugin-core/config-context.d.ts +30 -0
  108. package/src/internal/start-plugin-core/config-context.js +89 -0
  109. package/src/internal/start-plugin-core/constants.d.ts +20 -0
  110. package/src/internal/start-plugin-core/constants.js +24 -0
  111. package/src/internal/start-plugin-core/debug.d.ts +1 -0
  112. package/src/internal/start-plugin-core/hydrate-when-transform.d.ts +5 -0
  113. package/src/internal/start-plugin-core/hydrate-when-transform.js +661 -0
  114. package/src/internal/start-plugin-core/hydration-constants.d.ts +1 -0
  115. package/src/internal/start-plugin-core/hydration-constants.js +4 -0
  116. package/src/internal/start-plugin-core/import-protection/adapterUtils.d.ts +40 -0
  117. package/src/internal/start-plugin-core/import-protection/adapterUtils.js +42 -0
  118. package/src/internal/start-plugin-core/import-protection/analysis.d.ts +63 -0
  119. package/src/internal/start-plugin-core/import-protection/analysis.js +533 -0
  120. package/src/internal/start-plugin-core/import-protection/constants.d.ts +11 -0
  121. package/src/internal/start-plugin-core/import-protection/constants.js +39 -0
  122. package/src/internal/start-plugin-core/import-protection/defaults.d.ts +19 -0
  123. package/src/internal/start-plugin-core/import-protection/defaults.js +34 -0
  124. package/src/internal/start-plugin-core/import-protection/extensionlessAbsoluteIdResolver.d.ts +22 -0
  125. package/src/internal/start-plugin-core/import-protection/extensionlessAbsoluteIdResolver.js +94 -0
  126. package/src/internal/start-plugin-core/import-protection/matchers.d.ts +18 -0
  127. package/src/internal/start-plugin-core/import-protection/matchers.js +39 -0
  128. package/src/internal/start-plugin-core/import-protection/rewrite.d.ts +29 -0
  129. package/src/internal/start-plugin-core/import-protection/rewrite.js +184 -0
  130. package/src/internal/start-plugin-core/import-protection/sourceLocation.d.ts +170 -0
  131. package/src/internal/start-plugin-core/import-protection/sourceLocation.js +376 -0
  132. package/src/internal/start-plugin-core/import-protection/trace.d.ts +89 -0
  133. package/src/internal/start-plugin-core/import-protection/trace.js +186 -0
  134. package/src/internal/start-plugin-core/import-protection/utils.d.ts +78 -0
  135. package/src/internal/start-plugin-core/import-protection/utils.js +171 -0
  136. package/src/internal/start-plugin-core/import-protection/virtualModules.d.ts +38 -0
  137. package/src/internal/start-plugin-core/import-protection/virtualModules.js +241 -0
  138. package/src/internal/start-plugin-core/index.d.ts +8 -0
  139. package/src/internal/start-plugin-core/index.js +2 -0
  140. package/src/internal/start-plugin-core/planning.d.ts +44 -0
  141. package/src/internal/start-plugin-core/planning.js +98 -0
  142. package/src/internal/start-plugin-core/post-build.d.ts +12 -0
  143. package/src/internal/start-plugin-core/post-build.js +40 -0
  144. package/src/internal/start-plugin-core/prerender.d.ts +17 -0
  145. package/src/internal/start-plugin-core/prerender.js +172 -0
  146. package/src/internal/start-plugin-core/queue.d.ts +37 -0
  147. package/src/internal/start-plugin-core/queue.js +118 -0
  148. package/src/internal/start-plugin-core/resolve-entries.d.ts +10 -0
  149. package/src/internal/start-plugin-core/resolve-entries.js +32 -0
  150. package/src/internal/start-plugin-core/schema.d.ts +1799 -0
  151. package/src/internal/start-plugin-core/schema.js +252 -0
  152. package/src/internal/start-plugin-core/serialization-adapters-module.d.ts +18 -0
  153. package/src/internal/start-plugin-core/serialization-adapters-module.js +37 -0
  154. package/src/internal/start-plugin-core/start-compiler/compiler.d.ts +181 -0
  155. package/src/internal/start-plugin-core/start-compiler/compiler.js +1078 -0
  156. package/src/internal/start-plugin-core/start-compiler/config.d.ts +20 -0
  157. package/src/internal/start-plugin-core/start-compiler/config.js +84 -0
  158. package/src/internal/start-plugin-core/start-compiler/handleClientOnlyJSX.d.ts +24 -0
  159. package/src/internal/start-plugin-core/start-compiler/handleClientOnlyJSX.js +25 -0
  160. package/src/internal/start-plugin-core/start-compiler/handleCreateIsomorphicFn.d.ts +11 -0
  161. package/src/internal/start-plugin-core/start-compiler/handleCreateIsomorphicFn.js +24 -0
  162. package/src/internal/start-plugin-core/start-compiler/handleCreateMiddleware.d.ts +11 -0
  163. package/src/internal/start-plugin-core/start-compiler/handleCreateMiddleware.js +35 -0
  164. package/src/internal/start-plugin-core/start-compiler/handleCreateServerFn.d.ts +22 -0
  165. package/src/internal/start-plugin-core/start-compiler/handleCreateServerFn.js +292 -0
  166. package/src/internal/start-plugin-core/start-compiler/handleEnvOnly.d.ts +14 -0
  167. package/src/internal/start-plugin-core/start-compiler/handleEnvOnly.js +41 -0
  168. package/src/internal/start-plugin-core/start-compiler/host.d.ts +44 -0
  169. package/src/internal/start-plugin-core/start-compiler/host.js +75 -0
  170. package/src/internal/start-plugin-core/start-compiler/server-fn-resolver-module.d.ts +10 -0
  171. package/src/internal/start-plugin-core/start-compiler/server-fn-resolver-module.js +87 -0
  172. package/src/internal/start-plugin-core/start-compiler/types.d.ts +119 -0
  173. package/src/internal/start-plugin-core/start-compiler/utils.d.ts +27 -0
  174. package/src/internal/start-plugin-core/start-compiler/utils.js +36 -0
  175. package/src/internal/start-plugin-core/start-manifest-plugin/inlineCss.d.ts +16 -0
  176. package/src/internal/start-plugin-core/start-manifest-plugin/inlineCss.js +131 -0
  177. package/src/internal/start-plugin-core/start-manifest-plugin/manifestBuilder.d.ts +64 -0
  178. package/src/internal/start-plugin-core/start-manifest-plugin/manifestBuilder.js +441 -0
  179. package/src/internal/start-plugin-core/start-router-plugin/constants.d.ts +1 -0
  180. package/src/internal/start-plugin-core/start-router-plugin/constants.js +4 -0
  181. package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/compose-generator-plugins.d.ts +6 -0
  182. package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/compose-generator-plugins.js +6 -0
  183. package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/prerender-routes-plugin.d.ts +6 -0
  184. package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/prerender-routes-plugin.js +27 -0
  185. package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/routes-manifest-plugin.d.ts +6 -0
  186. package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/routes-manifest-plugin.js +34 -0
  187. package/src/internal/start-plugin-core/start-router-plugin/pruneServerOnlySubtrees.d.ts +11 -0
  188. package/src/internal/start-plugin-core/start-router-plugin/pruneServerOnlySubtrees.js +42 -0
  189. package/src/internal/start-plugin-core/start-router-plugin/route-tree-footer.d.ts +6 -0
  190. package/src/internal/start-plugin-core/start-router-plugin/route-tree-footer.js +59 -0
  191. package/src/internal/start-plugin-core/types.d.ts +135 -0
  192. package/src/internal/start-plugin-core/types.js +4 -0
  193. package/src/internal/start-plugin-core/utils.d.ts +13 -0
  194. package/src/internal/start-plugin-core/utils.js +42 -0
  195. package/src/internal/start-plugin-core/vite/createVirtualModule.d.ts +15 -0
  196. package/src/internal/start-plugin-core/vite/createVirtualModule.js +27 -0
  197. package/src/internal/start-plugin-core/vite/dev-server-plugin/dev-styles.d.ts +26 -0
  198. package/src/internal/start-plugin-core/vite/dev-server-plugin/dev-styles.js +165 -0
  199. package/src/internal/start-plugin-core/vite/dev-server-plugin/plugin.d.ts +11 -0
  200. package/src/internal/start-plugin-core/vite/dev-server-plugin/plugin.js +170 -0
  201. package/src/internal/start-plugin-core/vite/import-protection-plugin/plugin.d.ts +4 -0
  202. package/src/internal/start-plugin-core/vite/import-protection-plugin/plugin.js +1553 -0
  203. package/src/internal/start-plugin-core/vite/import-protection-plugin/types.d.ts +103 -0
  204. package/src/internal/start-plugin-core/vite/import-protection-plugin/virtualModules.d.ts +40 -0
  205. package/src/internal/start-plugin-core/vite/import-protection-plugin/virtualModules.js +68 -0
  206. package/src/internal/start-plugin-core/vite/index.d.ts +13 -0
  207. package/src/internal/start-plugin-core/vite/index.js +4 -0
  208. package/src/internal/start-plugin-core/vite/load-env-plugin/plugin.d.ts +2 -0
  209. package/src/internal/start-plugin-core/vite/load-env-plugin/plugin.js +13 -0
  210. package/src/internal/start-plugin-core/vite/output-directory.d.ts +7 -0
  211. package/src/internal/start-plugin-core/vite/output-directory.js +18 -0
  212. package/src/internal/start-plugin-core/vite/planning.d.ts +112 -0
  213. package/src/internal/start-plugin-core/vite/planning.js +152 -0
  214. package/src/internal/start-plugin-core/vite/plugin.d.ts +7 -0
  215. package/src/internal/start-plugin-core/vite/plugin.js +208 -0
  216. package/src/internal/start-plugin-core/vite/plugins.d.ts +17 -0
  217. package/src/internal/start-plugin-core/vite/plugins.js +72 -0
  218. package/src/internal/start-plugin-core/vite/post-server-build.d.ts +9 -0
  219. package/src/internal/start-plugin-core/vite/post-server-build.js +22 -0
  220. package/src/internal/start-plugin-core/vite/prerender.d.ts +9 -0
  221. package/src/internal/start-plugin-core/vite/prerender.js +52 -0
  222. package/src/internal/start-plugin-core/vite/preview-server-plugin/plugin.d.ts +2 -0
  223. package/src/internal/start-plugin-core/vite/preview-server-plugin/plugin.js +54 -0
  224. package/src/internal/start-plugin-core/vite/schema.d.ts +2423 -0
  225. package/src/internal/start-plugin-core/vite/schema.js +17 -0
  226. package/src/internal/start-plugin-core/vite/serialization-adapters-plugin.d.ts +5 -0
  227. package/src/internal/start-plugin-core/vite/serialization-adapters-plugin.js +63 -0
  228. package/src/internal/start-plugin-core/vite/start-compiler-plugin/hot-update.d.ts +5 -0
  229. package/src/internal/start-plugin-core/vite/start-compiler-plugin/hot-update.js +14 -0
  230. package/src/internal/start-plugin-core/vite/start-compiler-plugin/module-specifier.d.ts +5 -0
  231. package/src/internal/start-plugin-core/vite/start-compiler-plugin/module-specifier.js +25 -0
  232. package/src/internal/start-plugin-core/vite/start-compiler-plugin/plugin.d.ts +29 -0
  233. package/src/internal/start-plugin-core/vite/start-compiler-plugin/plugin.js +380 -0
  234. package/src/internal/start-plugin-core/vite/start-manifest-plugin/normalized-client-build.d.ts +11 -0
  235. package/src/internal/start-plugin-core/vite/start-manifest-plugin/normalized-client-build.js +114 -0
  236. package/src/internal/start-plugin-core/vite/start-manifest-plugin/plugin.d.ts +3 -0
  237. package/src/internal/start-plugin-core/vite/start-manifest-plugin/plugin.js +103 -0
  238. package/src/internal/start-plugin-core/vite/start-router-plugin/plugin.d.ts +9 -0
  239. package/src/internal/start-plugin-core/vite/start-router-plugin/plugin.js +143 -0
  240. package/src/internal/start-plugin-core/vite/types.d.ts +17 -0
  241. package/src/package-names.js +10 -0
  242. package/src/plugin-vite.d.ts +23 -0
  243. package/src/plugin-vite.js +62 -0
  244. package/src/runtime/client/StartClient.d.ts +11 -0
  245. package/src/runtime/client/StartClient.js +16 -0
  246. package/src/runtime/client/hydrateStart.d.ts +4 -0
  247. package/src/runtime/client/hydrateStart.js +30 -0
  248. package/src/runtime/server/StartServer.d.ts +10 -0
  249. package/src/runtime/server/StartServer.js +6 -0
  250. package/src/runtime/server/defaultRenderHandler.d.ts +3 -0
  251. package/src/runtime/server/defaultRenderHandler.js +11 -0
  252. package/src/runtime/server/defaultStreamHandler.d.ts +3 -0
  253. package/src/runtime/server/defaultStreamHandler.js +13 -0
  254. package/src/server-entry.d.ts +11 -0
  255. package/src/server-entry.js +13 -0
  256. package/src/server-only.d.ts +1 -0
  257. package/src/server-only.js +0 -0
  258. package/src/server-rpc.d.ts +1 -0
  259. package/src/server-rpc.js +1 -0
  260. package/src/server.d.ts +6 -0
  261. package/src/server.js +4 -0
  262. package/src/ssr-rpc.d.ts +1 -0
  263. package/src/ssr-rpc.js +1 -0
  264. package/src/use-server-fn.d.ts +3 -0
  265. package/src/use-server-fn.js +18 -0
  266. package/src/validate-options.js +7 -0
@@ -0,0 +1,20 @@
1
+ import { LookupConfig } from './compiler.js';
2
+ import {
3
+ CompileStartFrameworkOptions,
4
+ StartCompilerImportTransform,
5
+ StartCompilerPlugin,
6
+ } from '../types.js';
7
+ export declare function getTransformCodeFilterForEnv(
8
+ env: 'client' | 'server',
9
+ opts?: {
10
+ compilerTransforms?: Array<StartCompilerImportTransform> | undefined;
11
+ compilerPlugins?: Array<StartCompilerPlugin> | undefined;
12
+ },
13
+ ): Array<RegExp>;
14
+ export declare function getLookupConfigurationsForEnv(
15
+ env: 'client' | 'server',
16
+ framework: CompileStartFrameworkOptions,
17
+ opts?: {
18
+ compilerTransforms?: Array<StartCompilerImportTransform> | undefined;
19
+ },
20
+ ): Array<LookupConfig>;
@@ -0,0 +1,84 @@
1
+ import {
2
+ KindDetectionPatterns,
3
+ getExternalLookupKind,
4
+ getLookupKindsForEnv,
5
+ isCompilerTransformEnabledForEnv,
6
+ isStartCompilerPluginEnabledForEnv,
7
+ } from './compiler.js';
8
+ import { getRouterPackage, getStartPackage } from '#tanstack-start/package-names';
9
+ //#region src/start-compiler/config.ts
10
+ function getTransformCodeFilterForEnv(env, opts) {
11
+ const validKinds = getLookupKindsForEnv(env, opts);
12
+ const patterns = [];
13
+ for (const [kind, pattern] of Object.entries(KindDetectionPatterns))
14
+ if (validKinds.has(kind)) patterns.push(pattern);
15
+ for (const transform of opts?.compilerTransforms ?? [])
16
+ if (isCompilerTransformEnabledForEnv(transform, env)) patterns.push(transform.detect);
17
+ for (const plugin of opts?.compilerPlugins ?? [])
18
+ if (plugin.detect && isStartCompilerPluginEnabledForEnv(plugin, env))
19
+ patterns.push(plugin.detect);
20
+ return patterns;
21
+ }
22
+ function getLookupConfigurationsForEnv(env, framework, opts) {
23
+ const commonConfigs = [
24
+ {
25
+ libName: getStartPackage(framework),
26
+ rootExport: 'createServerFn',
27
+ kind: 'Root',
28
+ },
29
+ {
30
+ libName: getStartPackage(framework),
31
+ rootExport: 'createIsomorphicFn',
32
+ kind: 'IsomorphicFn',
33
+ },
34
+ {
35
+ libName: getStartPackage(framework),
36
+ rootExport: 'createServerOnlyFn',
37
+ kind: 'ServerOnlyFn',
38
+ },
39
+ {
40
+ libName: getStartPackage(framework),
41
+ rootExport: 'createClientOnlyFn',
42
+ kind: 'ClientOnlyFn',
43
+ },
44
+ ];
45
+ const externalConfigs = [];
46
+ for (const transform of opts?.compilerTransforms ?? []) {
47
+ if (!isCompilerTransformEnabledForEnv(transform, env)) continue;
48
+ const kind = getExternalLookupKind(transform);
49
+ for (const imported of transform.imports)
50
+ externalConfigs.push({
51
+ libName: imported.libName,
52
+ rootExport: imported.rootExport,
53
+ kind,
54
+ });
55
+ }
56
+ if (env === 'client')
57
+ return [
58
+ {
59
+ libName: getStartPackage(framework),
60
+ rootExport: 'createMiddleware',
61
+ kind: 'Root',
62
+ },
63
+ {
64
+ libName: getStartPackage(framework),
65
+ rootExport: 'createStart',
66
+ kind: 'Root',
67
+ },
68
+ ...commonConfigs,
69
+ ...externalConfigs,
70
+ ];
71
+ return [
72
+ ...[
73
+ ...commonConfigs,
74
+ {
75
+ libName: getRouterPackage(framework),
76
+ rootExport: 'ClientOnly',
77
+ kind: 'ClientOnlyJSX',
78
+ },
79
+ ],
80
+ ...externalConfigs,
81
+ ];
82
+ }
83
+ //#endregion
84
+ export { getLookupConfigurationsForEnv, getTransformCodeFilterForEnv };
@@ -0,0 +1,24 @@
1
+ import type * as t from '@babel/types';
2
+ import type * as babel from '@babel/core';
3
+ /**
4
+ * Handles <ClientOnly> JSX elements on the server side.
5
+ *
6
+ * On the server, the children of <ClientOnly> should be removed since they
7
+ * are client-only code. Only the fallback prop (if present) will be rendered.
8
+ *
9
+ * Transform:
10
+ * <ClientOnly fallback={<Loading />}>{clientOnlyContent}</ClientOnly>
11
+ * Into:
12
+ * <ClientOnly fallback={<Loading />} />
13
+ *
14
+ * Or if no fallback:
15
+ * <ClientOnly>{clientOnlyContent}</ClientOnly>
16
+ * Into:
17
+ * <ClientOnly />
18
+ */
19
+ export declare function handleClientOnlyJSX(
20
+ path: babel.NodePath<t.JSXElement>,
21
+ _opts: {
22
+ env: 'server';
23
+ },
24
+ ): void;
@@ -0,0 +1,25 @@
1
+ //#region src/start-compiler/handleClientOnlyJSX.ts
2
+ /**
3
+ * Handles <ClientOnly> JSX elements on the server side.
4
+ *
5
+ * On the server, the children of <ClientOnly> should be removed since they
6
+ * are client-only code. Only the fallback prop (if present) will be rendered.
7
+ *
8
+ * Transform:
9
+ * <ClientOnly fallback={<Loading />}>{clientOnlyContent}</ClientOnly>
10
+ * Into:
11
+ * <ClientOnly fallback={<Loading />} />
12
+ *
13
+ * Or if no fallback:
14
+ * <ClientOnly>{clientOnlyContent}</ClientOnly>
15
+ * Into:
16
+ * <ClientOnly />
17
+ */
18
+ function handleClientOnlyJSX(path, _opts) {
19
+ const element = path.node;
20
+ element.children = [];
21
+ element.openingElement.selfClosing = true;
22
+ element.closingElement = null;
23
+ }
24
+ //#endregion
25
+ export { handleClientOnlyJSX };
@@ -0,0 +1,11 @@
1
+ import { CompilationContext, RewriteCandidate } from './types.js';
2
+ /**
3
+ * Handles createIsomorphicFn transformations for a batch of candidates.
4
+ *
5
+ * @param candidates - All IsomorphicFn candidates to process
6
+ * @param context - The compilation context
7
+ */
8
+ export declare function handleCreateIsomorphicFn(
9
+ candidates: Array<RewriteCandidate>,
10
+ context: CompilationContext,
11
+ ): void;
@@ -0,0 +1,24 @@
1
+ import * as t from '@babel/types';
2
+ //#region src/start-compiler/handleCreateIsomorphicFn.ts
3
+ /**
4
+ * Handles createIsomorphicFn transformations for a batch of candidates.
5
+ *
6
+ * @param candidates - All IsomorphicFn candidates to process
7
+ * @param context - The compilation context
8
+ */
9
+ function handleCreateIsomorphicFn(candidates, context) {
10
+ for (const candidate of candidates) {
11
+ const { path, methodChain } = candidate;
12
+ const envCallInfo = context.env === 'client' ? methodChain.client : methodChain.server;
13
+ if (!envCallInfo) {
14
+ path.replaceWith(t.arrowFunctionExpression([], t.blockStatement([])));
15
+ continue;
16
+ }
17
+ const innerFn = envCallInfo.firstArgPath?.node;
18
+ if (!t.isExpression(innerFn))
19
+ throw new Error(`createIsomorphicFn().${context.env}(func) must be called with a function!`);
20
+ path.replaceWith(innerFn);
21
+ }
22
+ }
23
+ //#endregion
24
+ export { handleCreateIsomorphicFn };
@@ -0,0 +1,11 @@
1
+ import { CompilationContext, RewriteCandidate } from './types.js';
2
+ /**
3
+ * Handles createMiddleware transformations for a batch of candidates.
4
+ *
5
+ * @param candidates - All Middleware candidates to process
6
+ * @param context - The compilation context
7
+ */
8
+ export declare function handleCreateMiddleware(
9
+ candidates: Array<RewriteCandidate>,
10
+ context: CompilationContext,
11
+ ): void;
@@ -0,0 +1,35 @@
1
+ import { stripMethodCall } from './utils.js';
2
+ //#region src/start-compiler/handleCreateMiddleware.ts
3
+ function warnInputValidatorDeprecation(context, inputValidator) {
4
+ const loc = inputValidator.callPath.node.loc?.start;
5
+ const location = loc ? `${context.id}:${loc.line}:${loc.column + 1} ` : `${context.id} `;
6
+ context.warn?.(
7
+ `${location}createMiddleware().inputValidator() is deprecated. Use createMiddleware().validator() instead.`,
8
+ );
9
+ }
10
+ /**
11
+ * Handles createMiddleware transformations for a batch of candidates.
12
+ *
13
+ * @param candidates - All Middleware candidates to process
14
+ * @param context - The compilation context
15
+ */
16
+ function handleCreateMiddleware(candidates, context) {
17
+ if (context.env === 'server')
18
+ throw new Error('handleCreateMiddleware should not be called on the server');
19
+ for (const candidate of candidates) {
20
+ const { validator, inputValidator, server } = candidate.methodChain;
21
+ if (inputValidator) warnInputValidatorDeprecation(context, inputValidator);
22
+ for (const [methodName, methodCall] of [
23
+ ['validator', validator],
24
+ ['inputValidator', inputValidator],
25
+ ]) {
26
+ if (!methodCall) continue;
27
+ if (!methodCall.callPath.node.arguments[0])
28
+ throw new Error(`createMiddleware().${methodName}() must be called with a validator!`);
29
+ stripMethodCall(methodCall.callPath);
30
+ }
31
+ if (server) stripMethodCall(server.callPath);
32
+ }
33
+ }
34
+ //#endregion
35
+ export { handleCreateMiddleware };
@@ -0,0 +1,22 @@
1
+ import { CompilationContext, RewriteCandidate } from './types.js';
2
+ /**
3
+ * Handles createServerFn transformations for a batch of candidates.
4
+ *
5
+ * This function performs extraction and replacement of server functions
6
+ *
7
+ * For caller files (non-provider):
8
+ * - Replaces the server function with an RPC stub
9
+ * - Does not include the handler function body
10
+ *
11
+ * For provider files:
12
+ * - Creates an extractedFn that calls __executeServer
13
+ * - Modifies .handler() to pass (extractedFn, serverFn) - two arguments
14
+ *
15
+ * @param candidates - All ServerFn candidates to process
16
+ * @param context - The compilation context with helpers and mutable state
17
+ * @returns Result containing runtime code to add, or null if no candidates processed
18
+ */
19
+ export declare function handleCreateServerFn(
20
+ candidates: Array<RewriteCandidate>,
21
+ context: CompilationContext,
22
+ ): void;
@@ -0,0 +1,292 @@
1
+ import { cleanId, codeFrameError, stripMethodCall } from './utils.js';
2
+ import { hasKeys } from '@tanstack/router-core';
3
+ import path from 'pathe';
4
+ import * as t from '@babel/types';
5
+ import { getVariableDeclaratorForExpressionPath } from '@tanstack/router-utils';
6
+ import babel from '@babel/core';
7
+ import { getStartPackage } from '#tanstack-start/package-names';
8
+ //#region src/start-compiler/handleCreateServerFn.ts
9
+ var TSS_SERVERFN_SPLIT_PARAM = 'tss-serverfn-split';
10
+ var providerHmrAcceptTemplate = babel.template.statements(
11
+ `
12
+ if (import.meta.hot) {
13
+ import.meta.hot.accept(() => {})
14
+ }
15
+ if (import.meta.webpackHot) {
16
+ import.meta.webpackHot.accept(() => {})
17
+ }
18
+ `,
19
+ { placeholderPattern: false },
20
+ );
21
+ var serverRpcTemplate = babel.template.expression(`createServerRpc(%%serverFnMeta%%, %%fn%%)`);
22
+ var clientRpcTemplate = babel.template.expression(`createClientRpc(%%functionId%%)`);
23
+ var ssrRpcManifestTemplate = babel.template.expression(`createSsrRpc(%%functionId%%)`);
24
+ function warnInputValidatorDeprecation(context, inputValidator) {
25
+ const loc = inputValidator.callPath.node.loc?.start;
26
+ const location = loc ? `${context.id}:${loc.line}:${loc.column + 1} ` : `${context.id} `;
27
+ context.warn?.(
28
+ `${location}createServerFn().inputValidator() is deprecated. Use createServerFn().validator() instead.`,
29
+ );
30
+ }
31
+ var RuntimeCodeCache = /* @__PURE__ */ new Map();
32
+ function getCachedRuntimeCode(framework, type) {
33
+ let cache = RuntimeCodeCache.get(framework);
34
+ if (!cache) {
35
+ const startPackage = getStartPackage(framework);
36
+ cache = {
37
+ provider: babel.template.ast(`import { createServerRpc } from '${startPackage}/server-rpc'`, {
38
+ placeholderPattern: false,
39
+ }),
40
+ client: babel.template.ast(`import { createClientRpc } from '${startPackage}/client-rpc'`, {
41
+ placeholderPattern: false,
42
+ }),
43
+ ssr: babel.template.ast(`import { createSsrRpc } from '${startPackage}/ssr-rpc'`, {
44
+ placeholderPattern: false,
45
+ }),
46
+ };
47
+ RuntimeCodeCache.set(framework, cache);
48
+ }
49
+ return cache[type];
50
+ }
51
+ /**
52
+ * Gets the environment configuration for the current compilation context.
53
+ */
54
+ function getEnvConfig(context, isProviderFile) {
55
+ const { env } = context;
56
+ if (isProviderFile)
57
+ return {
58
+ isClientEnvironment: false,
59
+ runtimeCodeType: 'provider',
60
+ };
61
+ if (env === 'client')
62
+ return {
63
+ isClientEnvironment: true,
64
+ runtimeCodeType: 'client',
65
+ };
66
+ return {
67
+ isClientEnvironment: false,
68
+ runtimeCodeType: 'ssr',
69
+ };
70
+ }
71
+ /**
72
+ * Builds the serverFnMeta object literal AST node.
73
+ * The object contains: { id, name, filename }
74
+ */
75
+ function buildServerFnMetaObject(functionId, variableName, filename) {
76
+ return t.objectExpression([
77
+ t.objectProperty(t.identifier('id'), t.stringLiteral(functionId)),
78
+ t.objectProperty(t.identifier('name'), t.stringLiteral(variableName)),
79
+ t.objectProperty(t.identifier('filename'), t.stringLiteral(filename)),
80
+ ]);
81
+ }
82
+ /**
83
+ * Generates the RPC stub expression for provider files.
84
+ * Uses pre-compiled template for performance.
85
+ */
86
+ function generateProviderRpcStub(serverFnMeta, fn) {
87
+ return serverRpcTemplate({
88
+ serverFnMeta,
89
+ fn,
90
+ });
91
+ }
92
+ /**
93
+ * Generates the RPC stub expression for caller files.
94
+ * Uses pre-compiled templates for performance.
95
+ * Note: Client and SSR callers only receive the functionId string, not the full metadata.
96
+ */
97
+ function generateCallerRpcStub(functionId, envConfig) {
98
+ const functionIdLiteral = t.stringLiteral(functionId);
99
+ if (envConfig.runtimeCodeType === 'client')
100
+ return clientRpcTemplate({ functionId: functionIdLiteral });
101
+ return ssrRpcManifestTemplate({ functionId: functionIdLiteral });
102
+ }
103
+ /**
104
+ * Handles createServerFn transformations for a batch of candidates.
105
+ *
106
+ * This function performs extraction and replacement of server functions
107
+ *
108
+ * For caller files (non-provider):
109
+ * - Replaces the server function with an RPC stub
110
+ * - Does not include the handler function body
111
+ *
112
+ * For provider files:
113
+ * - Creates an extractedFn that calls __executeServer
114
+ * - Modifies .handler() to pass (extractedFn, serverFn) - two arguments
115
+ *
116
+ * @param candidates - All ServerFn candidates to process
117
+ * @param context - The compilation context with helpers and mutable state
118
+ * @returns Result containing runtime code to add, or null if no candidates processed
119
+ */
120
+ function handleCreateServerFn(candidates, context) {
121
+ if (candidates.length === 0) return;
122
+ const isProviderFile = context.id.includes(TSS_SERVERFN_SPLIT_PARAM);
123
+ if (isProviderFile && context.serverFnProviderModuleDirectives)
124
+ ensureDirectivePrologue(context.ast, context.serverFnProviderModuleDirectives);
125
+ const envConfig = getEnvConfig(context, isProviderFile);
126
+ const functionNameSet = /* @__PURE__ */ new Set();
127
+ const exportNames = /* @__PURE__ */ new Set();
128
+ const serverFnsById = {};
129
+ const [baseFilename] = context.id.split('?');
130
+ const extractedFilename = `${baseFilename}?${TSS_SERVERFN_SPLIT_PARAM}`;
131
+ const relativeFilename = path.relative(context.root, baseFilename);
132
+ const knownFns = context.getKnownServerFns();
133
+ const cleanedContextId = cleanId(context.id);
134
+ for (const candidate of candidates) {
135
+ const { path: candidatePath, methodChain } = candidate;
136
+ const { validator, inputValidator, handler } = methodChain;
137
+ const candidateVariableDeclarator = getVariableDeclaratorForExpressionPath(candidatePath);
138
+ if (!candidateVariableDeclarator)
139
+ throw new Error('createServerFn must be assigned to a variable!');
140
+ const variableDeclarator = candidateVariableDeclarator.node;
141
+ if (!t.isIdentifier(variableDeclarator.id))
142
+ throw codeFrameError(
143
+ context.code,
144
+ variableDeclarator.id.loc,
145
+ 'createServerFn must be assigned to a simple identifier, not a destructuring pattern',
146
+ );
147
+ const existingVariableName = variableDeclarator.id.name;
148
+ let functionName = `${existingVariableName}_createServerFn_handler`;
149
+ while (functionNameSet.has(functionName))
150
+ functionName = incrementFunctionNameVersion(functionName);
151
+ functionNameSet.add(functionName);
152
+ const functionId = context.generateFunctionId({
153
+ filename: relativeFilename,
154
+ functionName,
155
+ extractedFilename,
156
+ });
157
+ const knownFn = knownFns[functionId];
158
+ const isClientReferenced =
159
+ envConfig.isClientEnvironment || !!knownFn || envConfig.runtimeCodeType === 'ssr';
160
+ const canonicalExtractedFilename = knownFn?.extractedFilename ?? extractedFilename;
161
+ if (inputValidator) warnInputValidatorDeprecation(context, inputValidator);
162
+ for (const [methodName, methodCall] of [
163
+ ['validator', validator],
164
+ ['inputValidator', inputValidator],
165
+ ]) {
166
+ if (!methodCall) continue;
167
+ if (!methodCall.callPath.node.arguments[0])
168
+ throw new Error(`createServerFn().${methodName}() must be called with a validator!`);
169
+ if (context.env === 'client') stripMethodCall(methodCall.callPath);
170
+ }
171
+ const handlerFnPath = handler?.firstArgPath;
172
+ if (!handler || !handlerFnPath?.node)
173
+ throw codeFrameError(
174
+ context.code,
175
+ candidatePath.node.callee.loc,
176
+ `createServerFn must be called with a "handler" property!`,
177
+ );
178
+ if (!t.isExpression(handlerFnPath.node))
179
+ throw codeFrameError(
180
+ context.code,
181
+ handlerFnPath.node.loc,
182
+ `handler() must be called with an expression, not a ${handlerFnPath.node.type}`,
183
+ );
184
+ const handlerFn = handlerFnPath.node;
185
+ if (!isProviderFile)
186
+ serverFnsById[functionId] = {
187
+ functionName,
188
+ functionId,
189
+ filename: cleanedContextId,
190
+ extractedFilename: canonicalExtractedFilename,
191
+ isClientReferenced,
192
+ };
193
+ if (isProviderFile) {
194
+ const executeServerArrowFn = t.arrowFunctionExpression(
195
+ [t.identifier('opts')],
196
+ t.callExpression(
197
+ t.memberExpression(t.identifier(existingVariableName), t.identifier('__executeServer')),
198
+ [t.identifier('opts')],
199
+ ),
200
+ );
201
+ const extractedFnInit = generateProviderRpcStub(
202
+ buildServerFnMetaObject(functionId, existingVariableName, relativeFilename),
203
+ executeServerArrowFn,
204
+ );
205
+ const extractedFnStatement = t.variableDeclaration('const', [
206
+ t.variableDeclarator(t.identifier(functionName), extractedFnInit),
207
+ ]);
208
+ const variableDeclaration = candidateVariableDeclarator.parentPath;
209
+ if (!variableDeclaration.isVariableDeclaration())
210
+ throw new Error('Expected createServerFn to be in a VariableDeclaration');
211
+ variableDeclaration.insertBefore(extractedFnStatement);
212
+ const extractedFnIdentifier = t.identifier(functionName);
213
+ const serverFnNode = t.cloneNode(handlerFn, true);
214
+ handler.callPath.node.arguments = [extractedFnIdentifier, serverFnNode];
215
+ exportNames.add(functionName);
216
+ } else {
217
+ const rpcStub = generateCallerRpcStub(functionId, envConfig);
218
+ handlerFnPath.replaceWith(rpcStub);
219
+ }
220
+ }
221
+ if (isProviderFile) {
222
+ safeRemoveExports(context.ast);
223
+ if (exportNames.size > 0)
224
+ context.ast.program.body.push(
225
+ t.exportNamedDeclaration(
226
+ void 0,
227
+ Array.from(exportNames).map((name) =>
228
+ t.exportSpecifier(t.identifier(name), t.identifier(name)),
229
+ ),
230
+ ),
231
+ );
232
+ if (context.mode === 'dev') context.ast.program.body.push(...providerHmrAcceptTemplate());
233
+ }
234
+ if (!isProviderFile && hasKeys(serverFnsById) && context.onServerFnsById)
235
+ context.onServerFnsById(serverFnsById);
236
+ const runtimeCode = getCachedRuntimeCode(context.framework, envConfig.runtimeCodeType);
237
+ context.ast.program.body.unshift(t.cloneNode(runtimeCode));
238
+ }
239
+ /**
240
+ * Makes an identifier safe for use as a JavaScript identifier.
241
+ */
242
+ function makeIdentifierSafe(identifier) {
243
+ return identifier
244
+ .replace(/[^a-zA-Z0-9_$]/g, '_')
245
+ .replace(/^[0-9]/, '_$&')
246
+ .replace(/^\$/, '_$')
247
+ .replace(/_{2,}/g, '_')
248
+ .replace(/^_|_$/g, '');
249
+ }
250
+ /**
251
+ * Increments the version number suffix on a function name.
252
+ */
253
+ function incrementFunctionNameVersion(functionName) {
254
+ const [realReferenceName, count] = functionName.split(/_(\d+)$/);
255
+ const suffix = `_${Number(count || '0') + 1}`;
256
+ return makeIdentifierSafe(realReferenceName) + suffix;
257
+ }
258
+ /**
259
+ * Removes all exports from the AST while preserving the declarations.
260
+ * Used for provider files where we want to re-export only the server functions.
261
+ */
262
+ function safeRemoveExports(ast) {
263
+ ast.program.body = ast.program.body.flatMap((node) => {
264
+ if (t.isExportNamedDeclaration(node) || t.isExportDefaultDeclaration(node)) {
265
+ if (
266
+ t.isFunctionDeclaration(node.declaration) ||
267
+ t.isClassDeclaration(node.declaration) ||
268
+ t.isVariableDeclaration(node.declaration)
269
+ ) {
270
+ if (t.isFunctionDeclaration(node.declaration) || t.isClassDeclaration(node.declaration)) {
271
+ if (!node.declaration.id) return node;
272
+ }
273
+ return node.declaration;
274
+ } else if (node.declaration === null) return [];
275
+ }
276
+ return node;
277
+ });
278
+ }
279
+ function ensureDirectivePrologue(ast, directiveValues) {
280
+ const directives = ast.program.directives;
281
+ const existingDirectives = new Set(directives.map((directive) => directive.value.value));
282
+ const missingDirectives = [];
283
+ for (const directiveValue of directiveValues) {
284
+ if (!directiveValue || existingDirectives.has(directiveValue)) continue;
285
+ existingDirectives.add(directiveValue);
286
+ missingDirectives.push(directiveValue);
287
+ }
288
+ for (let i = missingDirectives.length - 1; i >= 0; i--)
289
+ directives.unshift(t.directive(t.directiveLiteral(missingDirectives[i])));
290
+ }
291
+ //#endregion
292
+ export { handleCreateServerFn };
@@ -0,0 +1,14 @@
1
+ import { CompilationContext, RewriteCandidate } from './types.js';
2
+ import { LookupKind } from './compiler.js';
3
+ /**
4
+ * Handles serverOnly/clientOnly function transformations for a batch of candidates.
5
+ *
6
+ * @param candidates - All EnvOnly candidates to process (all same kind)
7
+ * @param context - The compilation context
8
+ * @param kind - The specific kind (ServerOnlyFn or ClientOnlyFn)
9
+ */
10
+ export declare function handleEnvOnlyFn(
11
+ candidates: Array<RewriteCandidate>,
12
+ context: CompilationContext,
13
+ kind: LookupKind,
14
+ ): void;
@@ -0,0 +1,41 @@
1
+ import * as t from '@babel/types';
2
+ //#region src/start-compiler/handleEnvOnly.ts
3
+ function capitalize(str) {
4
+ if (!str) return '';
5
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
6
+ }
7
+ /**
8
+ * Handles serverOnly/clientOnly function transformations for a batch of candidates.
9
+ *
10
+ * @param candidates - All EnvOnly candidates to process (all same kind)
11
+ * @param context - The compilation context
12
+ * @param kind - The specific kind (ServerOnlyFn or ClientOnlyFn)
13
+ */
14
+ function handleEnvOnlyFn(candidates, context, kind) {
15
+ const targetEnv = kind === 'ClientOnlyFn' ? 'client' : 'server';
16
+ for (const candidate of candidates) {
17
+ const { path } = candidate;
18
+ if (context.env === targetEnv) {
19
+ const innerFn = path.node.arguments[0];
20
+ if (!t.isExpression(innerFn))
21
+ throw new Error(`create${capitalize(targetEnv)}OnlyFn() must be called with a function!`);
22
+ path.replaceWith(innerFn);
23
+ } else
24
+ path.replaceWith(
25
+ t.arrowFunctionExpression(
26
+ [],
27
+ t.blockStatement([
28
+ t.throwStatement(
29
+ t.newExpression(t.identifier('Error'), [
30
+ t.stringLiteral(
31
+ `create${capitalize(targetEnv)}OnlyFn() functions can only be called on the ${targetEnv}!`,
32
+ ),
33
+ ]),
34
+ ),
35
+ ]),
36
+ ),
37
+ );
38
+ }
39
+ }
40
+ //#endregion
41
+ export { handleEnvOnlyFn };
@@ -0,0 +1,44 @@
1
+ import { StartCompiler } from './compiler.js';
2
+ import {
3
+ CompileStartFrameworkOptions,
4
+ StartCompilerImportTransform,
5
+ StartCompilerPlugin,
6
+ StartCompilerTransformResult,
7
+ StartCompilerVirtualModuleContext,
8
+ } from '../types.js';
9
+ import {
10
+ DevServerFnModuleSpecifierEncoder,
11
+ GenerateFunctionIdFnOptional,
12
+ ServerFn,
13
+ } from './types.js';
14
+ export interface CreateStartCompilerOptions {
15
+ env: 'client' | 'server';
16
+ envName: string;
17
+ root: string;
18
+ framework: CompileStartFrameworkOptions;
19
+ providerEnvName: string;
20
+ mode: 'dev' | 'build';
21
+ generateFunctionId?: GenerateFunctionIdFnOptional;
22
+ compilerTransforms?: Array<StartCompilerImportTransform> | undefined;
23
+ compilerPlugins?: Array<StartCompilerPlugin> | undefined;
24
+ serverFnProviderModuleDirectives?: ReadonlyArray<string> | undefined;
25
+ warn?: (message: string) => void;
26
+ onServerFnsById?: (d: Record<string, ServerFn>) => void;
27
+ getKnownServerFns: () => Record<string, ServerFn>;
28
+ encodeModuleSpecifierInDev?: DevServerFnModuleSpecifierEncoder;
29
+ loadModule: (id: string) => Promise<void>;
30
+ resolveId: (id: string, importer?: string) => Promise<string | null>;
31
+ }
32
+ export declare function createStartCompiler(options: CreateStartCompilerOptions): StartCompiler;
33
+ export declare function mergeServerFnsById(
34
+ current: Record<string, ServerFn>,
35
+ next: Record<string, ServerFn>,
36
+ ): void;
37
+ export declare function matchesCodeFilters(code: string, filters: ReadonlyArray<RegExp>): boolean;
38
+ export declare function createCompilerVirtualModuleIdPattern(
39
+ compilerPlugins: ReadonlyArray<StartCompilerPlugin>,
40
+ ): RegExp | undefined;
41
+ export declare function loadCompilerVirtualModule(
42
+ compilerPlugins: ReadonlyArray<StartCompilerPlugin>,
43
+ context: StartCompilerVirtualModuleContext,
44
+ ): StartCompilerTransformResult | null;