@tanstack/start-plugin-core 1.169.8 → 1.169.9

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.
@@ -1,6 +1,6 @@
1
1
  //#region src/start-compiler/server-fn-resolver-module.ts
2
2
  function getResolverManifestEntries(serverFnsById) {
3
- return Object.entries(serverFnsById).map(([id, fn]) => ({
3
+ return Object.entries(serverFnsById).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([id, fn]) => ({
4
4
  id,
5
5
  functionName: fn.functionName,
6
6
  extractedFilename: fn.extractedFilename,
@@ -1 +1 @@
1
- {"version":3,"file":"server-fn-resolver-module.js","names":[],"sources":["../../../src/start-compiler/server-fn-resolver-module.ts"],"sourcesContent":["import type { ServerFn } from './types'\n\ninterface ResolverManifestEntry {\n id: string\n functionName: string\n extractedFilename: string\n isClientReferenced: boolean\n}\n\ninterface GenerateServerFnResolverModuleOptions {\n serverFnsById: Record<string, ServerFn>\n includeClientReferencedCheck: boolean\n useStaticImports?: boolean\n}\n\nfunction getResolverManifestEntries(\n serverFnsById: Record<string, ServerFn>,\n): Array<ResolverManifestEntry> {\n return Object.entries(serverFnsById).map(([id, fn]) => ({\n id,\n functionName: fn.functionName,\n extractedFilename: fn.extractedFilename,\n isClientReferenced: fn.isClientReferenced ?? true,\n }))\n}\n\nfunction getClientReferencedCheck(\n includeClientReferencedCheck: boolean,\n): string {\n if (!includeClientReferencedCheck) {\n return ''\n }\n\n return `\n if (access.origin === 'client' && !serverFnInfo.isClientReferenced) {\n throw new Error('Server function not accessible from client: ' + id)\n }\n`\n}\n\nfunction getResolverBody(): string {\n return `\nexport async function getServerFnById(id, access) {\n const serverFnInfo = manifest[id]\n if (!serverFnInfo) {\n throw new Error('Server function info not found for ' + id)\n }\n__CLIENT_REFERENCED_CHECK__\n const fnModule = serverFnInfo.module ?? (await serverFnInfo.importer())\n if (!fnModule) {\n throw new Error('Server function module not resolved for ' + id)\n }\n const action = fnModule[serverFnInfo.functionName]\n if (!action) {\n throw new Error('Server function module export not resolved for serverFn ID: ' + id)\n }\n return action\n}\n`\n}\n\nfunction getResolverManifestModuleAccess(opts: {\n useStaticImports?: boolean\n extractedFilename: string\n moduleRef: string\n}): string {\n if (opts.useStaticImports) {\n return `module: ${opts.moduleRef}`\n }\n\n return `importer: () => import(${JSON.stringify(opts.extractedFilename)})`\n}\n\nfunction getResolverManifestEntry(opts: {\n entry: ResolverManifestEntry\n moduleAccess: string\n includeClientReferencedCheck: boolean\n}): string {\n const clientReferenced = opts.includeClientReferencedCheck\n ? `,\\n isClientReferenced: ${opts.entry.isClientReferenced}`\n : ''\n\n return `'${opts.entry.id}': {\n functionName: '${opts.entry.functionName}',\n ${opts.moduleAccess}${clientReferenced}\n }`\n}\n\nexport function generateServerFnResolverModule(\n opts: GenerateServerFnResolverModuleOptions,\n): string {\n const manifestEntries = getResolverManifestEntries(opts.serverFnsById)\n const staticImports: Array<string> = []\n\n const manifest = manifestEntries\n .map((entry, index) => {\n const moduleRef = `serverFnModule${index}`\n\n if (opts.useStaticImports) {\n staticImports.push(\n `import * as ${moduleRef} from ${JSON.stringify(entry.extractedFilename)}`,\n )\n }\n\n return getResolverManifestEntry({\n entry,\n moduleAccess: getResolverManifestModuleAccess({\n useStaticImports: opts.useStaticImports,\n extractedFilename: entry.extractedFilename,\n moduleRef,\n }),\n includeClientReferencedCheck: opts.includeClientReferencedCheck,\n })\n })\n .join(',\\n ')\n\n const body = getResolverBody().replace(\n '__CLIENT_REFERENCED_CHECK__',\n getClientReferencedCheck(opts.includeClientReferencedCheck),\n )\n\n return `\n${staticImports.join('\\n')}\nconst manifest = {\n ${manifest}\n}\n${body}\n`\n}\n"],"mappings":";AAeA,SAAS,2BACP,eAC8B;AAC9B,QAAO,OAAO,QAAQ,cAAc,CAAC,KAAK,CAAC,IAAI,SAAS;EACtD;EACA,cAAc,GAAG;EACjB,mBAAmB,GAAG;EACtB,oBAAoB,GAAG,sBAAsB;EAC9C,EAAE;;AAGL,SAAS,yBACP,8BACQ;AACR,KAAI,CAAC,6BACH,QAAO;AAGT,QAAO;;;;;;AAOT,SAAS,kBAA0B;AACjC,QAAO;;;;;;;;;;;;;;;;;;;AAoBT,SAAS,gCAAgC,MAI9B;AACT,KAAI,KAAK,iBACP,QAAO,WAAW,KAAK;AAGzB,QAAO,0BAA0B,KAAK,UAAU,KAAK,kBAAkB,CAAC;;AAG1E,SAAS,yBAAyB,MAIvB;CACT,MAAM,mBAAmB,KAAK,+BAC1B,8BAA8B,KAAK,MAAM,uBACzC;AAEJ,QAAO,IAAI,KAAK,MAAM,GAAG;qBACN,KAAK,MAAM,aAAa;MACvC,KAAK,eAAe,iBAAiB;;;AAI3C,SAAgB,+BACd,MACQ;CACR,MAAM,kBAAkB,2BAA2B,KAAK,cAAc;CACtE,MAAM,gBAA+B,EAAE;CAEvC,MAAM,WAAW,gBACd,KAAK,OAAO,UAAU;EACrB,MAAM,YAAY,iBAAiB;AAEnC,MAAI,KAAK,iBACP,eAAc,KACZ,eAAe,UAAU,QAAQ,KAAK,UAAU,MAAM,kBAAkB,GACzE;AAGH,SAAO,yBAAyB;GAC9B;GACA,cAAc,gCAAgC;IAC5C,kBAAkB,KAAK;IACvB,mBAAmB,MAAM;IACzB;IACD,CAAC;GACF,8BAA8B,KAAK;GACpC,CAAC;GACF,CACD,KAAK,QAAQ;CAEhB,MAAM,OAAO,iBAAiB,CAAC,QAC7B,+BACA,yBAAyB,KAAK,6BAA6B,CAC5D;AAED,QAAO;EACP,cAAc,KAAK,KAAK,CAAC;;IAEvB,SAAS;;EAEX,KAAK"}
1
+ {"version":3,"file":"server-fn-resolver-module.js","names":[],"sources":["../../../src/start-compiler/server-fn-resolver-module.ts"],"sourcesContent":["import type { ServerFn } from './types'\n\ninterface ResolverManifestEntry {\n id: string\n functionName: string\n extractedFilename: string\n isClientReferenced: boolean\n}\n\ninterface GenerateServerFnResolverModuleOptions {\n serverFnsById: Record<string, ServerFn>\n includeClientReferencedCheck: boolean\n useStaticImports?: boolean\n}\n\nfunction getResolverManifestEntries(\n serverFnsById: Record<string, ServerFn>,\n): Array<ResolverManifestEntry> {\n return (\n Object.entries(serverFnsById)\n // Sort entries by ID so that the generated manifest has a stable, deterministic order.\n // Non-deterministic ordering causes the compiled hash of the same source file to change\n // between builds, breaking content-addressed caching and reproducible deployments.\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([id, fn]) => ({\n id,\n functionName: fn.functionName,\n extractedFilename: fn.extractedFilename,\n isClientReferenced: fn.isClientReferenced ?? true,\n }))\n )\n}\n\nfunction getClientReferencedCheck(\n includeClientReferencedCheck: boolean,\n): string {\n if (!includeClientReferencedCheck) {\n return ''\n }\n\n return `\n if (access.origin === 'client' && !serverFnInfo.isClientReferenced) {\n throw new Error('Server function not accessible from client: ' + id)\n }\n`\n}\n\nfunction getResolverBody(): string {\n return `\nexport async function getServerFnById(id, access) {\n const serverFnInfo = manifest[id]\n if (!serverFnInfo) {\n throw new Error('Server function info not found for ' + id)\n }\n__CLIENT_REFERENCED_CHECK__\n const fnModule = serverFnInfo.module ?? (await serverFnInfo.importer())\n if (!fnModule) {\n throw new Error('Server function module not resolved for ' + id)\n }\n const action = fnModule[serverFnInfo.functionName]\n if (!action) {\n throw new Error('Server function module export not resolved for serverFn ID: ' + id)\n }\n return action\n}\n`\n}\n\nfunction getResolverManifestModuleAccess(opts: {\n useStaticImports?: boolean\n extractedFilename: string\n moduleRef: string\n}): string {\n if (opts.useStaticImports) {\n return `module: ${opts.moduleRef}`\n }\n\n return `importer: () => import(${JSON.stringify(opts.extractedFilename)})`\n}\n\nfunction getResolverManifestEntry(opts: {\n entry: ResolverManifestEntry\n moduleAccess: string\n includeClientReferencedCheck: boolean\n}): string {\n const clientReferenced = opts.includeClientReferencedCheck\n ? `,\\n isClientReferenced: ${opts.entry.isClientReferenced}`\n : ''\n\n return `'${opts.entry.id}': {\n functionName: '${opts.entry.functionName}',\n ${opts.moduleAccess}${clientReferenced}\n }`\n}\n\nexport function generateServerFnResolverModule(\n opts: GenerateServerFnResolverModuleOptions,\n): string {\n const manifestEntries = getResolverManifestEntries(opts.serverFnsById)\n const staticImports: Array<string> = []\n\n const manifest = manifestEntries\n .map((entry, index) => {\n const moduleRef = `serverFnModule${index}`\n\n if (opts.useStaticImports) {\n staticImports.push(\n `import * as ${moduleRef} from ${JSON.stringify(entry.extractedFilename)}`,\n )\n }\n\n return getResolverManifestEntry({\n entry,\n moduleAccess: getResolverManifestModuleAccess({\n useStaticImports: opts.useStaticImports,\n extractedFilename: entry.extractedFilename,\n moduleRef,\n }),\n includeClientReferencedCheck: opts.includeClientReferencedCheck,\n })\n })\n .join(',\\n ')\n\n const body = getResolverBody().replace(\n '__CLIENT_REFERENCED_CHECK__',\n getClientReferencedCheck(opts.includeClientReferencedCheck),\n )\n\n return `\n${staticImports.join('\\n')}\nconst manifest = {\n ${manifest}\n}\n${body}\n`\n}\n"],"mappings":";AAeA,SAAS,2BACP,eAC8B;AAC9B,QACE,OAAO,QAAQ,cAAc,CAI1B,MAAM,CAAC,IAAI,CAAC,OAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,EAAG,CAChD,KAAK,CAAC,IAAI,SAAS;EAClB;EACA,cAAc,GAAG;EACjB,mBAAmB,GAAG;EACtB,oBAAoB,GAAG,sBAAsB;EAC9C,EAAE;;AAIT,SAAS,yBACP,8BACQ;AACR,KAAI,CAAC,6BACH,QAAO;AAGT,QAAO;;;;;;AAOT,SAAS,kBAA0B;AACjC,QAAO;;;;;;;;;;;;;;;;;;;AAoBT,SAAS,gCAAgC,MAI9B;AACT,KAAI,KAAK,iBACP,QAAO,WAAW,KAAK;AAGzB,QAAO,0BAA0B,KAAK,UAAU,KAAK,kBAAkB,CAAC;;AAG1E,SAAS,yBAAyB,MAIvB;CACT,MAAM,mBAAmB,KAAK,+BAC1B,8BAA8B,KAAK,MAAM,uBACzC;AAEJ,QAAO,IAAI,KAAK,MAAM,GAAG;qBACN,KAAK,MAAM,aAAa;MACvC,KAAK,eAAe,iBAAiB;;;AAI3C,SAAgB,+BACd,MACQ;CACR,MAAM,kBAAkB,2BAA2B,KAAK,cAAc;CACtE,MAAM,gBAA+B,EAAE;CAEvC,MAAM,WAAW,gBACd,KAAK,OAAO,UAAU;EACrB,MAAM,YAAY,iBAAiB;AAEnC,MAAI,KAAK,iBACP,eAAc,KACZ,eAAe,UAAU,QAAQ,KAAK,UAAU,MAAM,kBAAkB,GACzE;AAGH,SAAO,yBAAyB;GAC9B;GACA,cAAc,gCAAgC;IAC5C,kBAAkB,KAAK;IACvB,mBAAmB,MAAM;IACzB;IACD,CAAC;GACF,8BAA8B,KAAK;GACpC,CAAC;GACF,CACD,KAAK,QAAQ;CAEhB,MAAM,OAAO,iBAAiB,CAAC,QAC7B,+BACA,yBAAyB,KAAK,6BAA6B,CAC5D;AAED,QAAO;EACP,cAAc,KAAK,KAAK,CAAC;;IAEvB,SAAS;;EAEX,KAAK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/start-plugin-core",
3
- "version": "1.169.8",
3
+ "version": "1.169.9",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -16,12 +16,19 @@ interface GenerateServerFnResolverModuleOptions {
16
16
  function getResolverManifestEntries(
17
17
  serverFnsById: Record<string, ServerFn>,
18
18
  ): Array<ResolverManifestEntry> {
19
- return Object.entries(serverFnsById).map(([id, fn]) => ({
20
- id,
21
- functionName: fn.functionName,
22
- extractedFilename: fn.extractedFilename,
23
- isClientReferenced: fn.isClientReferenced ?? true,
24
- }))
19
+ return (
20
+ Object.entries(serverFnsById)
21
+ // Sort entries by ID so that the generated manifest has a stable, deterministic order.
22
+ // Non-deterministic ordering causes the compiled hash of the same source file to change
23
+ // between builds, breaking content-addressed caching and reproducible deployments.
24
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
25
+ .map(([id, fn]) => ({
26
+ id,
27
+ functionName: fn.functionName,
28
+ extractedFilename: fn.extractedFilename,
29
+ isClientReferenced: fn.isClientReferenced ?? true,
30
+ }))
31
+ )
25
32
  }
26
33
 
27
34
  function getClientReferencedCheck(