@tanstack/start-plugin-core 1.169.11 → 1.169.13

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 (43) hide show
  1. package/dist/esm/index.d.ts +1 -1
  2. package/dist/esm/rsbuild/index.d.ts +1 -0
  3. package/dist/esm/rsbuild/plugin.js +2 -0
  4. package/dist/esm/rsbuild/plugin.js.map +1 -1
  5. package/dist/esm/rsbuild/schema.d.ts +27 -27
  6. package/dist/esm/rsbuild/start-compiler-host.d.ts +3 -1
  7. package/dist/esm/rsbuild/start-compiler-host.js +6 -2
  8. package/dist/esm/rsbuild/start-compiler-host.js.map +1 -1
  9. package/dist/esm/schema.d.ts +51 -51
  10. package/dist/esm/start-compiler/compiler.d.ts +21 -5
  11. package/dist/esm/start-compiler/compiler.js +197 -48
  12. package/dist/esm/start-compiler/compiler.js.map +1 -1
  13. package/dist/esm/start-compiler/config.d.ts +7 -3
  14. package/dist/esm/start-compiler/config.js +19 -7
  15. package/dist/esm/start-compiler/config.js.map +1 -1
  16. package/dist/esm/start-compiler/handleCreateServerFn.js +12 -0
  17. package/dist/esm/start-compiler/handleCreateServerFn.js.map +1 -1
  18. package/dist/esm/start-compiler/host.d.ts +3 -1
  19. package/dist/esm/start-compiler/host.js +5 -3
  20. package/dist/esm/start-compiler/host.js.map +1 -1
  21. package/dist/esm/start-compiler/types.d.ts +4 -13
  22. package/dist/esm/types.d.ts +33 -0
  23. package/dist/esm/vite/index.d.ts +1 -0
  24. package/dist/esm/vite/plugin.js +2 -0
  25. package/dist/esm/vite/plugin.js.map +1 -1
  26. package/dist/esm/vite/schema.d.ts +27 -27
  27. package/dist/esm/vite/start-compiler-plugin/plugin.d.ts +3 -1
  28. package/dist/esm/vite/start-compiler-plugin/plugin.js +6 -2
  29. package/dist/esm/vite/start-compiler-plugin/plugin.js.map +1 -1
  30. package/package.json +6 -6
  31. package/src/index.ts +6 -1
  32. package/src/rsbuild/index.ts +5 -0
  33. package/src/rsbuild/plugin.ts +3 -0
  34. package/src/rsbuild/start-compiler-host.ts +22 -3
  35. package/src/start-compiler/compiler.ts +389 -70
  36. package/src/start-compiler/config.ts +43 -6
  37. package/src/start-compiler/handleCreateServerFn.ts +29 -0
  38. package/src/start-compiler/host.ts +13 -3
  39. package/src/start-compiler/types.ts +5 -14
  40. package/src/types.ts +44 -0
  41. package/src/vite/index.ts +5 -0
  42. package/src/vite/plugin.ts +3 -0
  43. package/src/vite/start-compiler-plugin/plugin.ts +22 -3
@@ -11,7 +11,10 @@ import {
11
11
  import { cleanId } from '../start-compiler/utils'
12
12
  import { RSBUILD_ENVIRONMENT_NAMES } from './planning'
13
13
  import type { RsbuildPluginAPI, Rspack } from '@rsbuild/core'
14
- import type { CompileStartFrameworkOptions } from '../types'
14
+ import type {
15
+ CompileStartFrameworkOptions,
16
+ StartCompilerImportTransform,
17
+ } from '../types'
15
18
  import type {
16
19
  DevServerFnModuleSpecifierEncoder,
17
20
  GenerateFunctionIdFnOptional,
@@ -36,6 +39,8 @@ export interface StartCompilerHostOptions {
36
39
  root: string | (() => string)
37
40
  providerEnvName: string
38
41
  generateFunctionId?: GenerateFunctionIdFnOptional
42
+ compilerTransforms?: Array<StartCompilerImportTransform> | undefined
43
+ serverFnProviderModuleDirectives?: ReadonlyArray<string> | undefined
39
44
  serverFnsById?: Record<string, ServerFn>
40
45
  onServerFnsByIdChange?: () => void
41
46
  }
@@ -79,11 +84,21 @@ export function registerStartCompilerTransforms(
79
84
  // Pre-compute code filter patterns per environment type
80
85
  const codeFilters: Record<'client' | 'server', Array<RegExp>> = {
81
86
  client: getTransformCodeFilterForEnv('client'),
82
- server: getTransformCodeFilterForEnv('server'),
87
+ server: getTransformCodeFilterForEnv('server', {
88
+ compilerTransforms: opts.compilerTransforms,
89
+ }),
83
90
  }
84
91
 
85
92
  for (const env of environments) {
86
93
  const envCodeFilters = codeFilters[env.type]
94
+ const compilerTransforms =
95
+ env.name === RSBUILD_ENVIRONMENT_NAMES.server
96
+ ? opts.compilerTransforms
97
+ : undefined
98
+ const serverFnProviderModuleDirectives =
99
+ env.name === opts.providerEnvName
100
+ ? opts.serverFnProviderModuleDirectives
101
+ : undefined
87
102
 
88
103
  api.transform(
89
104
  {
@@ -113,6 +128,8 @@ export function registerStartCompilerTransforms(
113
128
  framework: opts.framework,
114
129
  providerEnvName: opts.providerEnvName,
115
130
  generateFunctionId: opts.generateFunctionId,
131
+ compilerTransforms,
132
+ serverFnProviderModuleDirectives,
116
133
  onServerFnsById,
117
134
  getKnownServerFns: () => serverFnsById,
118
135
  encodeModuleSpecifierInDev: isDev
@@ -180,7 +197,9 @@ export function registerStartCompilerTransforms(
180
197
  compilers.set(env.name, compiler)
181
198
  }
182
199
 
183
- const detectedKinds = detectKindsInCode(code, env.type)
200
+ const detectedKinds = detectKindsInCode(code, env.type, {
201
+ compilerTransforms,
202
+ })
184
203
  const result = await compiler.compile({ id, code, detectedKinds })
185
204
 
186
205
  if (!result) {