@tanstack/start-plugin-core 1.121.0-alpha.2 → 1.121.0-alpha.21

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 (137) hide show
  1. package/dist/cjs/constants.cjs +4 -0
  2. package/dist/cjs/constants.cjs.map +1 -1
  3. package/dist/cjs/constants.d.cts +2 -0
  4. package/dist/cjs/{extractHtmlScripts.cjs → dev-server-plugin/extract-html-scripts.cjs} +1 -1
  5. package/dist/cjs/dev-server-plugin/extract-html-scripts.cjs.map +1 -0
  6. package/dist/cjs/{nitro/dev-server-plugin.cjs → dev-server-plugin/plugin.cjs} +2 -2
  7. package/dist/cjs/dev-server-plugin/plugin.cjs.map +1 -0
  8. package/dist/cjs/index.cjs +2 -0
  9. package/dist/cjs/index.cjs.map +1 -1
  10. package/dist/cjs/index.d.cts +1 -0
  11. package/dist/cjs/load-env-plugin/plugin.cjs +34 -0
  12. package/dist/cjs/load-env-plugin/plugin.cjs.map +1 -0
  13. package/dist/cjs/load-env-plugin/plugin.d.cts +3 -0
  14. package/dist/cjs/nitro-plugin/build-sitemap.cjs +138 -0
  15. package/dist/cjs/nitro-plugin/build-sitemap.cjs.map +1 -0
  16. package/dist/cjs/nitro-plugin/build-sitemap.d.cts +31 -0
  17. package/dist/cjs/{nitro/nitro-plugin.cjs → nitro-plugin/plugin.cjs} +77 -54
  18. package/dist/cjs/nitro-plugin/plugin.cjs.map +1 -0
  19. package/dist/cjs/{prerender.cjs → nitro-plugin/prerender.cjs} +12 -17
  20. package/dist/cjs/nitro-plugin/prerender.cjs.map +1 -0
  21. package/dist/cjs/{prerender.d.cts → nitro-plugin/prerender.d.cts} +1 -1
  22. package/dist/cjs/nitro-plugin/queue.cjs.map +1 -0
  23. package/dist/cjs/plugin.cjs +38 -27
  24. package/dist/cjs/plugin.cjs.map +1 -1
  25. package/dist/cjs/plugin.d.cts +25 -3064
  26. package/dist/cjs/resolve-virtual-entries-plugin/plugin.cjs +66 -0
  27. package/dist/cjs/resolve-virtual-entries-plugin/plugin.cjs.map +1 -0
  28. package/dist/cjs/resolve-virtual-entries-plugin/plugin.d.cts +3 -0
  29. package/dist/cjs/schema.cjs +6 -4
  30. package/dist/cjs/schema.cjs.map +1 -1
  31. package/dist/cjs/schema.d.cts +530 -1656
  32. package/dist/cjs/start-compiler-plugin.cjs +2 -2
  33. package/dist/cjs/start-compiler-plugin.cjs.map +1 -1
  34. package/dist/cjs/start-compiler-plugin.d.cts +1 -1
  35. package/dist/cjs/{routesManifestPlugin.cjs → start-routes-manifest-plugin/plugin.cjs} +86 -44
  36. package/dist/cjs/start-routes-manifest-plugin/plugin.cjs.map +1 -0
  37. package/dist/cjs/start-routes-manifest-plugin/plugin.d.cts +3 -0
  38. package/dist/cjs/start-server-routes-plugin/plugin.cjs +4 -2
  39. package/dist/cjs/start-server-routes-plugin/plugin.cjs.map +1 -1
  40. package/dist/cjs/utils.cjs +18 -0
  41. package/dist/cjs/utils.cjs.map +1 -0
  42. package/dist/cjs/utils.d.cts +8 -0
  43. package/dist/esm/constants.d.ts +2 -0
  44. package/dist/esm/constants.js +4 -0
  45. package/dist/esm/constants.js.map +1 -1
  46. package/dist/esm/{extractHtmlScripts.js → dev-server-plugin/extract-html-scripts.js} +1 -1
  47. package/dist/esm/dev-server-plugin/extract-html-scripts.js.map +1 -0
  48. package/dist/esm/{nitro/dev-server-plugin.js → dev-server-plugin/plugin.js} +2 -2
  49. package/dist/esm/dev-server-plugin/plugin.js.map +1 -0
  50. package/dist/esm/index.d.ts +1 -0
  51. package/dist/esm/index.js +3 -1
  52. package/dist/esm/index.js.map +1 -1
  53. package/dist/esm/load-env-plugin/plugin.d.ts +3 -0
  54. package/dist/esm/load-env-plugin/plugin.js +17 -0
  55. package/dist/esm/load-env-plugin/plugin.js.map +1 -0
  56. package/dist/esm/nitro-plugin/build-sitemap.d.ts +31 -0
  57. package/dist/esm/nitro-plugin/build-sitemap.js +138 -0
  58. package/dist/esm/nitro-plugin/build-sitemap.js.map +1 -0
  59. package/dist/esm/nitro-plugin/plugin.js +181 -0
  60. package/dist/esm/nitro-plugin/plugin.js.map +1 -0
  61. package/dist/esm/{prerender.d.ts → nitro-plugin/prerender.d.ts} +1 -1
  62. package/dist/esm/{prerender.js → nitro-plugin/prerender.js} +12 -17
  63. package/dist/esm/nitro-plugin/prerender.js.map +1 -0
  64. package/dist/esm/nitro-plugin/queue.js.map +1 -0
  65. package/dist/esm/plugin.d.ts +25 -3064
  66. package/dist/esm/plugin.js +39 -28
  67. package/dist/esm/plugin.js.map +1 -1
  68. package/dist/esm/resolve-virtual-entries-plugin/plugin.d.ts +3 -0
  69. package/dist/esm/resolve-virtual-entries-plugin/plugin.js +49 -0
  70. package/dist/esm/resolve-virtual-entries-plugin/plugin.js.map +1 -0
  71. package/dist/esm/schema.d.ts +530 -1656
  72. package/dist/esm/schema.js +6 -4
  73. package/dist/esm/schema.js.map +1 -1
  74. package/dist/esm/start-compiler-plugin.d.ts +1 -1
  75. package/dist/esm/start-compiler-plugin.js +2 -2
  76. package/dist/esm/start-compiler-plugin.js.map +1 -1
  77. package/dist/esm/start-routes-manifest-plugin/plugin.d.ts +3 -0
  78. package/dist/esm/{routesManifestPlugin.js → start-routes-manifest-plugin/plugin.js} +87 -45
  79. package/dist/esm/start-routes-manifest-plugin/plugin.js.map +1 -0
  80. package/dist/esm/start-server-routes-plugin/plugin.js +4 -2
  81. package/dist/esm/start-server-routes-plugin/plugin.js.map +1 -1
  82. package/dist/esm/utils.d.ts +8 -0
  83. package/dist/esm/utils.js +18 -0
  84. package/dist/esm/utils.js.map +1 -0
  85. package/package.json +6 -6
  86. package/src/constants.ts +3 -0
  87. package/src/{nitro/dev-server-plugin.ts → dev-server-plugin/plugin.ts} +11 -1
  88. package/src/index.ts +1 -0
  89. package/src/load-env-plugin/plugin.ts +17 -0
  90. package/src/nitro-plugin/build-sitemap.ts +213 -0
  91. package/src/nitro-plugin/plugin.ts +244 -0
  92. package/src/{prerender.ts → nitro-plugin/prerender.ts} +14 -21
  93. package/src/plugin.ts +57 -29
  94. package/src/resolve-virtual-entries-plugin/plugin.ts +63 -0
  95. package/src/schema.ts +11 -9
  96. package/src/start-compiler-plugin.ts +1 -1
  97. package/src/{routesManifestPlugin.ts → start-routes-manifest-plugin/plugin.ts} +111 -45
  98. package/src/start-server-routes-plugin/plugin.ts +4 -2
  99. package/src/utils.ts +14 -0
  100. package/dist/cjs/extractHtmlScripts.cjs.map +0 -1
  101. package/dist/cjs/nitro/build-nitro.cjs +0 -18
  102. package/dist/cjs/nitro/build-nitro.cjs.map +0 -1
  103. package/dist/cjs/nitro/build-nitro.d.cts +0 -2
  104. package/dist/cjs/nitro/build-sitemap.d.cts +0 -9
  105. package/dist/cjs/nitro/dev-server-plugin.cjs.map +0 -1
  106. package/dist/cjs/nitro/nitro-plugin.cjs.map +0 -1
  107. package/dist/cjs/prerender.cjs.map +0 -1
  108. package/dist/cjs/queue.cjs.map +0 -1
  109. package/dist/cjs/routesManifestPlugin.cjs.map +0 -1
  110. package/dist/cjs/routesManifestPlugin.d.cts +0 -3
  111. package/dist/esm/extractHtmlScripts.js.map +0 -1
  112. package/dist/esm/nitro/build-nitro.d.ts +0 -2
  113. package/dist/esm/nitro/build-nitro.js +0 -18
  114. package/dist/esm/nitro/build-nitro.js.map +0 -1
  115. package/dist/esm/nitro/build-sitemap.d.ts +0 -9
  116. package/dist/esm/nitro/dev-server-plugin.js.map +0 -1
  117. package/dist/esm/nitro/nitro-plugin.js +0 -158
  118. package/dist/esm/nitro/nitro-plugin.js.map +0 -1
  119. package/dist/esm/prerender.js.map +0 -1
  120. package/dist/esm/queue.js.map +0 -1
  121. package/dist/esm/routesManifestPlugin.d.ts +0 -3
  122. package/dist/esm/routesManifestPlugin.js.map +0 -1
  123. package/src/nitro/build-nitro.ts +0 -27
  124. package/src/nitro/build-sitemap.ts +0 -79
  125. package/src/nitro/nitro-plugin.ts +0 -199
  126. /package/dist/cjs/{extractHtmlScripts.d.cts → dev-server-plugin/extract-html-scripts.d.cts} +0 -0
  127. /package/dist/cjs/{nitro/dev-server-plugin.d.cts → dev-server-plugin/plugin.d.cts} +0 -0
  128. /package/dist/cjs/{nitro/nitro-plugin.d.cts → nitro-plugin/plugin.d.cts} +0 -0
  129. /package/dist/cjs/{queue.cjs → nitro-plugin/queue.cjs} +0 -0
  130. /package/dist/cjs/{queue.d.cts → nitro-plugin/queue.d.cts} +0 -0
  131. /package/dist/esm/{extractHtmlScripts.d.ts → dev-server-plugin/extract-html-scripts.d.ts} +0 -0
  132. /package/dist/esm/{nitro/dev-server-plugin.d.ts → dev-server-plugin/plugin.d.ts} +0 -0
  133. /package/dist/esm/{nitro/nitro-plugin.d.ts → nitro-plugin/plugin.d.ts} +0 -0
  134. /package/dist/esm/{queue.d.ts → nitro-plugin/queue.d.ts} +0 -0
  135. /package/dist/esm/{queue.js → nitro-plugin/queue.js} +0 -0
  136. /package/src/{extractHtmlScripts.ts → dev-server-plugin/extract-html-scripts.ts} +0 -0
  137. /package/src/{queue.ts → nitro-plugin/queue.ts} +0 -0
@@ -2,7 +2,7 @@ import path from "node:path";
2
2
  import { existsSync } from "node:fs";
3
3
  import { z } from "zod";
4
4
  import { configSchema, getConfig } from "@tanstack/router-generator";
5
- const tsrConfig = configSchema.partial().extend({
5
+ const tsrConfig = configSchema.omit({ autoCodeSplitting: true }).partial().extend({
6
6
  srcDirectory: z.string().optional().default("src")
7
7
  });
8
8
  function createTanStackConfig(frameworkPlugin) {
@@ -74,9 +74,11 @@ function createTanStackStartOptionsSchema(frameworkPlugin = {}) {
74
74
  dir: z.string().optional().default("public"),
75
75
  base: z.string().optional().default("/")
76
76
  }).optional().default({}),
77
- pages: z.array(z.union([z.string(), pageSchema])).optional().default([]),
78
- sitemap: pagePrerenderOptionsSchema.extend({
79
- host: z.string().optional()
77
+ pages: z.array(pageSchema).optional().default([]),
78
+ sitemap: z.object({
79
+ enabled: z.boolean().optional().default(true),
80
+ host: z.string().optional(),
81
+ outputPath: z.string().optional().default("sitemap.xml")
80
82
  }).optional(),
81
83
  prerender: z.object({
82
84
  enabled: z.boolean().optional(),
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sources":["../../src/schema.ts"],"sourcesContent":["import path from 'node:path'\nimport { existsSync } from 'node:fs'\nimport { z } from 'zod'\nimport { configSchema, getConfig } from '@tanstack/router-generator'\nimport type { NitroConfig } from 'nitropack'\n\nconst tsrConfig = configSchema.partial().extend({\n srcDirectory: z.string().optional().default('src'),\n})\n\nexport function createTanStackConfig<\n TFrameworkPlugin extends Record<string, unknown>,\n>(frameworkPlugin?: TFrameworkPlugin) {\n const schema = createTanStackStartOptionsSchema(frameworkPlugin)\n\n return {\n schema,\n parse: (opts?: z.input<typeof schema>) => {\n const options = schema.parse(opts)\n\n const srcDirectory = options.tsr.srcDirectory\n\n const routesDirectory =\n options.tsr.routesDirectory ?? path.join(srcDirectory, 'routes')\n\n const generatedRouteTree =\n options.tsr.generatedRouteTree ??\n path.join(srcDirectory, 'routeTree.gen.ts')\n\n const clientEntryPath = (() => {\n if (options.client.entry) {\n return path.join(srcDirectory, options.client.entry)\n }\n\n if (existsSync(path.join(srcDirectory, 'client.tsx'))) {\n return path.join(srcDirectory, 'client.tsx')\n }\n\n return '/~start/default-client-entry'\n })()\n\n const serverEntryPath = (() => {\n if (options.server.entry) {\n return path.join(srcDirectory, options.server.entry)\n }\n\n if (existsSync(path.join(srcDirectory, 'server.tsx'))) {\n return path.join(srcDirectory, 'server.tsx')\n }\n\n if (existsSync(path.join(srcDirectory, 'server.ts'))) {\n return path.join(srcDirectory, 'server.ts')\n }\n\n if (existsSync(path.join(srcDirectory, 'server.js'))) {\n return path.join(srcDirectory, 'server.js')\n }\n\n return '/~start/default-server-entry'\n })()\n\n return {\n ...options,\n tsr: {\n ...options.tsr,\n ...getConfig({\n ...options.tsr,\n routesDirectory,\n generatedRouteTree,\n }),\n },\n clientEntryPath,\n serverEntryPath,\n }\n },\n }\n}\n\nexport function createTanStackStartOptionsSchema(\n frameworkPlugin: Record<string, unknown> = {},\n) {\n return z\n .object({\n root: z.string().optional().default(process.cwd()),\n target: z.custom<NitroConfig['preset']>().optional(),\n ...frameworkPlugin,\n tsr: tsrConfig.optional().default({}),\n client: z\n .object({\n entry: z.string().optional(),\n base: z.string().optional().default('/_build'),\n })\n .optional()\n .default({}),\n server: z\n .object({\n entry: z.string().optional(),\n })\n .optional()\n .default({}),\n serverFns: z\n .object({\n base: z.string().optional().default('/_serverFn'),\n })\n .optional()\n .default({}),\n public: z\n .object({\n dir: z.string().optional().default('public'),\n base: z.string().optional().default('/'),\n })\n .optional()\n .default({}),\n pages: z\n .array(z.union([z.string(), pageSchema]))\n .optional()\n .default([]),\n sitemap: pagePrerenderOptionsSchema\n .extend({\n host: z.string().optional(),\n })\n .optional(),\n prerender: z\n .object({\n enabled: z.boolean().optional(),\n concurrency: z.number().optional(),\n filter: z.function().args(pageSchema).returns(z.any()).optional(),\n failOnError: z.boolean().optional(),\n })\n .and(pagePrerenderOptionsSchema.optional())\n .optional(),\n spa: spaSchema.optional(),\n })\n .optional()\n .default({})\n}\n\nconst pageSitemapOptionsSchema = z.object({\n exclude: z.boolean().optional(),\n priority: z.number().min(0).max(1).optional(),\n changefreq: z\n .enum(['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'])\n .optional(),\n lastmod: z.union([z.string(), z.date()]).optional(),\n alternateRefs: z\n .array(\n z.object({\n href: z.string(),\n hreflang: z.string(),\n }),\n )\n .optional(),\n images: z\n .array(\n z.object({\n loc: z.string(),\n caption: z.string().optional(),\n title: z.string().optional(),\n }),\n )\n .optional(),\n news: z\n .object({\n publication: z.object({\n name: z.string(),\n language: z.string(),\n }),\n publicationDate: z.union([z.string(), z.date()]),\n title: z.string(),\n })\n .optional(),\n})\n\nconst pageBaseSchema = z.object({\n path: z.string(),\n sitemap: pageSitemapOptionsSchema.optional(),\n fromCrawl: z.boolean().optional(),\n})\n\nconst pagePrerenderOptionsSchema = z.object({\n enabled: z.boolean().optional(),\n outputPath: z.string().optional(),\n autoSubfolderIndex: z.boolean().optional(),\n crawlLinks: z.boolean().optional(),\n retryCount: z.number().optional(),\n retryDelay: z.number().optional(),\n onSuccess: z\n .function()\n .args(\n z.object({\n page: pageBaseSchema,\n html: z.string(),\n }),\n )\n .returns(z.any())\n .optional(),\n})\n\nconst spaSchema = z.object({\n enabled: z.boolean().optional().default(true),\n maskPath: z.string().optional().default('/'),\n prerender: pagePrerenderOptionsSchema\n .optional()\n .default({})\n .transform((opts) => ({\n outputPath: opts.outputPath ?? '/_shell',\n crawlLinks: false,\n retryCount: 0,\n ...opts,\n enabled: true,\n })),\n})\n\nexport const pageSchema = pageBaseSchema.extend({\n prerender: pagePrerenderOptionsSchema.optional(),\n})\n\nexport type Page = z.infer<typeof pageSchema>\n"],"names":[],"mappings":";;;;AAMA,MAAM,YAAY,aAAa,QAAQ,EAAE,OAAO;AAAA,EAC9C,cAAc,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,KAAK;AACnD,CAAC;AAEM,SAAS,qBAEd,iBAAoC;AAC9B,QAAA,SAAS,iCAAiC,eAAe;AAExD,SAAA;AAAA,IACL;AAAA,IACA,OAAO,CAAC,SAAkC;AAClC,YAAA,UAAU,OAAO,MAAM,IAAI;AAE3B,YAAA,eAAe,QAAQ,IAAI;AAEjC,YAAM,kBACJ,QAAQ,IAAI,mBAAmB,KAAK,KAAK,cAAc,QAAQ;AAEjE,YAAM,qBACJ,QAAQ,IAAI,sBACZ,KAAK,KAAK,cAAc,kBAAkB;AAE5C,YAAM,mBAAmB,MAAM;AACzB,YAAA,QAAQ,OAAO,OAAO;AACxB,iBAAO,KAAK,KAAK,cAAc,QAAQ,OAAO,KAAK;AAAA,QAAA;AAGrD,YAAI,WAAW,KAAK,KAAK,cAAc,YAAY,CAAC,GAAG;AAC9C,iBAAA,KAAK,KAAK,cAAc,YAAY;AAAA,QAAA;AAGtC,eAAA;AAAA,MAAA,GACN;AAEH,YAAM,mBA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AI,CAAC,EACf,SAAS;AACd,CAAC;AAED,MAAM,YAAY,EAAE,OAAO;AAAA,EACzB,SAAS,EAAE,QAAA,EAAU,SAAS,EAAE,QAAQ,IAAI;AAAA,EAC5C,UAAU,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,GAAG;AAAA,EAC3C,WAAW,2BACR,WACA,QAAQ,CAAA,CAAE,EACV,UAAU,CAAC,UAAU;AAAA,IACpB,YAAY,KAAK,cAAc;AAAA,IAC/B,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,GAAG;AAAA,IACH,SAAS;AAAA,EAAA,EACT;AACN,CAAC;AAEY,MAAA,aAAa,eAAe,OAAO;AAAA,EAC9C,WAAW,2BAA2B,SAAS;AACjD,CAAC;"}
1
+ {"version":3,"file":"schema.js","sources":["../../src/schema.ts"],"sourcesContent":["import path from 'node:path'\nimport { existsSync } from 'node:fs'\nimport { z } from 'zod'\nimport { configSchema, getConfig } from '@tanstack/router-generator'\nimport type { NitroConfig } from 'nitropack'\n\nconst tsrConfig = configSchema\n .omit({ autoCodeSplitting: true })\n .partial()\n .extend({\n srcDirectory: z.string().optional().default('src'),\n })\n\nexport function createTanStackConfig<\n TFrameworkPlugin extends Record<string, unknown>,\n>(frameworkPlugin?: TFrameworkPlugin) {\n const schema = createTanStackStartOptionsSchema(frameworkPlugin)\n\n return {\n schema,\n parse: (opts?: z.input<typeof schema>) => {\n const options = schema.parse(opts)\n\n const srcDirectory = options.tsr.srcDirectory\n\n const routesDirectory =\n options.tsr.routesDirectory ?? path.join(srcDirectory, 'routes')\n\n const generatedRouteTree =\n options.tsr.generatedRouteTree ??\n path.join(srcDirectory, 'routeTree.gen.ts')\n\n const clientEntryPath = (() => {\n if (options.client.entry) {\n return path.join(srcDirectory, options.client.entry)\n }\n\n if (existsSync(path.join(srcDirectory, 'client.tsx'))) {\n return path.join(srcDirectory, 'client.tsx')\n }\n\n return '/~start/default-client-entry'\n })()\n\n const serverEntryPath = (() => {\n if (options.server.entry) {\n return path.join(srcDirectory, options.server.entry)\n }\n\n if (existsSync(path.join(srcDirectory, 'server.tsx'))) {\n return path.join(srcDirectory, 'server.tsx')\n }\n\n if (existsSync(path.join(srcDirectory, 'server.ts'))) {\n return path.join(srcDirectory, 'server.ts')\n }\n\n if (existsSync(path.join(srcDirectory, 'server.js'))) {\n return path.join(srcDirectory, 'server.js')\n }\n\n return '/~start/default-server-entry'\n })()\n\n return {\n ...options,\n tsr: {\n ...options.tsr,\n ...getConfig({\n ...options.tsr,\n routesDirectory,\n generatedRouteTree,\n }),\n },\n clientEntryPath,\n serverEntryPath,\n }\n },\n }\n}\n\nexport function createTanStackStartOptionsSchema(\n frameworkPlugin: Record<string, unknown> = {},\n) {\n return z\n .object({\n root: z.string().optional().default(process.cwd()),\n target: z.custom<NitroConfig['preset']>().optional(),\n ...frameworkPlugin,\n tsr: tsrConfig.optional().default({}),\n client: z\n .object({\n entry: z.string().optional(),\n base: z.string().optional().default('/_build'),\n })\n .optional()\n .default({}),\n server: z\n .object({\n entry: z.string().optional(),\n })\n .optional()\n .default({}),\n serverFns: z\n .object({\n base: z.string().optional().default('/_serverFn'),\n })\n .optional()\n .default({}),\n public: z\n .object({\n dir: z.string().optional().default('public'),\n base: z.string().optional().default('/'),\n })\n .optional()\n .default({}),\n pages: z.array(pageSchema).optional().default([]),\n sitemap: z\n .object({\n enabled: z.boolean().optional().default(true),\n host: z.string().optional(),\n outputPath: z.string().optional().default('sitemap.xml'),\n })\n .optional(),\n prerender: z\n .object({\n enabled: z.boolean().optional(),\n concurrency: z.number().optional(),\n filter: z.function().args(pageSchema).returns(z.any()).optional(),\n failOnError: z.boolean().optional(),\n })\n .and(pagePrerenderOptionsSchema.optional())\n .optional(),\n spa: spaSchema.optional(),\n })\n .optional()\n .default({})\n}\n\nconst pageSitemapOptionsSchema = z.object({\n exclude: z.boolean().optional(),\n priority: z.number().min(0).max(1).optional(),\n changefreq: z\n .enum(['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'])\n .optional(),\n lastmod: z.union([z.string(), z.date()]).optional(),\n alternateRefs: z\n .array(\n z.object({\n href: z.string(),\n hreflang: z.string(),\n }),\n )\n .optional(),\n images: z\n .array(\n z.object({\n loc: z.string(),\n caption: z.string().optional(),\n title: z.string().optional(),\n }),\n )\n .optional(),\n news: z\n .object({\n publication: z.object({\n name: z.string(),\n language: z.string(),\n }),\n publicationDate: z.union([z.string(), z.date()]),\n title: z.string(),\n })\n .optional(),\n})\n\nconst pageBaseSchema = z.object({\n path: z.string(),\n sitemap: pageSitemapOptionsSchema.optional(),\n fromCrawl: z.boolean().optional(),\n})\n\nconst pagePrerenderOptionsSchema = z.object({\n enabled: z.boolean().optional(),\n outputPath: z.string().optional(),\n autoSubfolderIndex: z.boolean().optional(),\n crawlLinks: z.boolean().optional(),\n retryCount: z.number().optional(),\n retryDelay: z.number().optional(),\n onSuccess: z\n .function()\n .args(\n z.object({\n page: pageBaseSchema,\n html: z.string(),\n }),\n )\n .returns(z.any())\n .optional(),\n})\n\nconst spaSchema = z.object({\n enabled: z.boolean().optional().default(true),\n maskPath: z.string().optional().default('/'),\n prerender: pagePrerenderOptionsSchema\n .optional()\n .default({})\n .transform((opts) => ({\n outputPath: opts.outputPath ?? '/_shell',\n crawlLinks: false,\n retryCount: 0,\n ...opts,\n enabled: true,\n })),\n})\n\nexport const pageSchema = pageBaseSchema.extend({\n prerender: pagePrerenderOptionsSchema.optional(),\n})\n\nexport type Page = z.infer<typeof pageSchema>\n"],"names":[],"mappings":";;;;AAMA,MAAM,YAAY,aACf,KAAK,EAAE,mBAAmB,MAAM,EAChC,QAAQ,EACR,OAAO;AAAA,EACN,cAAc,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,KAAK;AACnD,CAAC;AAEI,SAAS,qBAEd,iBAAoC;AAC9B,QAAA,SAAS,iCAAiC,eAAe;AAExD,SAAA;AAAA,IACL;AAAA,IACA,OAAO,CAAC,SAAkC;AAClC,YAAA,UAAU,OAAO,MAAM,IA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ACf,SAAS,yBAAyB,SAAS;AAAA,EAC3C,WAAW,EAAE,QAAQ,EAAE,SAAS;AAClC,CAAC;AAED,MAAM,6BAA6B,EAAE,OAAO;AAAA,EAC1C,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC9B,YAAY,EAAE,OAAO,EAAE,SAAS;AAAA,EAChC,oBAAoB,EAAE,QAAQ,EAAE,SAAS;AAAA,EACzC,YAAY,EAAE,QAAQ,EAAE,SAAS;AAAA,EACjC,YAAY,EAAE,OAAO,EAAE,SAAS;AAAA,EAChC,YAAY,EAAE,OAAO,EAAE,SAAS;AAAA,EAChC,WAAW,EACR,SAAA,EACA;AAAA,IACC,EAAE,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM,EAAE,OAAO;AAAA,IAChB,CAAA;AAAA,IAEF,QAAQ,EAAE,IAAI,CAAC,EACf,SAAS;AACd,CAAC;AAED,MAAM,YAAY,EAAE,OAAO;AAAA,EACzB,SAAS,EAAE,QAAA,EAAU,SAAS,EAAE,QAAQ,IAAI;AAAA,EAC5C,UAAU,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,GAAG;AAAA,EAC3C,WAAW,2BACR,WACA,QAAQ,CAAA,CAAE,EACV,UAAU,CAAC,UAAU;AAAA,IACpB,YAAY,KAAK,cAAc;AAAA,IAC/B,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,GAAG;AAAA,IACH,SAAS;AAAA,EAAA,EACT;AACN,CAAC;AAEY,MAAA,aAAa,eAAe,OAAO;AAAA,EAC9C,WAAW,2BAA2B,SAAS;AACjD,CAAC;"}
@@ -3,7 +3,7 @@ import { CompileStartFrameworkOptions } from './compilers.js';
3
3
  export type TanStackStartViteOptions = {
4
4
  globalMiddlewareEntry: string;
5
5
  };
6
- export declare function TanStackStartCompilerPlugin(framework: CompileStartFrameworkOptions, inputOpts?: {
6
+ export declare function startCompilerPlugin(framework: CompileStartFrameworkOptions, inputOpts?: {
7
7
  client?: {
8
8
  envName?: string;
9
9
  };
@@ -11,7 +11,7 @@ const transformFuncs = [
11
11
  "createServerFileRoute"
12
12
  ];
13
13
  const tokenRegex = new RegExp(transformFuncs.join("|"));
14
- function TanStackStartCompilerPlugin(framework, inputOpts) {
14
+ function startCompilerPlugin(framework, inputOpts) {
15
15
  const opts = {
16
16
  client: {
17
17
  envName: "client",
@@ -67,6 +67,6 @@ function transformCode(opts) {
67
67
  return compiled;
68
68
  }
69
69
  export {
70
- TanStackStartCompilerPlugin
70
+ startCompilerPlugin
71
71
  };
72
72
  //# sourceMappingURL=start-compiler-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"start-compiler-plugin.js","sources":["../../src/start-compiler-plugin.ts"],"sourcesContent":["import { fileURLToPath, pathToFileURL } from 'node:url'\nimport { logDiff } from '@tanstack/router-utils'\n\nimport { compileStartOutputFactory } from './compilers'\nimport type { Plugin } from 'vite'\nimport type { CompileStartFrameworkOptions } from './compilers'\n\nconst debug =\n process.env.TSR_VITE_DEBUG &&\n ['true', 'start-plugin'].includes(process.env.TSR_VITE_DEBUG)\n\nexport type TanStackStartViteOptions = {\n globalMiddlewareEntry: string\n}\n\nconst transformFuncs = [\n 'createServerFn',\n 'createMiddleware',\n 'serverOnly',\n 'clientOnly',\n 'createIsomorphicFn',\n 'createServerFileRoute',\n]\n\nconst tokenRegex = new RegExp(transformFuncs.join('|'))\n\nexport function TanStackStartCompilerPlugin(\n framework: CompileStartFrameworkOptions,\n inputOpts?: {\n client?: {\n envName?: string\n }\n server?: {\n envName?: string\n }\n },\n): Plugin {\n const opts = {\n client: {\n envName: 'client',\n ...inputOpts?.client,\n },\n server: {\n envName: 'server',\n ...inputOpts?.server,\n },\n }\n\n return {\n name: 'vite-plugin-tanstack-start-create-server-fn',\n enforce: 'pre',\n applyToEnvironment(env) {\n return [opts.client.envName, opts.server.envName].includes(env.name)\n },\n transform(code, id) {\n const env =\n this.environment.name === opts.client.envName\n ? 'client'\n : this.environment.name === opts.server.envName\n ? 'server'\n : (() => {\n throw new Error(\n `Environment ${this.environment.name} not configured`,\n )\n })()\n\n return transformCode({\n code,\n id,\n env,\n framework,\n })\n },\n }\n}\n\nfunction transformCode(opts: {\n code: string\n id: string\n env: 'server' | 'client'\n framework: CompileStartFrameworkOptions\n}) {\n const { code, env, framework } = opts\n let { id } = opts\n\n const url = pathToFileURL(id)\n url.searchParams.delete('v')\n id = fileURLToPath(url).replace(/\\\\/g, '/')\n\n const includesToken = tokenRegex.test(code)\n\n if (!includesToken) {\n return null\n }\n\n if (debug) console.info(`${env} Compiling Start: `, id)\n\n const compileStartOutput = compileStartOutputFactory(framework)\n const compiled = compileStartOutput({\n code,\n filename: id,\n env,\n })\n\n if (debug) {\n logDiff(code, compiled.code)\n console.log('Output:\\n', compiled.code + '\\n\\n')\n }\n\n return compiled\n}\n"],"names":[],"mappings":";;;AAOA,MAAM,QACJ,QAAQ,IAAI,kBACZ,CAAC,QAAQ,cAAc,EAAE,SAAS,QAAQ,IAAI,cAAc;AAM9D,MAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,aAAa,IAAI,OAAO,eAAe,KAAK,GAAG,CAAC;AAEtC,SAAA,4BACd,WACA,WAQQ;AACR,QAAM,OAAO;AAAA,IACX,QAAQ;AAAA,MACN,SAAS;AAAA,MACT,GAAG,uCAAW;AAAA,IAChB;AAAA,IACA,QAAQ;AAAA,MACN,SAAS;AAAA,MACT,GAAG,uCAAW;AAAA,IAAA;AAAA,EAElB;AAEO,SAAA;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,mBAAmB,KAAK;AACf,aAAA,CAAC,KAAK,OAAO,SAAS,KAAK,OAAO,OAAO,EAAE,SAAS,IAAI,IAAI;AAAA,IACrE;AAAA,IACA,UAAU,MAAM,IAAI;AAClB,YAAM,MACJ,KAAK,YAAY,SAAS,KAAK,OAAO,UAClC,WACA,KAAK,YAAY,SAAS,KAAK,OAAO,UACpC,YACC,MAAM;AACL,cAAM,IAAI;AAAA,UACR,eAAe,KAAK,YAAY,IAAI;AAAA,QACtC;AAAA,MAAA,GACC;AAEX,aAAO,cAAc;AAAA,QACnB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA,CACD;AAAA,IAAA;AAAA,EAEL;AACF;AAEA,SAAS,cAAc,MAKpB;AACD,QAAM,EAAE,MAAM,KAAK,UAAc,IAAA;AAC7B,MAAA,EAAE,OAAO;AAEP,QAAA,MAAM,cAAc,EAAE;AACxB,MAAA,aAAa,OAAO,GAAG;AAC3B,OAAK,cAAc,GAAG,EAAE,QAAQ,OAAO,GAAG;AAEpC,QAAA,gBAAgB,WAAW,KAAK,IAAI;AAE1C,MAAI,CAAC,eAAe;AACX,WAAA;AAAA,EAAA;AAGT,MAAI,MAAe,SAAA,KAAK,GAAG,GAAG,sBAAsB,EAAE;AAEhD,QAAA,qBAAqB,0BAA0B,SAAS;AAC9D,QAAM,WAAW,mBAAmB;AAAA,IAClC;AAAA,IACA,UAAU;AAAA,IACV;AAAA,EAAA,CACD;AAED,MAAI,OAAO;AACD,YAAA,MAAM,SAAS,IAAI;AAC3B,YAAQ,IAAI,aAAa,SAAS,OAAO,MAAM;AAAA,EAAA;AAG1C,SAAA;AACT;"}
1
+ {"version":3,"file":"start-compiler-plugin.js","sources":["../../src/start-compiler-plugin.ts"],"sourcesContent":["import { fileURLToPath, pathToFileURL } from 'node:url'\nimport { logDiff } from '@tanstack/router-utils'\n\nimport { compileStartOutputFactory } from './compilers'\nimport type { Plugin } from 'vite'\nimport type { CompileStartFrameworkOptions } from './compilers'\n\nconst debug =\n process.env.TSR_VITE_DEBUG &&\n ['true', 'start-plugin'].includes(process.env.TSR_VITE_DEBUG)\n\nexport type TanStackStartViteOptions = {\n globalMiddlewareEntry: string\n}\n\nconst transformFuncs = [\n 'createServerFn',\n 'createMiddleware',\n 'serverOnly',\n 'clientOnly',\n 'createIsomorphicFn',\n 'createServerFileRoute',\n]\n\nconst tokenRegex = new RegExp(transformFuncs.join('|'))\n\nexport function startCompilerPlugin(\n framework: CompileStartFrameworkOptions,\n inputOpts?: {\n client?: {\n envName?: string\n }\n server?: {\n envName?: string\n }\n },\n): Plugin {\n const opts = {\n client: {\n envName: 'client',\n ...inputOpts?.client,\n },\n server: {\n envName: 'server',\n ...inputOpts?.server,\n },\n }\n\n return {\n name: 'vite-plugin-tanstack-start-create-server-fn',\n enforce: 'pre',\n applyToEnvironment(env) {\n return [opts.client.envName, opts.server.envName].includes(env.name)\n },\n transform(code, id) {\n const env =\n this.environment.name === opts.client.envName\n ? 'client'\n : this.environment.name === opts.server.envName\n ? 'server'\n : (() => {\n throw new Error(\n `Environment ${this.environment.name} not configured`,\n )\n })()\n\n return transformCode({\n code,\n id,\n env,\n framework,\n })\n },\n }\n}\n\nfunction transformCode(opts: {\n code: string\n id: string\n env: 'server' | 'client'\n framework: CompileStartFrameworkOptions\n}) {\n const { code, env, framework } = opts\n let { id } = opts\n\n const url = pathToFileURL(id)\n url.searchParams.delete('v')\n id = fileURLToPath(url).replace(/\\\\/g, '/')\n\n const includesToken = tokenRegex.test(code)\n\n if (!includesToken) {\n return null\n }\n\n if (debug) console.info(`${env} Compiling Start: `, id)\n\n const compileStartOutput = compileStartOutputFactory(framework)\n const compiled = compileStartOutput({\n code,\n filename: id,\n env,\n })\n\n if (debug) {\n logDiff(code, compiled.code)\n console.log('Output:\\n', compiled.code + '\\n\\n')\n }\n\n return compiled\n}\n"],"names":[],"mappings":";;;AAOA,MAAM,QACJ,QAAQ,IAAI,kBACZ,CAAC,QAAQ,cAAc,EAAE,SAAS,QAAQ,IAAI,cAAc;AAM9D,MAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,aAAa,IAAI,OAAO,eAAe,KAAK,GAAG,CAAC;AAEtC,SAAA,oBACd,WACA,WAQQ;AACR,QAAM,OAAO;AAAA,IACX,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 @@
1
+ import { PluginOption } from 'vite';
2
+ import { TanStackStartOutputConfig } from '../plugin.js';
3
+ export declare function startRoutesManifestPlugin(opts: TanStackStartOutputConfig): PluginOption;
@@ -1,9 +1,34 @@
1
- import { readFileSync } from "node:fs";
1
+ import { readFileSync, rmSync, mkdirSync, writeFile } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { joinURL } from "ufo";
4
4
  import { rootRouteId } from "@tanstack/router-core";
5
- function startManifestPlugin(opts) {
5
+ import { resolveViteId } from "../utils.js";
6
+ const getCSSRecursively = (file, filesByRouteFilePath, basePath) => {
7
+ const result = [];
8
+ for (const cssFile of file.css ?? []) {
9
+ result.push({
10
+ tag: "link",
11
+ attrs: {
12
+ rel: "stylesheet",
13
+ href: joinURL(basePath, cssFile),
14
+ type: "text/css"
15
+ }
16
+ });
17
+ }
18
+ for (const imp of file.imports ?? []) {
19
+ const importInfo = filesByRouteFilePath[imp];
20
+ if (importInfo) {
21
+ result.push(
22
+ ...getCSSRecursively(importInfo, filesByRouteFilePath, basePath)
23
+ );
24
+ }
25
+ }
26
+ return result;
27
+ };
28
+ function startRoutesManifestPlugin(opts) {
6
29
  let config;
30
+ const moduleId = "tanstack-start-router-manifest:v";
31
+ const resolvedModuleId = resolveViteId(moduleId);
7
32
  return {
8
33
  name: "tsr-routes-manifest",
9
34
  enforce: "pre",
@@ -14,23 +39,23 @@ function startManifestPlugin(opts) {
14
39
  // config = envConfig.
15
40
  // },
16
41
  resolveId(id) {
17
- if (id === "tanstack:start-manifest") {
18
- return id;
42
+ if (id === moduleId) {
43
+ return resolvedModuleId;
19
44
  }
20
45
  return;
21
46
  },
22
47
  load(id) {
23
48
  var _a, _b;
24
- if (id === "tanstack:start-manifest") {
49
+ if (id === resolvedModuleId) {
25
50
  if (this.environment.config.consumer !== "server") {
26
51
  return `export default {}`;
27
52
  }
28
53
  if (config.command === "serve") {
29
54
  return `export const tsrStartManifest = () => ({
30
- entry: "$${process.env.TSS_CLIENT_BASE}/",
31
55
  routes: {}
32
56
  })`;
33
57
  }
58
+ const APP_BASE = globalThis.TSS_APP_BASE;
34
59
  const clientViteManifestPath = path.resolve(
35
60
  opts.root,
36
61
  ".tanstack-start/build/client-dist/.vite/manifest.json"
@@ -61,7 +86,7 @@ function startManifestPlugin(opts) {
61
86
  /\/\* ROUTE_MANIFEST_START([\s\S]*?)ROUTE_MANIFEST_END \*\//
62
87
  )) == null ? void 0 : _a[1]) || "{ routes: {} }"
63
88
  );
64
- const routes = routerManifest.routes;
89
+ const routeTreeRoutes = routerManifest.routes;
65
90
  let entryFile;
66
91
  const filesByRouteFilePath = Object.fromEntries(
67
92
  Object.entries(viteManifest).map(([k, v]) => {
@@ -76,27 +101,22 @@ function startManifestPlugin(opts) {
76
101
  opts.root,
77
102
  opts.tsr.routesDirectory
78
103
  );
79
- Object.entries(routes).forEach(([k, v]) => {
104
+ Object.entries(routeTreeRoutes).forEach(([routeId, v]) => {
80
105
  const file = filesByRouteFilePath[path.join(routesDirectoryFromRoot, v.filePath)];
81
106
  if (file) {
82
- const preloads = (file.imports ?? []).map(
83
- (d) => path.join("/", viteManifest[d].file)
84
- );
107
+ const preloads = (file.imports ?? []).map((d) => {
108
+ const assetPath = joinURL(APP_BASE, viteManifest[d].file);
109
+ return assetPath;
110
+ });
85
111
  if (file.file) {
86
- preloads.unshift(path.join("/", file.file));
112
+ preloads.unshift(path.join(APP_BASE, file.file));
87
113
  }
88
- const cssFiles = file.css ?? [];
89
- const cssAssetsList = cssFiles.map(
90
- (cssFile) => ({
91
- tag: "link",
92
- attrs: {
93
- rel: "stylesheet",
94
- href: joinURL("/", cssFile),
95
- type: "text/css"
96
- }
97
- })
114
+ const cssAssetsList = getCSSRecursively(
115
+ file,
116
+ filesByRouteFilePath,
117
+ APP_BASE
98
118
  );
99
- routes[k] = {
119
+ routeTreeRoutes[routeId] = {
100
120
  ...v,
101
121
  assets: [...v.assets || [], ...cssAssetsList],
102
122
  preloads
@@ -104,30 +124,24 @@ function startManifestPlugin(opts) {
104
124
  }
105
125
  });
106
126
  if (entryFile) {
107
- routes[rootRouteId].preloads = [
108
- path.join("/", entryFile.file),
127
+ routeTreeRoutes[rootRouteId].preloads = [
128
+ joinURL(APP_BASE, entryFile.file),
109
129
  ...((_b = entryFile.imports) == null ? void 0 : _b.map(
110
- (d) => path.join("/", viteManifest[d].file)
130
+ (d) => joinURL(APP_BASE, viteManifest[d].file)
111
131
  )) || []
112
132
  ];
113
- const entryCssFiles = entryFile.css ?? [];
114
- const entryCssAssetsList = entryCssFiles.map(
115
- (cssFile) => ({
116
- tag: "link",
117
- attrs: {
118
- rel: "stylesheet",
119
- href: joinURL("/", cssFile),
120
- type: "text/css"
121
- }
122
- })
133
+ const entryCssAssetsList = getCSSRecursively(
134
+ entryFile,
135
+ filesByRouteFilePath,
136
+ APP_BASE
123
137
  );
124
- routes[rootRouteId].assets = [
125
- ...routes[rootRouteId].assets || [],
138
+ routeTreeRoutes[rootRouteId].assets = [
139
+ ...routeTreeRoutes[rootRouteId].assets || [],
126
140
  ...entryCssAssetsList,
127
141
  {
128
142
  tag: "script",
129
143
  attrs: {
130
- src: joinURL("/", entryFile.file),
144
+ src: joinURL(APP_BASE, entryFile.file),
131
145
  type: "module"
132
146
  }
133
147
  }
@@ -144,22 +158,50 @@ function startManifestPlugin(opts) {
144
158
  });
145
159
  if (route.children) {
146
160
  route.children.forEach((child) => {
147
- const childRoute = routes[child];
161
+ const childRoute = routeTreeRoutes[child];
148
162
  recurseRoute(childRoute, { ...seenPreloads });
149
163
  });
150
164
  }
151
165
  };
152
- recurseRoute(routes[rootRouteId]);
166
+ recurseRoute(routeTreeRoutes[rootRouteId]);
153
167
  const routesManifest = {
154
- routes
168
+ routes: routeTreeRoutes
155
169
  };
170
+ try {
171
+ const routesManifestOutputDirPath = path.resolve(
172
+ opts.root,
173
+ ".tanstack-start/build/route-assets-manifest"
174
+ );
175
+ rmSync(routesManifestOutputDirPath, {
176
+ recursive: true,
177
+ force: true
178
+ });
179
+ mkdirSync(routesManifestOutputDirPath, { recursive: true });
180
+ writeFile(
181
+ path.join(routesManifestOutputDirPath, "manifest.json"),
182
+ JSON.stringify(routesManifest),
183
+ (err) => {
184
+ if (err) {
185
+ console.error(
186
+ "There was an error writing the routes manifest to disk.\nYou can ignore this error. It does not affect the runtime of your application."
187
+ );
188
+ console.error(err);
189
+ }
190
+ }
191
+ );
192
+ } catch (err) {
193
+ console.error(
194
+ "There was an error writing the routes manifest to disk.\nYou can ignore this error. It does not affect the runtime of your application."
195
+ );
196
+ console.error(err);
197
+ }
156
198
  return `export const tsrStartManifest = () => (${JSON.stringify(routesManifest)})`;
157
199
  }
158
- return;
200
+ return void 0;
159
201
  }
160
202
  };
161
203
  }
162
204
  export {
163
- startManifestPlugin
205
+ startRoutesManifestPlugin
164
206
  };
165
- //# sourceMappingURL=routesManifestPlugin.js.map
207
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["../../../src/start-routes-manifest-plugin/plugin.ts"],"sourcesContent":["import { mkdirSync, readFileSync, rmSync, writeFile } from 'node:fs'\nimport path from 'node:path'\nimport { joinURL } from 'ufo'\nimport { rootRouteId } from '@tanstack/router-core'\nimport { resolveViteId } from '../utils'\nimport type {\n PluginOption,\n ResolvedConfig,\n Manifest as ViteManifest,\n ManifestChunk as ViteManifestChunk,\n} from 'vite'\nimport type { Manifest, RouterManagedTag } from '@tanstack/router-core'\nimport type { TanStackStartOutputConfig } from '../plugin'\n\nconst getCSSRecursively = (\n file: ViteManifestChunk,\n filesByRouteFilePath: ViteManifest,\n basePath: string,\n) => {\n const result: Array<RouterManagedTag> = []\n\n // Get all css imports from the file\n for (const cssFile of file.css ?? []) {\n result.push({\n tag: 'link',\n attrs: {\n rel: 'stylesheet',\n href: joinURL(basePath, cssFile),\n type: 'text/css',\n },\n })\n }\n\n // Recursively get CSS from imports\n for (const imp of file.imports ?? []) {\n const importInfo = filesByRouteFilePath[imp]\n if (importInfo) {\n result.push(\n ...getCSSRecursively(importInfo, filesByRouteFilePath, basePath),\n )\n }\n }\n\n return result\n}\n\nexport function startRoutesManifestPlugin(\n opts: TanStackStartOutputConfig,\n): PluginOption {\n let config: ResolvedConfig\n\n const moduleId = 'tanstack-start-router-manifest:v'\n const resolvedModuleId = resolveViteId(moduleId)\n\n return {\n name: 'tsr-routes-manifest',\n enforce: 'pre',\n\n configResolved(resolvedConfig) {\n config = resolvedConfig\n },\n // configEnvironment(env, envConfig) {\n // config = envConfig.\n // },\n resolveId(id) {\n if (id === moduleId) {\n return resolvedModuleId\n }\n return\n },\n load(id) {\n if (id === resolvedModuleId) {\n if (this.environment.config.consumer !== 'server') {\n // this will ultimately fail the build if the plugin is used outside the server environment\n // TODO: do we need special handling for `serve`?\n return `export default {}`\n }\n\n // If we're in development, return a dummy manifest\n if (config.command === 'serve') {\n return `export const tsrStartManifest = () => ({\n routes: {}\n })`\n }\n\n // This is the basepath for the application\n const APP_BASE = globalThis.TSS_APP_BASE\n\n const clientViteManifestPath = path.resolve(\n opts.root,\n '.tanstack-start/build/client-dist/.vite/manifest.json',\n )\n\n let viteManifest: ViteManifest\n try {\n viteManifest = JSON.parse(\n readFileSync(clientViteManifestPath, 'utf-8'),\n )\n } catch (err) {\n console.error(err)\n throw new Error(\n `Could not find the production client vite manifest at '${clientViteManifestPath}'!`,\n )\n }\n\n const routeTreePath = path.resolve(opts.tsr.generatedRouteTree)\n\n let routeTreeContent: string\n try {\n routeTreeContent = readFileSync(routeTreePath, 'utf-8')\n } catch (err) {\n console.error(err)\n throw new Error(\n `Could not find the generated route tree at '${routeTreePath}'!`,\n )\n }\n\n // Extract the routesManifest JSON from the route tree file.\n // It's located between the /* ROUTE_MANIFEST_START and ROUTE_MANIFEST_END */ comment block.\n\n const routerManifest = JSON.parse(\n routeTreeContent.match(\n /\\/\\* ROUTE_MANIFEST_START([\\s\\S]*?)ROUTE_MANIFEST_END \\*\\//,\n )?.[1] || '{ routes: {} }',\n ) as Manifest\n\n // This the manifest pulled from the generated route tree and later used by the Router.\n // i.e what's located in `src/generatedRouteTree.gen.ts`\n const routeTreeRoutes = routerManifest.routes\n\n // This is where hydration will start, from when the SSR'd page reaches the browser.\n // By default, this'd be the virtual entry of `/~start/default-client-entry.tsx`, unless a custom entry is provided.\n let entryFile: ViteManifestChunk | undefined\n\n const filesByRouteFilePath: ViteManifest = Object.fromEntries(\n Object.entries(viteManifest).map(([k, v]) => {\n if (v.isEntry) {\n entryFile = v\n }\n\n const rPath = k.split('?')[0]\n\n return [rPath, v]\n }, {}),\n )\n\n const routesDirectoryFromRoot = path.relative(\n opts.root,\n opts.tsr.routesDirectory,\n )\n\n // Add preloads to the routes from the vite manifest\n Object.entries(routeTreeRoutes).forEach(([routeId, v]) => {\n const file =\n filesByRouteFilePath[\n path.join(routesDirectoryFromRoot, v.filePath as string)\n ]\n\n if (file) {\n // Map the relevant imports to their route paths,\n // so that it can be imported in the browser.\n const preloads = (file.imports ?? []).map((d) => {\n const assetPath = joinURL(APP_BASE, viteManifest[d]!.file)\n return assetPath\n })\n\n // Since this is the most important JS entry for the route,\n // it should be moved to the front of the preloads so that\n // it has the best chance of being loaded first.\n if (file.file) {\n preloads.unshift(path.join(APP_BASE, file.file))\n }\n\n const cssAssetsList = getCSSRecursively(\n file,\n filesByRouteFilePath,\n APP_BASE,\n )\n\n routeTreeRoutes[routeId] = {\n ...v,\n assets: [...(v.assets || []), ...cssAssetsList],\n preloads,\n }\n }\n })\n\n if (entryFile) {\n routeTreeRoutes[rootRouteId]!.preloads = [\n joinURL(APP_BASE, entryFile.file),\n ...(entryFile.imports?.map((d) =>\n joinURL(APP_BASE, viteManifest[d]!.file),\n ) || []),\n ]\n\n // Gather all the CSS files from the entry file in\n // the `css` key and add them to the root route\n const entryCssAssetsList = getCSSRecursively(\n entryFile,\n filesByRouteFilePath,\n APP_BASE,\n )\n\n routeTreeRoutes[rootRouteId]!.assets = [\n ...(routeTreeRoutes[rootRouteId]!.assets || []),\n ...entryCssAssetsList,\n {\n tag: 'script',\n attrs: {\n src: joinURL(APP_BASE, entryFile.file),\n type: 'module',\n },\n },\n ]\n }\n\n const recurseRoute = (\n route: {\n preloads?: Array<string>\n children?: Array<any>\n },\n seenPreloads = {} as Record<string, true>,\n ) => {\n route.preloads = route.preloads?.filter((preload) => {\n if (seenPreloads[preload]) {\n return false\n }\n seenPreloads[preload] = true\n return true\n })\n\n if (route.children) {\n route.children.forEach((child) => {\n const childRoute = routeTreeRoutes[child]!\n recurseRoute(childRoute, { ...seenPreloads })\n })\n }\n }\n\n // @ts-expect-error\n recurseRoute(routeTreeRoutes[rootRouteId])\n\n const routesManifest = {\n routes: routeTreeRoutes,\n }\n\n try {\n const routesManifestOutputDirPath = path.resolve(\n opts.root,\n '.tanstack-start/build/route-assets-manifest',\n )\n rmSync(routesManifestOutputDirPath, {\n recursive: true,\n force: true,\n })\n mkdirSync(routesManifestOutputDirPath, { recursive: true })\n writeFile(\n path.join(routesManifestOutputDirPath, 'manifest.json'),\n JSON.stringify(routesManifest),\n (err) => {\n if (err) {\n console.error(\n 'There was an error writing the routes manifest to disk.\\nYou can ignore this error. It does not affect the runtime of your application.',\n )\n console.error(err)\n }\n },\n )\n } catch (err) {\n console.error(\n 'There was an error writing the routes manifest to disk.\\nYou can ignore this error. It does not affect the runtime of your application.',\n )\n console.error(err)\n }\n\n return `export const tsrStartManifest = () => (${JSON.stringify(routesManifest)})`\n }\n\n return undefined\n },\n }\n}\n"],"names":["_a"],"mappings":";;;;;AAcA,MAAM,oBAAoB,CACxB,MACA,sBACA,aACG;AACH,QAAM,SAAkC,CAAC;AAGzC,aAAW,WAAW,KAAK,OAAO,CAAA,GAAI;AACpC,WAAO,KAAK;AAAA,MACV,KAAK;AAAA,MACL,OAAO;AAAA,QACL,KAAK;AAAA,QACL,MAAM,QAAQ,UAAU,OAAO;AAAA,QAC/B,MAAM;AAAA,MAAA;AAAA,IACR,CACD;AAAA,EAAA;AAIH,aAAW,OAAO,KAAK,WAAW,CAAA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A,YACnB;AAAA,UAEJ;AAAA,iBACO,KAAK;AACJ,kBAAA;AAAA,YACN;AAAA,UACF;AACA,kBAAQ,MAAM,GAAG;AAAA,QAAA;AAGnB,eAAO,0CAA0C,KAAK,UAAU,cAAc,CAAC;AAAA,MAAA;AAG1E,aAAA;AAAA,IAAA;AAAA,EAEX;AACF;"}
@@ -11,6 +11,7 @@ const setLock = (bool) => {
11
11
  };
12
12
  function TanStackStartServerRoutesVite(config) {
13
13
  let ROOT = process.cwd();
14
+ const moduleId = "tanstack-start-server-routes-manifest:v";
14
15
  const getRoutesDirectoryPath = () => {
15
16
  return isAbsolute(config.routesDirectory) ? config.routesDirectory : join(ROOT, config.routesDirectory);
16
17
  };
@@ -50,7 +51,7 @@ function TanStackStartServerRoutesVite(config) {
50
51
  },
51
52
  sharedDuringBuild: true,
52
53
  resolveId(id) {
53
- if (id === "tanstack:server-routes") {
54
+ if (id === moduleId) {
54
55
  const generatedRouteTreePath = getGeneratedRouteTreePath(ROOT);
55
56
  return generatedRouteTreePath;
56
57
  }
@@ -160,7 +161,8 @@ Add the file in: "${config.routesDirectory}/${rootPathId}.tsx"`;
160
161
  node.cleanedPath = removeGroups(
161
162
  removeUnderscores(removeLayoutSegments(node.path)) ?? ""
162
163
  );
163
- const routeCode = node.fullPath ? fs.readFileSync(node.fullPath, "utf-8") : "";
164
+ const stats = fs.statSync(node.fullPath);
165
+ const routeCode = stats.isFile() ? fs.readFileSync(node.fullPath, "utf-8") : "";
164
166
  if (!node.isVirtualParentRoute && !node.isVirtual) ;
165
167
  const cleanedPathIsEmpty = (node.cleanedPath || "").length === 0;
166
168
  const nonPathRoute = node._fsRouteType === "pathless_layout" && node.isNonPath;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["../../../src/start-server-routes-plugin/plugin.ts"],"sourcesContent":["import path, { isAbsolute, join, normalize } from 'node:path'\nimport fs from 'node:fs'\nimport fsp from 'node:fs/promises'\nimport {\n format,\n logging,\n multiSortBy,\n physicalGetRouteNodes,\n removeExt,\n removeUnderscores,\n replaceBackslash,\n resetRegex,\n rootPathId,\n routePathToVariable,\n trimPathLeft,\n virtualGetRouteNodes,\n writeIfDifferent,\n} from '@tanstack/router-generator'\nimport { rootRouteId } from '@tanstack/router-core'\nimport { fillTemplate, getTargetTemplate } from './template'\nimport type { GetRouteNodesResult, RouteNode } from '@tanstack/router-generator'\nimport type { Config } from './config'\nimport type { Plugin } from 'vite'\n\nlet lock = false\nconst checkLock = () => lock\nconst setLock = (bool: boolean) => {\n lock = bool\n}\n\nexport function TanStackStartServerRoutesVite(config: Config): Plugin {\n let ROOT: string = process.cwd()\n\n const getRoutesDirectoryPath = () => {\n return isAbsolute(config.routesDirectory)\n ? config.routesDirectory\n : join(ROOT, config.routesDirectory)\n }\n\n const generate = async () => {\n if (checkLock()) {\n return\n }\n\n setLock(true)\n\n try {\n await generator(config, ROOT)\n } catch (err) {\n console.error(err)\n console.info()\n } finally {\n setLock(false)\n }\n }\n\n const handleFile = async (file: string) => {\n const filePath = normalize(file)\n\n const routesDirectoryPath = getRoutesDirectoryPath()\n if (filePath.startsWith(routesDirectoryPath)) {\n await generate()\n }\n }\n\n return {\n name: 'tanstack-start-server-routes-plugin',\n configureServer(server) {\n server.watcher.on('all', (event, path) => {\n handleFile(path)\n })\n },\n configResolved(config) {\n ROOT = config.root\n },\n async buildStart() {\n await generate()\n // if (this.environment.name === 'server') {\n // }\n },\n sharedDuringBuild: true,\n resolveId(id) {\n if (id === 'tanstack:server-routes') {\n const generatedRouteTreePath = getGeneratedRouteTreePath(ROOT)\n return generatedRouteTreePath\n }\n return null\n },\n }\n}\n\n// Maybe import this from `@tanstack/router-core` in the future???\nlet latestTask = 0\nconst routeGroupPatternRegex = /\\(.+\\)/g\nconst possiblyNestedRouteGroupPatternRegex = /\\([^/]+\\)\\/?/g\n\nlet isFirst = false\nlet skipMessage = false\n\nfunction getGeneratedRouteTreePath(root: string) {\n return path.resolve(root, '.tanstack-start/server-routes/routeTree.gen.ts')\n}\n\nasync function generator(config: Config, root: string) {\n const generatedServerRouteTreePath = getGeneratedRouteTreePath(root)\n const ROUTE_TEMPLATE = getTargetTemplate(config.target)\n const logger = logging({ disabled: config.disableLogging })\n\n if (!isFirst) {\n // logger.log('♻️ Generating server routes...')\n isFirst = true\n } else if (skipMessage) {\n skipMessage = false\n } else {\n // logger.log('♻️ Regenerating server routes...')\n }\n\n const taskId = latestTask + 1\n latestTask = taskId\n\n const checkLatest = () => {\n if (latestTask !== taskId) {\n skipMessage = true\n return false\n }\n\n return true\n }\n\n const start = Date.now()\n\n let getRouteNodesResult: GetRouteNodesResult\n\n if (config.virtualRouteConfig) {\n getRouteNodesResult = await virtualGetRouteNodes(config, root)\n } else {\n getRouteNodesResult = await physicalGetRouteNodes(config, root)\n }\n\n const { rootRouteNode, routeNodes: beforeRouteNodes } = getRouteNodesResult\n if (rootRouteNode === undefined) {\n let errorMessage = `rootRouteNode must not be undefined. Make sure you've added your root route into the route-tree.`\n if (!config.virtualRouteConfig) {\n errorMessage += `\\nMake sure that you add a \"${rootPathId}.tsx\" file to your routes directory.\\nAdd the file in: \"${config.routesDirectory}/${rootPathId}.tsx\"`\n }\n throw new Error(errorMessage)\n }\n\n const preRouteNodes = multiSortBy(beforeRouteNodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) =>\n d.filePath.match(new RegExp(`[./]${config.indexToken}[.]`)) ? 1 : -1,\n (d) =>\n d.filePath.match(\n /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,\n )\n ? 1\n : -1,\n (d) =>\n d.filePath.match(new RegExp(`[./]${config.routeToken}[.]`)) ? -1 : 1,\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ''))\n\n const routeTree: Array<RouteNode> = []\n\n // Loop over the flat list of routeNodes and\n // build up a tree based on the routeNodes' routePath\n const routeNodes: Array<RouteNode> = []\n\n // the handleRootNode function is not being collapsed into the handleNode function\n // because it requires only a subset of the logic that the handleNode function requires\n // and it's easier to read and maintain this way\n const handleRootNode = async (node?: RouteNode) => {\n if (!node) {\n // currently this is not being handled, but it could be in the future\n // for example to handle a virtual root route\n return\n }\n\n // from here on, we are only handling the root node that's present in the file system\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n if (!routeCode) {\n const _rootTemplate = ROUTE_TEMPLATE.rootRoute\n const replaced = await fillTemplate(config, _rootTemplate.template(), {\n tsrImports: _rootTemplate.imports.tsrImports(),\n tsrPath: rootPathId,\n tsrExportStart: _rootTemplate.imports.tsrExportStart(),\n tsrExportEnd: _rootTemplate.imports.tsrExportEnd(),\n })\n\n await writeIfDifferent(\n node.fullPath,\n '', // Empty string because the file doesn't exist yet\n replaced,\n {\n beforeWrite: () => {\n // logger.log(`🟡 Creating ${node.fullPath}`)\n },\n },\n )\n }\n }\n\n await handleRootNode(rootRouteNode)\n\n const handleNode = async (node: RouteNode) => {\n // Do not remove this as we need to set the lastIndex to 0 as it\n // is necessary to reset the regex's index when using the global flag\n // otherwise it might not match the next time it's used\n resetRegex(routeGroupPatternRegex)\n\n let parentRoute = hasParentRoute(routeNodes, node, node.routePath)\n\n // if the parent route is a virtual parent route, we need to find the real parent route\n if (parentRoute?.isVirtualParentRoute && parentRoute.children?.length) {\n // only if this sub-parent route returns a valid parent route, we use it, if not leave it as it\n const possibleParentRoute = hasParentRoute(\n parentRoute.children,\n node,\n node.routePath,\n )\n if (possibleParentRoute) {\n parentRoute = possibleParentRoute\n }\n }\n\n if (parentRoute) node.parent = parentRoute\n\n node.path = determineNodePath(node)\n\n const trimmedPath = trimPathLeft(node.path ?? '')\n\n const split = trimmedPath.split('/')\n const lastRouteSegment = split[split.length - 1] ?? trimmedPath\n\n node.isNonPath =\n lastRouteSegment.startsWith('_') ||\n routeGroupPatternRegex.test(lastRouteSegment)\n\n node.cleanedPath = removeGroups(\n removeUnderscores(removeLayoutSegments(node.path)) ?? '',\n )\n\n const routeCode = node.fullPath\n ? fs.readFileSync(node.fullPath, 'utf-8')\n : ''\n\n // Ensure the boilerplate for the route exists, which can be skipped for virtual parent routes and virtual routes\n if (!node.isVirtualParentRoute && !node.isVirtual) {\n // const escapedRoutePath = node.routePath?.replaceAll('$', '$$') ?? ''\n // let replaced = routeCode\n // await writeIfDifferent(node.fullPath, routeCode, replaced, {\n // beforeWrite: () => {\n // // logger.log(`🟡 Updating ${node.fullPath}`)\n // },\n // })\n }\n\n const cleanedPathIsEmpty = (node.cleanedPath || '').length === 0\n const nonPathRoute =\n node._fsRouteType === 'pathless_layout' && node.isNonPath\n\n node.isVirtualParentRequired =\n node._fsRouteType === 'pathless_layout' || nonPathRoute\n ? !cleanedPathIsEmpty\n : false\n\n if (!node.isVirtual && node.isVirtualParentRequired) {\n const parentRoutePath = removeLastSegmentFromPath(node.routePath) || '/'\n const parentVariableName = routePathToVariable(parentRoutePath)\n\n const anchorRoute = routeNodes.find(\n (d) => d.routePath === parentRoutePath,\n )\n\n if (!anchorRoute) {\n const parentNode: RouteNode = {\n ...node,\n path: removeLastSegmentFromPath(node.path) || '/',\n filePath: removeLastSegmentFromPath(node.filePath) || '/',\n fullPath: removeLastSegmentFromPath(node.fullPath) || '/',\n routePath: parentRoutePath,\n variableName: parentVariableName,\n isVirtual: true,\n _fsRouteType: 'layout', // layout since this route will wrap other routes\n isVirtualParentRoute: true,\n isVirtualParentRequired: false,\n }\n\n parentNode.children = parentNode.children ?? []\n parentNode.children.push(node)\n\n node.parent = parentNode\n\n if (node._fsRouteType === 'pathless_layout') {\n // since `node.path` is used as the `id` on the route definition, we need to update it\n node.path = determineNodePath(node)\n }\n\n await handleNode(parentNode)\n } else {\n anchorRoute.children = anchorRoute.children ?? []\n anchorRoute.children.push(node)\n\n node.parent = anchorRoute\n }\n }\n\n if (\n !routeCode\n .split('\\n')\n .some((line) => line.trim().startsWith('export const ServerRoute'))\n ) {\n return\n }\n\n if (node.parent) {\n if (!node.isVirtualParentRequired) {\n node.parent.children = node.parent.children ?? []\n node.parent.children.push(node)\n }\n } else {\n routeTree.push(node)\n }\n\n routeNodes.push(node)\n }\n\n for (const node of preRouteNodes) {\n await handleNode(node)\n }\n\n // This is run against the `routeNodes` array since it\n // has the accumulated (intended) Server Route nodes\n // Since TSR allows multiple way of defining a route,\n // we need to ensure that a user hasn't defined the\n // same route in multiple ways (i.e. `flat`, `nested`, `virtual`)\n checkRouteFullPathUniqueness(routeNodes, config)\n\n function buildRouteTreeConfig(nodes: Array<RouteNode>, depth = 1): string {\n const children = nodes.map((node) => {\n if (node._fsRouteType === '__root') {\n return\n }\n\n if (node._fsRouteType === 'pathless_layout' && !node.children?.length) {\n return\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = buildRouteTreeConfig(node.children, depth + 1)\n\n const childrenDeclaration = `interface ${route}Children {\n ${node.children.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`\n\n const children = `const ${route}Children: ${route}Children = {\n ${node.children.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`\n\n const routeWithChildren = `const ${route}WithChildren = ${route}._addFileChildren(${route}Children)`\n\n return [\n childConfigs,\n childrenDeclaration,\n children,\n routeWithChildren,\n ].join('\\n\\n')\n }\n\n return undefined\n })\n\n return children.filter(Boolean).join('\\n\\n')\n }\n\n const routeConfigChildrenText = buildRouteTreeConfig(routeTree)\n\n const sortedRouteNodes = multiSortBy(routeNodes, [\n (d) => (d.routePath?.includes(`/${rootPathId}`) ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.routePath?.endsWith(config.indexToken) ? -1 : 1),\n (d) => d,\n ])\n\n const imports = Object.entries({\n createFileRoute: sortedRouteNodes.some((d) => d.isVirtual),\n })\n .filter((d) => d[1])\n .map((d) => d[0])\n\n const virtualRouteNodes = sortedRouteNodes.filter((d) => d.isVirtual)\n\n function getImportPath(node: RouteNode) {\n return replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(generatedServerRouteTreePath),\n path.resolve(config.routesDirectory, node.filePath),\n ),\n ),\n )\n }\n\n const rootRouteExists = fs.existsSync(rootRouteNode.fullPath)\n const rootRouteCode = rootRouteExists\n ? fs.readFileSync(rootRouteNode.fullPath, 'utf-8')\n : ''\n const hasServerRootRoute =\n rootRouteExists && rootRouteCode.includes('export const ServerRoute')\n\n const routeImports = [\n ...config.routeTreeFileHeader,\n `// This file was automatically generated by TanStack Router.\n// You should NOT make any changes in this file as it will be overwritten.\n// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.`,\n imports.length\n ? `import { ${imports.join(', ')} } from '${ROUTE_TEMPLATE.fullPkg}'\\n`\n : '',\n '// Import Routes',\n [\n `import type { FileRoutesByPath, CreateServerFileRoute } from '${ROUTE_TEMPLATE.fullPkg}'`,\n `import { createServerRoute, createServerFileRoute } from '${ROUTE_TEMPLATE.fullPkg}'`,\n hasServerRootRoute\n ? `import { ServerRoute as rootRouteImport } from './${getImportPath(rootRouteNode)}'`\n : '',\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { ServerRoute as ${\n node.variableName\n }RouteImport } from './${getImportPath(node)}'`\n }),\n ].join('\\n'),\n virtualRouteNodes.length ? '// Create Virtual Routes' : '',\n virtualRouteNodes\n .map((node) => {\n return `const ${\n node.variableName\n }RouteImport = createFileRoute('${node.routePath}')()`\n })\n .join('\\n'),\n '// Create/Update Routes',\n !hasServerRootRoute\n ? `\n const rootRoute = createServerRoute()\n `\n : '',\n sortedRouteNodes\n .map((node) => {\n return [\n [\n `const ${node.variableName}Route = ${node.variableName}RouteImport.update({\n ${[\n `id: '${node.path}'`,\n !node.isNonPath ? `path: '${node.cleanedPath}'` : undefined,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n } as any)`,\n ].join(''),\n ].join('\\n\\n')\n })\n .join('\\n\\n'),\n '',\n\n '// Populate the FileRoutesByPath interface',\n `declare module '${ROUTE_TEMPLATE.fullPkg}' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n const filePathId = routeNode.routePath\n\n return `'${filePathId}': {\n id: '${filePathId}'\n path: '${inferPath(routeNode)}'\n fullPath: '${inferFullPath(routeNode)}'\n preLoaderRoute: typeof ${routeNode.variableName}RouteImport\n parentRoute: typeof ${\n routeNode.isVirtualParentRequired\n ? `${routeNode.parent?.variableName}Route`\n : routeNode.parent?.variableName\n ? `${routeNode.parent.variableName}RouteImport`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n `// Add type-safety to the createFileRoute function across the route tree`,\n routeNodes\n .map((routeNode) => {\n return `declare module './${getImportPath(routeNode)}' {\nconst createServerFileRoute: CreateServerFileRoute<\nFileRoutesByPath['${routeNode.routePath}']['parentRoute'],\nFileRoutesByPath['${routeNode.routePath}']['id'],\nFileRoutesByPath['${routeNode.routePath}']['path'],\nFileRoutesByPath['${routeNode.routePath}']['fullPath'],\n${routeNode.children?.length ? `${routeNode.variableName}RouteChildren` : 'unknown'}\n>\n}`\n })\n .join('\\n'),\n '// Create and export the route tree',\n routeConfigChildrenText,\n `export interface FileRoutesByFullPath {\n ${[...createRouteNodesByFullPath(routeNodes).entries()].map(\n ([fullPath, routeNode]) => {\n return `'${fullPath}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n },\n )}\n}`,\n `export interface FileRoutesByTo {\n ${[...createRouteNodesByTo(routeNodes).entries()].map(([to, routeNode]) => {\n return `'${to}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n })}\n}`,\n `export interface FileRoutesById {\n '${rootRouteId}': typeof rootRoute,\n ${[...createRouteNodesById(routeNodes).entries()].map(([id, routeNode]) => {\n return `'${id}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n })}\n}`,\n `export interface FileRouteTypes {\n fileRoutesByFullPath: FileRoutesByFullPath\n fullPaths: ${routeNodes.length > 0 ? [...createRouteNodesByFullPath(routeNodes).keys()].map((fullPath) => `'${fullPath}'`).join('|') : 'never'}\n fileRoutesByTo: FileRoutesByTo\n to: ${routeNodes.length > 0 ? [...createRouteNodesByTo(routeNodes).keys()].map((to) => `'${to}'`).join('|') : 'never'}\n id: ${[`'${rootRouteId}'`, ...[...createRouteNodesById(routeNodes).keys()].map((id) => `'${id}'`)].join('|')}\n fileRoutesById: FileRoutesById\n}`,\n `export interface RootRouteChildren {\n ${routeTree.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`,\n `const rootRouteChildren: RootRouteChildren = {\n ${routeTree.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`,\n `export const routeTree = rootRoute._addFileChildren(rootRouteChildren)._addFileTypes<FileRouteTypes>()`,\n ]\n .filter(Boolean)\n .join('\\n\\n')\n\n const createRouteManifest = () => {\n const routesManifest = {\n [rootRouteId]: {\n filePath: rootRouteNode.filePath,\n children: routeTree.map((d) => d.routePath),\n },\n ...Object.fromEntries(\n routeNodes.map((d) => {\n const filePathId = d.routePath\n\n return [\n filePathId,\n {\n filePath: d.filePath,\n parent: d.parent?.routePath ? d.parent.routePath : undefined,\n children: d.children?.map((childRoute) => childRoute.routePath),\n },\n ]\n }),\n ),\n }\n\n return JSON.stringify(\n {\n routes: routesManifest,\n },\n null,\n 2,\n )\n }\n\n const includeManifest = ['react', 'solid']\n const routeConfigFileContent = !includeManifest.includes(config.target)\n ? routeImports\n : [\n routeImports,\n '\\n',\n '/* ROUTE_MANIFEST_START',\n createRouteManifest(),\n 'ROUTE_MANIFEST_END */',\n ].join('\\n')\n\n if (!checkLatest()) return\n\n const existingRouteTreeContent = await fsp\n .readFile(path.resolve(generatedServerRouteTreePath), 'utf-8')\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return ''\n }\n\n throw err\n })\n\n if (!checkLatest()) return\n\n // Ensure the directory exists\n await fsp.mkdir(path.dirname(path.resolve(generatedServerRouteTreePath)), {\n recursive: true,\n })\n\n if (!checkLatest()) return\n\n // Write the route tree file, if it has changed\n const routeTreeWriteResult = await writeIfDifferent(\n path.resolve(generatedServerRouteTreePath),\n await format(existingRouteTreeContent, config),\n await format(routeConfigFileContent, config),\n {\n beforeWrite: () => {\n // logger.log(`🟡 Updating ${generatedRouteTreePath}`)\n },\n },\n )\n\n // Write declaration file\n const startDeclarationFilePath = path.join(\n path.resolve(root, config.srcDirectory),\n 'tanstack-start.d.ts',\n )\n const serverRoutesRelativePath = removeExt(\n path.relative(\n path.dirname(startDeclarationFilePath),\n generatedServerRouteTreePath,\n ),\n )\n const startDeclarationFileContent = buildStartDeclarationFile({\n serverRoutesRelativePath,\n })\n if (!fs.existsSync(startDeclarationFilePath)) {\n await writeIfDifferent(\n startDeclarationFilePath,\n '',\n startDeclarationFileContent,\n {\n beforeWrite: () => {\n logger.log(`🟡 Creating tanstack-start.d.ts`)\n },\n },\n )\n } else {\n const existingDeclarationFileContent = await fsp\n .readFile(startDeclarationFilePath, 'utf-8')\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return ''\n }\n throw err\n })\n await writeIfDifferent(\n startDeclarationFilePath,\n existingDeclarationFileContent,\n startDeclarationFileContent,\n {\n beforeWrite: () => {\n logger.log(`🟡 Updating tanstack-start.d.ts`)\n },\n },\n )\n }\n\n if (routeTreeWriteResult && !checkLatest()) {\n return\n }\n\n // logger.log(\n // `✅ Processed ${routeNodes.length === 1 ? 'server route' : 'server routes'} in ${\n // Date.now() - start\n // }ms`,\n // )\n}\n\nfunction buildStartDeclarationFile({\n serverRoutesRelativePath,\n}: {\n serverRoutesRelativePath: string\n}) {\n const serverRoutesPath = replaceBackslash(serverRoutesRelativePath)\n return (\n [\n '/// <reference types=\"vite/client\" />',\n `import '${serverRoutesPath}'`,\n ].join('\\n') + '\\n'\n )\n}\n\nfunction removeGroups(s: string) {\n return s.replace(possiblyNestedRouteGroupPatternRegex, '')\n}\n\n/**\n * The `node.path` is used as the `id` in the route definition.\n * This function checks if the given node has a parent and if so, it determines the correct path for the given node.\n * @param node - The node to determine the path for.\n * @returns The correct path for the given node.\n */\nfunction determineNodePath(node: RouteNode) {\n return (node.path = node.parent\n ? node.routePath?.replace(node.parent.routePath ?? '', '') || '/'\n : node.routePath)\n}\n\n/**\n * Removes the last segment from a given path. Segments are considered to be separated by a '/'.\n *\n * @param {string} routePath - The path from which to remove the last segment. Defaults to '/'.\n * @returns {string} The path with the last segment removed.\n * @example\n * removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth'\n */\nfunction removeLastSegmentFromPath(routePath: string = '/'): string {\n const segments = routePath.split('/')\n segments.pop() // Remove the last segment\n return segments.join('/')\n}\n\n/**\n * Removes all segments from a given path that start with an underscore ('_').\n *\n * @param {string} routePath - The path from which to remove segments. Defaults to '/'.\n * @returns {string} The path with all underscore-prefixed segments removed.\n * @example\n * removeLayoutSegments('/workspace/_auth/foo') // '/workspace/foo'\n */\nfunction removeLayoutSegments(routePath: string = '/'): string {\n const segments = routePath.split('/')\n const newSegments = segments.filter((segment) => !segment.startsWith('_'))\n return newSegments.join('/')\n}\n\nfunction hasParentRoute(\n routes: Array<RouteNode>,\n node: RouteNode,\n routePathToCheck: string | undefined,\n): RouteNode | null {\n if (!routePathToCheck || routePathToCheck === '/') {\n return null\n }\n\n const sortedNodes = multiSortBy(routes, [\n (d) => d.routePath!.length * -1,\n (d) => d.variableName,\n ]).filter((d) => d.routePath !== `/${rootPathId}`)\n\n for (const route of sortedNodes) {\n if (route.routePath === '/') continue\n\n if (\n routePathToCheck.startsWith(`${route.routePath}/`) &&\n route.routePath !== routePathToCheck\n ) {\n return route\n }\n }\n\n const segments = routePathToCheck.split('/')\n segments.pop() // Remove the last segment\n const parentRoutePath = segments.join('/')\n\n return hasParentRoute(routes, node, parentRoutePath)\n}\n\n/**\n * Gets the final variable name for a route\n */\nconst getResolvedRouteNodeVariableName = (routeNode: RouteNode): string => {\n return routeNode.children?.length\n ? `${routeNode.variableName}RouteWithChildren`\n : `${routeNode.variableName}Route`\n}\n\n/**\n * Creates a map from fullPath to routeNode\n */\nconst createRouteNodesByFullPath = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => [inferFullPath(routeNode), routeNode]),\n )\n}\n\n/**\n * Create a map from 'to' to a routeNode\n */\nconst createRouteNodesByTo = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n dedupeBranchesAndIndexRoutes(routeNodes).map((routeNode) => [\n inferTo(routeNode),\n routeNode,\n ]),\n )\n}\n\n/**\n * Create a map from 'id' to a routeNode\n */\nconst createRouteNodesById = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => {\n const id = routeNode.routePath ?? ''\n return [id, routeNode]\n }),\n )\n}\n\n/**\n * Infers the full path for use by TS\n */\nconst inferFullPath = (routeNode: RouteNode): string => {\n const fullPath = removeGroups(\n removeUnderscores(removeLayoutSegments(routeNode.routePath)) ?? '',\n )\n\n return routeNode.cleanedPath === '/' ? fullPath : fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Infers the path for use by TS\n */\nconst inferPath = (routeNode: RouteNode): string => {\n return routeNode.cleanedPath === '/'\n ? routeNode.cleanedPath\n : (routeNode.cleanedPath?.replace(/\\/$/, '') ?? '')\n}\n\n/**\n * Infers to path\n */\nconst inferTo = (routeNode: RouteNode): string => {\n const fullPath = inferFullPath(routeNode)\n\n if (fullPath === '/') return fullPath\n\n return fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Dedupes branches and index routes\n */\nconst dedupeBranchesAndIndexRoutes = (\n routes: Array<RouteNode>,\n): Array<RouteNode> => {\n return routes.filter((route) => {\n if (route.children?.find((child) => child.cleanedPath === '/')) return false\n return true\n })\n}\n\nfunction checkUnique<TElement>(routes: Array<TElement>, key: keyof TElement) {\n // Check no two routes have the same `key`\n // if they do, throw an error with the conflicting filePaths\n const keys = routes.map((d) => d[key])\n const uniqueKeys = new Set(keys)\n if (keys.length !== uniqueKeys.size) {\n const duplicateKeys = keys.filter((d, i) => keys.indexOf(d) !== i)\n const conflictingFiles = routes.filter((d) =>\n duplicateKeys.includes(d[key]),\n )\n return conflictingFiles\n }\n return undefined\n}\n\nfunction checkRouteFullPathUniqueness(\n _routes: Array<RouteNode>,\n config: Config,\n) {\n const routes = _routes.map((d) => {\n const inferredFullPath = inferFullPath(d)\n return { ...d, inferredFullPath }\n })\n\n const conflictingFiles = checkUnique(routes, 'inferredFullPath')\n\n if (conflictingFiles !== undefined) {\n const errorMessage = `Conflicting configuration paths were found for the following route${conflictingFiles.length > 1 ? 's' : ''}: ${conflictingFiles\n .map((p) => `\"${p.inferredFullPath}\"`)\n .join(', ')}.\nPlease ensure each Server Route has a unique full path.\nConflicting files: \\n ${conflictingFiles.map((d) => path.resolve(config.routesDirectory, d.filePath)).join('\\n ')}\\n`\n console.error(errorMessage)\n process.exit(1)\n }\n}\n"],"names":["path","config","children"],"mappings":";;;;;;AAwBA,IAAI,OAAO;AACX,MAAM,YAAY,MAAM;AACxB,MAAM,UAAU,CAAC,SAAkB;AAC1B,SAAA;AACT;AAEO,SAAS,8BAA8B,QAAwB;AAChE,MAAA,OAAe,QAAQ,IAAI;AAE/B,QAAM,yBAAyB,MAAM;AAC5B,WAAA,WAAW,OAAO,eAAe,IACpC,OAAO,kBACP,KAAK,MAAM,OAAO,eAAe;AAAA,EACvC;AAEA,QAAM,WAAW,YAAY;AAC3B,QAAI,aAAa;AACf;AAAA,IAAA;AAGF,YAAQ,IAAI;AAER,QAAA;AACI,YAAA,UAAU,QAAQ,IAAI;AAAA,aACrB,KAAK;AACZ,cAAQ,MAAM,GAAG;AACjB,cAAQ,KAAK;AAAA,IAAA,UACb;AACA,cAAQ,KAAK;AAAA,IAAA;AAAA,EAEjB;AAEM,QAAA,aAAa,OAAO,SAAiB;AACnC,UAAA,WAAW,UAAU,IAAI;A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GAAG,CAAC;AAC/B,QAAA,aAAa,IAAI,IAAI,IAAI;AAC3B,MAAA,KAAK,WAAW,WAAW,MAAM;AAC7B,UAAA,gBAAgB,KAAK,OAAO,CAAC,GAAG,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;AACjE,UAAM,mBAAmB,OAAO;AAAA,MAAO,CAAC,MACtC,cAAc,SAAS,EAAE,GAAG,CAAC;AAAA,IAC/B;AACO,WAAA;AAAA,EAAA;AAEF,SAAA;AACT;AAEA,SAAS,6BACP,SACA,QACA;AACA,QAAM,SAAS,QAAQ,IAAI,CAAC,MAAM;AAC1B,UAAA,mBAAmB,cAAc,CAAC;AACjC,WAAA,EAAE,GAAG,GAAG,iBAAiB;AAAA,EAAA,CACjC;AAEK,QAAA,mBAAmB,YAAY,QAAQ,kBAAkB;AAE/D,MAAI,qBAAqB,QAAW;AAClC,UAAM,eAAe,qEAAqE,iBAAiB,SAAS,IAAI,MAAM,EAAE,KAAK,iBAClI,IAAI,CAAC,MAAM,IAAI,EAAE,gBAAgB,GAAG,EACpC,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA,GAEO,iBAAiB,IAAI,CAAC,MAAM,KAAK,QAAQ,OAAO,iBAAiB,EAAE,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAAA;AAC7G,YAAQ,MAAM,YAAY;AAC1B,YAAQ,KAAK,CAAC;AAAA,EAAA;AAElB;"}
1
+ {"version":3,"file":"plugin.js","sources":["../../../src/start-server-routes-plugin/plugin.ts"],"sourcesContent":["import path, { isAbsolute, join, normalize } from 'node:path'\nimport fs from 'node:fs'\nimport fsp from 'node:fs/promises'\nimport {\n format,\n logging,\n multiSortBy,\n physicalGetRouteNodes,\n removeExt,\n removeUnderscores,\n replaceBackslash,\n resetRegex,\n rootPathId,\n routePathToVariable,\n trimPathLeft,\n virtualGetRouteNodes,\n writeIfDifferent,\n} from '@tanstack/router-generator'\nimport { rootRouteId } from '@tanstack/router-core'\nimport { fillTemplate, getTargetTemplate } from './template'\nimport type { GetRouteNodesResult, RouteNode } from '@tanstack/router-generator'\nimport type { Config } from './config'\nimport type { Plugin } from 'vite'\n\nlet lock = false\nconst checkLock = () => lock\nconst setLock = (bool: boolean) => {\n lock = bool\n}\n\nexport function TanStackStartServerRoutesVite(config: Config): Plugin {\n let ROOT: string = process.cwd()\n const moduleId = 'tanstack-start-server-routes-manifest:v'\n\n const getRoutesDirectoryPath = () => {\n return isAbsolute(config.routesDirectory)\n ? config.routesDirectory\n : join(ROOT, config.routesDirectory)\n }\n\n const generate = async () => {\n if (checkLock()) {\n return\n }\n\n setLock(true)\n\n try {\n await generator(config, ROOT)\n } catch (err) {\n console.error(err)\n console.info()\n } finally {\n setLock(false)\n }\n }\n\n const handleFile = async (file: string) => {\n const filePath = normalize(file)\n\n const routesDirectoryPath = getRoutesDirectoryPath()\n if (filePath.startsWith(routesDirectoryPath)) {\n await generate()\n }\n }\n\n return {\n name: 'tanstack-start-server-routes-plugin',\n configureServer(server) {\n server.watcher.on('all', (event, path) => {\n handleFile(path)\n })\n },\n configResolved(config) {\n ROOT = config.root\n },\n async buildStart() {\n await generate()\n // if (this.environment.name === 'server') {\n // }\n },\n sharedDuringBuild: true,\n resolveId(id) {\n if (id === moduleId) {\n const generatedRouteTreePath = getGeneratedRouteTreePath(ROOT)\n return generatedRouteTreePath\n }\n return null\n },\n }\n}\n\n// Maybe import this from `@tanstack/router-core` in the future???\nlet latestTask = 0\nconst routeGroupPatternRegex = /\\(.+\\)/g\nconst possiblyNestedRouteGroupPatternRegex = /\\([^/]+\\)\\/?/g\n\nlet isFirst = false\nlet skipMessage = false\n\nfunction getGeneratedRouteTreePath(root: string) {\n return path.resolve(root, '.tanstack-start/server-routes/routeTree.gen.ts')\n}\n\nasync function generator(config: Config, root: string) {\n const generatedServerRouteTreePath = getGeneratedRouteTreePath(root)\n const ROUTE_TEMPLATE = getTargetTemplate(config.target)\n const logger = logging({ disabled: config.disableLogging })\n\n if (!isFirst) {\n // logger.log('♻️ Generating server routes...')\n isFirst = true\n } else if (skipMessage) {\n skipMessage = false\n } else {\n // logger.log('♻️ Regenerating server routes...')\n }\n\n const taskId = latestTask + 1\n latestTask = taskId\n\n const checkLatest = () => {\n if (latestTask !== taskId) {\n skipMessage = true\n return false\n }\n\n return true\n }\n\n const start = Date.now()\n\n let getRouteNodesResult: GetRouteNodesResult\n\n if (config.virtualRouteConfig) {\n getRouteNodesResult = await virtualGetRouteNodes(config, root)\n } else {\n getRouteNodesResult = await physicalGetRouteNodes(config, root)\n }\n\n const { rootRouteNode, routeNodes: beforeRouteNodes } = getRouteNodesResult\n if (rootRouteNode === undefined) {\n let errorMessage = `rootRouteNode must not be undefined. Make sure you've added your root route into the route-tree.`\n if (!config.virtualRouteConfig) {\n errorMessage += `\\nMake sure that you add a \"${rootPathId}.tsx\" file to your routes directory.\\nAdd the file in: \"${config.routesDirectory}/${rootPathId}.tsx\"`\n }\n throw new Error(errorMessage)\n }\n\n const preRouteNodes = multiSortBy(beforeRouteNodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) =>\n d.filePath.match(new RegExp(`[./]${config.indexToken}[.]`)) ? 1 : -1,\n (d) =>\n d.filePath.match(\n /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,\n )\n ? 1\n : -1,\n (d) =>\n d.filePath.match(new RegExp(`[./]${config.routeToken}[.]`)) ? -1 : 1,\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ''))\n\n const routeTree: Array<RouteNode> = []\n\n // Loop over the flat list of routeNodes and\n // build up a tree based on the routeNodes' routePath\n const routeNodes: Array<RouteNode> = []\n\n // the handleRootNode function is not being collapsed into the handleNode function\n // because it requires only a subset of the logic that the handleNode function requires\n // and it's easier to read and maintain this way\n const handleRootNode = async (node?: RouteNode) => {\n if (!node) {\n // currently this is not being handled, but it could be in the future\n // for example to handle a virtual root route\n return\n }\n\n // from here on, we are only handling the root node that's present in the file system\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n if (!routeCode) {\n const _rootTemplate = ROUTE_TEMPLATE.rootRoute\n const replaced = await fillTemplate(config, _rootTemplate.template(), {\n tsrImports: _rootTemplate.imports.tsrImports(),\n tsrPath: rootPathId,\n tsrExportStart: _rootTemplate.imports.tsrExportStart(),\n tsrExportEnd: _rootTemplate.imports.tsrExportEnd(),\n })\n\n await writeIfDifferent(\n node.fullPath,\n '', // Empty string because the file doesn't exist yet\n replaced,\n {\n beforeWrite: () => {\n // logger.log(`🟡 Creating ${node.fullPath}`)\n },\n },\n )\n }\n }\n\n await handleRootNode(rootRouteNode)\n\n const handleNode = async (node: RouteNode) => {\n // Do not remove this as we need to set the lastIndex to 0 as it\n // is necessary to reset the regex's index when using the global flag\n // otherwise it might not match the next time it's used\n resetRegex(routeGroupPatternRegex)\n\n let parentRoute = hasParentRoute(routeNodes, node, node.routePath)\n\n // if the parent route is a virtual parent route, we need to find the real parent route\n if (parentRoute?.isVirtualParentRoute && parentRoute.children?.length) {\n // only if this sub-parent route returns a valid parent route, we use it, if not leave it as it\n const possibleParentRoute = hasParentRoute(\n parentRoute.children,\n node,\n node.routePath,\n )\n if (possibleParentRoute) {\n parentRoute = possibleParentRoute\n }\n }\n\n if (parentRoute) node.parent = parentRoute\n\n node.path = determineNodePath(node)\n\n const trimmedPath = trimPathLeft(node.path ?? '')\n\n const split = trimmedPath.split('/')\n const lastRouteSegment = split[split.length - 1] ?? trimmedPath\n\n node.isNonPath =\n lastRouteSegment.startsWith('_') ||\n routeGroupPatternRegex.test(lastRouteSegment)\n\n node.cleanedPath = removeGroups(\n removeUnderscores(removeLayoutSegments(node.path)) ?? '',\n )\n\n const stats = fs.statSync(node.fullPath)\n const routeCode = stats.isFile()\n ? fs.readFileSync(node.fullPath, 'utf-8')\n : ''\n\n // Ensure the boilerplate for the route exists, which can be skipped for virtual parent routes and virtual routes\n if (!node.isVirtualParentRoute && !node.isVirtual) {\n // const escapedRoutePath = node.routePath?.replaceAll('$', '$$') ?? ''\n // let replaced = routeCode\n // await writeIfDifferent(node.fullPath, routeCode, replaced, {\n // beforeWrite: () => {\n // // logger.log(`🟡 Updating ${node.fullPath}`)\n // },\n // })\n }\n\n const cleanedPathIsEmpty = (node.cleanedPath || '').length === 0\n const nonPathRoute =\n node._fsRouteType === 'pathless_layout' && node.isNonPath\n\n node.isVirtualParentRequired =\n node._fsRouteType === 'pathless_layout' || nonPathRoute\n ? !cleanedPathIsEmpty\n : false\n\n if (!node.isVirtual && node.isVirtualParentRequired) {\n const parentRoutePath = removeLastSegmentFromPath(node.routePath) || '/'\n const parentVariableName = routePathToVariable(parentRoutePath)\n\n const anchorRoute = routeNodes.find(\n (d) => d.routePath === parentRoutePath,\n )\n\n if (!anchorRoute) {\n const parentNode: RouteNode = {\n ...node,\n path: removeLastSegmentFromPath(node.path) || '/',\n filePath: removeLastSegmentFromPath(node.filePath) || '/',\n fullPath: removeLastSegmentFromPath(node.fullPath) || '/',\n routePath: parentRoutePath,\n variableName: parentVariableName,\n isVirtual: true,\n _fsRouteType: 'layout', // layout since this route will wrap other routes\n isVirtualParentRoute: true,\n isVirtualParentRequired: false,\n }\n\n parentNode.children = parentNode.children ?? []\n parentNode.children.push(node)\n\n node.parent = parentNode\n\n if (node._fsRouteType === 'pathless_layout') {\n // since `node.path` is used as the `id` on the route definition, we need to update it\n node.path = determineNodePath(node)\n }\n\n await handleNode(parentNode)\n } else {\n anchorRoute.children = anchorRoute.children ?? []\n anchorRoute.children.push(node)\n\n node.parent = anchorRoute\n }\n }\n\n if (\n !routeCode\n .split('\\n')\n .some((line) => line.trim().startsWith('export const ServerRoute'))\n ) {\n return\n }\n\n if (node.parent) {\n if (!node.isVirtualParentRequired) {\n node.parent.children = node.parent.children ?? []\n node.parent.children.push(node)\n }\n } else {\n routeTree.push(node)\n }\n\n routeNodes.push(node)\n }\n\n for (const node of preRouteNodes) {\n await handleNode(node)\n }\n\n // This is run against the `routeNodes` array since it\n // has the accumulated (intended) Server Route nodes\n // Since TSR allows multiple way of defining a route,\n // we need to ensure that a user hasn't defined the\n // same route in multiple ways (i.e. `flat`, `nested`, `virtual`)\n checkRouteFullPathUniqueness(routeNodes, config)\n\n function buildRouteTreeConfig(nodes: Array<RouteNode>, depth = 1): string {\n const children = nodes.map((node) => {\n if (node._fsRouteType === '__root') {\n return\n }\n\n if (node._fsRouteType === 'pathless_layout' && !node.children?.length) {\n return\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = buildRouteTreeConfig(node.children, depth + 1)\n\n const childrenDeclaration = `interface ${route}Children {\n ${node.children.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`\n\n const children = `const ${route}Children: ${route}Children = {\n ${node.children.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`\n\n const routeWithChildren = `const ${route}WithChildren = ${route}._addFileChildren(${route}Children)`\n\n return [\n childConfigs,\n childrenDeclaration,\n children,\n routeWithChildren,\n ].join('\\n\\n')\n }\n\n return undefined\n })\n\n return children.filter(Boolean).join('\\n\\n')\n }\n\n const routeConfigChildrenText = buildRouteTreeConfig(routeTree)\n\n const sortedRouteNodes = multiSortBy(routeNodes, [\n (d) => (d.routePath?.includes(`/${rootPathId}`) ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.routePath?.endsWith(config.indexToken) ? -1 : 1),\n (d) => d,\n ])\n\n const imports = Object.entries({\n createFileRoute: sortedRouteNodes.some((d) => d.isVirtual),\n })\n .filter((d) => d[1])\n .map((d) => d[0])\n\n const virtualRouteNodes = sortedRouteNodes.filter((d) => d.isVirtual)\n\n function getImportPath(node: RouteNode) {\n return replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(generatedServerRouteTreePath),\n path.resolve(config.routesDirectory, node.filePath),\n ),\n ),\n )\n }\n\n const rootRouteExists = fs.existsSync(rootRouteNode.fullPath)\n const rootRouteCode = rootRouteExists\n ? fs.readFileSync(rootRouteNode.fullPath, 'utf-8')\n : ''\n const hasServerRootRoute =\n rootRouteExists && rootRouteCode.includes('export const ServerRoute')\n\n const routeImports = [\n ...config.routeTreeFileHeader,\n `// This file was automatically generated by TanStack Router.\n// You should NOT make any changes in this file as it will be overwritten.\n// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.`,\n imports.length\n ? `import { ${imports.join(', ')} } from '${ROUTE_TEMPLATE.fullPkg}'\\n`\n : '',\n '// Import Routes',\n [\n `import type { FileRoutesByPath, CreateServerFileRoute } from '${ROUTE_TEMPLATE.fullPkg}'`,\n `import { createServerRoute, createServerFileRoute } from '${ROUTE_TEMPLATE.fullPkg}'`,\n hasServerRootRoute\n ? `import { ServerRoute as rootRouteImport } from './${getImportPath(rootRouteNode)}'`\n : '',\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { ServerRoute as ${\n node.variableName\n }RouteImport } from './${getImportPath(node)}'`\n }),\n ].join('\\n'),\n virtualRouteNodes.length ? '// Create Virtual Routes' : '',\n virtualRouteNodes\n .map((node) => {\n return `const ${\n node.variableName\n }RouteImport = createFileRoute('${node.routePath}')()`\n })\n .join('\\n'),\n '// Create/Update Routes',\n !hasServerRootRoute\n ? `\n const rootRoute = createServerRoute()\n `\n : '',\n sortedRouteNodes\n .map((node) => {\n return [\n [\n `const ${node.variableName}Route = ${node.variableName}RouteImport.update({\n ${[\n `id: '${node.path}'`,\n !node.isNonPath ? `path: '${node.cleanedPath}'` : undefined,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n } as any)`,\n ].join(''),\n ].join('\\n\\n')\n })\n .join('\\n\\n'),\n '',\n\n '// Populate the FileRoutesByPath interface',\n `declare module '${ROUTE_TEMPLATE.fullPkg}' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n const filePathId = routeNode.routePath\n\n return `'${filePathId}': {\n id: '${filePathId}'\n path: '${inferPath(routeNode)}'\n fullPath: '${inferFullPath(routeNode)}'\n preLoaderRoute: typeof ${routeNode.variableName}RouteImport\n parentRoute: typeof ${\n routeNode.isVirtualParentRequired\n ? `${routeNode.parent?.variableName}Route`\n : routeNode.parent?.variableName\n ? `${routeNode.parent.variableName}RouteImport`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n `// Add type-safety to the createFileRoute function across the route tree`,\n routeNodes\n .map((routeNode) => {\n return `declare module './${getImportPath(routeNode)}' {\nconst createServerFileRoute: CreateServerFileRoute<\nFileRoutesByPath['${routeNode.routePath}']['parentRoute'],\nFileRoutesByPath['${routeNode.routePath}']['id'],\nFileRoutesByPath['${routeNode.routePath}']['path'],\nFileRoutesByPath['${routeNode.routePath}']['fullPath'],\n${routeNode.children?.length ? `${routeNode.variableName}RouteChildren` : 'unknown'}\n>\n}`\n })\n .join('\\n'),\n '// Create and export the route tree',\n routeConfigChildrenText,\n `export interface FileRoutesByFullPath {\n ${[...createRouteNodesByFullPath(routeNodes).entries()].map(\n ([fullPath, routeNode]) => {\n return `'${fullPath}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n },\n )}\n}`,\n `export interface FileRoutesByTo {\n ${[...createRouteNodesByTo(routeNodes).entries()].map(([to, routeNode]) => {\n return `'${to}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n })}\n}`,\n `export interface FileRoutesById {\n '${rootRouteId}': typeof rootRoute,\n ${[...createRouteNodesById(routeNodes).entries()].map(([id, routeNode]) => {\n return `'${id}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n })}\n}`,\n `export interface FileRouteTypes {\n fileRoutesByFullPath: FileRoutesByFullPath\n fullPaths: ${routeNodes.length > 0 ? [...createRouteNodesByFullPath(routeNodes).keys()].map((fullPath) => `'${fullPath}'`).join('|') : 'never'}\n fileRoutesByTo: FileRoutesByTo\n to: ${routeNodes.length > 0 ? [...createRouteNodesByTo(routeNodes).keys()].map((to) => `'${to}'`).join('|') : 'never'}\n id: ${[`'${rootRouteId}'`, ...[...createRouteNodesById(routeNodes).keys()].map((id) => `'${id}'`)].join('|')}\n fileRoutesById: FileRoutesById\n}`,\n `export interface RootRouteChildren {\n ${routeTree.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`,\n `const rootRouteChildren: RootRouteChildren = {\n ${routeTree.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`,\n `export const routeTree = rootRoute._addFileChildren(rootRouteChildren)._addFileTypes<FileRouteTypes>()`,\n ]\n .filter(Boolean)\n .join('\\n\\n')\n\n const createRouteManifest = () => {\n const routesManifest = {\n [rootRouteId]: {\n filePath: rootRouteNode.filePath,\n children: routeTree.map((d) => d.routePath),\n },\n ...Object.fromEntries(\n routeNodes.map((d) => {\n const filePathId = d.routePath\n\n return [\n filePathId,\n {\n filePath: d.filePath,\n parent: d.parent?.routePath ? d.parent.routePath : undefined,\n children: d.children?.map((childRoute) => childRoute.routePath),\n },\n ]\n }),\n ),\n }\n\n return JSON.stringify(\n {\n routes: routesManifest,\n },\n null,\n 2,\n )\n }\n\n const includeManifest = ['react', 'solid']\n const routeConfigFileContent = !includeManifest.includes(config.target)\n ? routeImports\n : [\n routeImports,\n '\\n',\n '/* ROUTE_MANIFEST_START',\n createRouteManifest(),\n 'ROUTE_MANIFEST_END */',\n ].join('\\n')\n\n if (!checkLatest()) return\n\n const existingRouteTreeContent = await fsp\n .readFile(path.resolve(generatedServerRouteTreePath), 'utf-8')\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return ''\n }\n\n throw err\n })\n\n if (!checkLatest()) return\n\n // Ensure the directory exists\n await fsp.mkdir(path.dirname(path.resolve(generatedServerRouteTreePath)), {\n recursive: true,\n })\n\n if (!checkLatest()) return\n\n // Write the route tree file, if it has changed\n const routeTreeWriteResult = await writeIfDifferent(\n path.resolve(generatedServerRouteTreePath),\n await format(existingRouteTreeContent, config),\n await format(routeConfigFileContent, config),\n {\n beforeWrite: () => {\n // logger.log(`🟡 Updating ${generatedRouteTreePath}`)\n },\n },\n )\n\n // Write declaration file\n const startDeclarationFilePath = path.join(\n path.resolve(root, config.srcDirectory),\n 'tanstack-start.d.ts',\n )\n const serverRoutesRelativePath = removeExt(\n path.relative(\n path.dirname(startDeclarationFilePath),\n generatedServerRouteTreePath,\n ),\n )\n const startDeclarationFileContent = buildStartDeclarationFile({\n serverRoutesRelativePath,\n })\n if (!fs.existsSync(startDeclarationFilePath)) {\n await writeIfDifferent(\n startDeclarationFilePath,\n '',\n startDeclarationFileContent,\n {\n beforeWrite: () => {\n logger.log(`🟡 Creating tanstack-start.d.ts`)\n },\n },\n )\n } else {\n const existingDeclarationFileContent = await fsp\n .readFile(startDeclarationFilePath, 'utf-8')\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return ''\n }\n throw err\n })\n await writeIfDifferent(\n startDeclarationFilePath,\n existingDeclarationFileContent,\n startDeclarationFileContent,\n {\n beforeWrite: () => {\n logger.log(`🟡 Updating tanstack-start.d.ts`)\n },\n },\n )\n }\n\n if (routeTreeWriteResult && !checkLatest()) {\n return\n }\n\n // logger.log(\n // `✅ Processed ${routeNodes.length === 1 ? 'server route' : 'server routes'} in ${\n // Date.now() - start\n // }ms`,\n // )\n}\n\nfunction buildStartDeclarationFile({\n serverRoutesRelativePath,\n}: {\n serverRoutesRelativePath: string\n}) {\n const serverRoutesPath = replaceBackslash(serverRoutesRelativePath)\n return (\n [\n '/// <reference types=\"vite/client\" />',\n `import '${serverRoutesPath}'`,\n ].join('\\n') + '\\n'\n )\n}\n\nfunction removeGroups(s: string) {\n return s.replace(possiblyNestedRouteGroupPatternRegex, '')\n}\n\n/**\n * The `node.path` is used as the `id` in the route definition.\n * This function checks if the given node has a parent and if so, it determines the correct path for the given node.\n * @param node - The node to determine the path for.\n * @returns The correct path for the given node.\n */\nfunction determineNodePath(node: RouteNode) {\n return (node.path = node.parent\n ? node.routePath?.replace(node.parent.routePath ?? '', '') || '/'\n : node.routePath)\n}\n\n/**\n * Removes the last segment from a given path. Segments are considered to be separated by a '/'.\n *\n * @param {string} routePath - The path from which to remove the last segment. Defaults to '/'.\n * @returns {string} The path with the last segment removed.\n * @example\n * removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth'\n */\nfunction removeLastSegmentFromPath(routePath: string = '/'): string {\n const segments = routePath.split('/')\n segments.pop() // Remove the last segment\n return segments.join('/')\n}\n\n/**\n * Removes all segments from a given path that start with an underscore ('_').\n *\n * @param {string} routePath - The path from which to remove segments. Defaults to '/'.\n * @returns {string} The path with all underscore-prefixed segments removed.\n * @example\n * removeLayoutSegments('/workspace/_auth/foo') // '/workspace/foo'\n */\nfunction removeLayoutSegments(routePath: string = '/'): string {\n const segments = routePath.split('/')\n const newSegments = segments.filter((segment) => !segment.startsWith('_'))\n return newSegments.join('/')\n}\n\nfunction hasParentRoute(\n routes: Array<RouteNode>,\n node: RouteNode,\n routePathToCheck: string | undefined,\n): RouteNode | null {\n if (!routePathToCheck || routePathToCheck === '/') {\n return null\n }\n\n const sortedNodes = multiSortBy(routes, [\n (d) => d.routePath!.length * -1,\n (d) => d.variableName,\n ]).filter((d) => d.routePath !== `/${rootPathId}`)\n\n for (const route of sortedNodes) {\n if (route.routePath === '/') continue\n\n if (\n routePathToCheck.startsWith(`${route.routePath}/`) &&\n route.routePath !== routePathToCheck\n ) {\n return route\n }\n }\n\n const segments = routePathToCheck.split('/')\n segments.pop() // Remove the last segment\n const parentRoutePath = segments.join('/')\n\n return hasParentRoute(routes, node, parentRoutePath)\n}\n\n/**\n * Gets the final variable name for a route\n */\nconst getResolvedRouteNodeVariableName = (routeNode: RouteNode): string => {\n return routeNode.children?.length\n ? `${routeNode.variableName}RouteWithChildren`\n : `${routeNode.variableName}Route`\n}\n\n/**\n * Creates a map from fullPath to routeNode\n */\nconst createRouteNodesByFullPath = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => [inferFullPath(routeNode), routeNode]),\n )\n}\n\n/**\n * Create a map from 'to' to a routeNode\n */\nconst createRouteNodesByTo = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n dedupeBranchesAndIndexRoutes(routeNodes).map((routeNode) => [\n inferTo(routeNode),\n routeNode,\n ]),\n )\n}\n\n/**\n * Create a map from 'id' to a routeNode\n */\nconst createRouteNodesById = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => {\n const id = routeNode.routePath ?? ''\n return [id, routeNode]\n }),\n )\n}\n\n/**\n * Infers the full path for use by TS\n */\nconst inferFullPath = (routeNode: RouteNode): string => {\n const fullPath = removeGroups(\n removeUnderscores(removeLayoutSegments(routeNode.routePath)) ?? '',\n )\n\n return routeNode.cleanedPath === '/' ? fullPath : fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Infers the path for use by TS\n */\nconst inferPath = (routeNode: RouteNode): string => {\n return routeNode.cleanedPath === '/'\n ? routeNode.cleanedPath\n : (routeNode.cleanedPath?.replace(/\\/$/, '') ?? '')\n}\n\n/**\n * Infers to path\n */\nconst inferTo = (routeNode: RouteNode): string => {\n const fullPath = inferFullPath(routeNode)\n\n if (fullPath === '/') return fullPath\n\n return fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Dedupes branches and index routes\n */\nconst dedupeBranchesAndIndexRoutes = (\n routes: Array<RouteNode>,\n): Array<RouteNode> => {\n return routes.filter((route) => {\n if (route.children?.find((child) => child.cleanedPath === '/')) return false\n return true\n })\n}\n\nfunction checkUnique<TElement>(routes: Array<TElement>, key: keyof TElement) {\n // Check no two routes have the same `key`\n // if they do, throw an error with the conflicting filePaths\n const keys = routes.map((d) => d[key])\n const uniqueKeys = new Set(keys)\n if (keys.length !== uniqueKeys.size) {\n const duplicateKeys = keys.filter((d, i) => keys.indexOf(d) !== i)\n const conflictingFiles = routes.filter((d) =>\n duplicateKeys.includes(d[key]),\n )\n return conflictingFiles\n }\n return undefined\n}\n\nfunction checkRouteFullPathUniqueness(\n _routes: Array<RouteNode>,\n config: Config,\n) {\n const routes = _routes.map((d) => {\n const inferredFullPath = inferFullPath(d)\n return { ...d, inferredFullPath }\n })\n\n const conflictingFiles = checkUnique(routes, 'inferredFullPath')\n\n if (conflictingFiles !== undefined) {\n const errorMessage = `Conflicting configuration paths were found for the following route${conflictingFiles.length > 1 ? 's' : ''}: ${conflictingFiles\n .map((p) => `\"${p.inferredFullPath}\"`)\n .join(', ')}.\nPlease ensure each Server Route has a unique full path.\nConflicting files: \\n ${conflictingFiles.map((d) => path.resolve(config.routesDirectory, d.filePath)).join('\\n ')}\\n`\n console.error(errorMessage)\n process.exit(1)\n }\n}\n"],"names":["path","config","children"],"mappings":";;;;;;AAwBA,IAAI,OAAO;AACX,MAAM,YAAY,MAAM;AACxB,MAAM,UAAU,CAAC,SAAkB;AAC1B,SAAA;AACT;AAEO,SAAS,8BAA8B,QAAwB;AAChE,MAAA,OAAe,QAAQ,IAAI;AAC/B,QAAM,WAAW;AAEjB,QAAM,yBAAyB,MAAM;AAC5B,WAAA,WAAW,OAAO,eAAe,IACpC,OAAO,kBACP,KAAK,MAAM,OAAO,eAAe;AAAA,EACvC;AAEA,QAAM,WAAW,YAAY;AAC3B,QAAI,aAAa;AACf;AAAA,IAAA;AAGF,YAAQ,IAAI;AAER,QAAA;AACI,YAAA,UAAU,QAAQ,IAAI;AAAA,aACrB,KAAK;AACZ,cAAQ,MAAM,GAAG;AACjB,cAAQ,KAAK;AAAA,IAAA,UACb;AACA,cAAQ,KAAK;AAAA,IAAA;AAAA,EAEjB;AAEM,QAAA,aAAa,OAAO,SAAiB;AACnC,UAAA,WAAW,UAAU,IAAI;AAE/B,UAAM,sBAAsB,uBAAuB;AAC/C,QAAA,SAAS,WAAW,mBAAmB,GAAG;AAC5C,YAAM,SAAS;AAAA,IAAA;AAAA,EAEnB;AAE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AW,MAAM;AAC7B,UAAA,gBAAgB,KAAK,OAAO,CAAC,GAAG,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;AACjE,UAAM,mBAAmB,OAAO;AAAA,MAAO,CAAC,MACtC,cAAc,SAAS,EAAE,GAAG,CAAC;AAAA,IAC/B;AACO,WAAA;AAAA,EAAA;AAEF,SAAA;AACT;AAEA,SAAS,6BACP,SACA,QACA;AACA,QAAM,SAAS,QAAQ,IAAI,CAAC,MAAM;AAC1B,UAAA,mBAAmB,cAAc,CAAC;AACjC,WAAA,EAAE,GAAG,GAAG,iBAAiB;AAAA,EAAA,CACjC;AAEK,QAAA,mBAAmB,YAAY,QAAQ,kBAAkB;AAE/D,MAAI,qBAAqB,QAAW;AAClC,UAAM,eAAe,qEAAqE,iBAAiB,SAAS,IAAI,MAAM,EAAE,KAAK,iBAClI,IAAI,CAAC,MAAM,IAAI,EAAE,gBAAgB,GAAG,EACpC,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA,GAEO,iBAAiB,IAAI,CAAC,MAAM,KAAK,QAAQ,OAAO,iBAAiB,EAAE,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAAA;AAC7G,YAAQ,MAAM,YAAY;AAC1B,YAAQ,KAAK,CAAC;AAAA,EAAA;AAElB;"}
@@ -0,0 +1,8 @@
1
+ export declare function resolveViteId(id: string): string;
2
+ export declare function createLogger(prefix: string): {
3
+ log: (...args: any) => void;
4
+ debug: (...args: any) => void;
5
+ info: (...args: any) => void;
6
+ warn: (...args: any) => void;
7
+ error: (...args: any) => void;
8
+ };