@tanstack/start-plugin-core 1.121.0-alpha.24 → 1.121.0-alpha.26

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 (102) hide show
  1. package/dist/cjs/compilers.cjs +24 -10
  2. package/dist/cjs/compilers.cjs.map +1 -1
  3. package/dist/cjs/debug.cjs +5 -0
  4. package/dist/cjs/debug.cjs.map +1 -0
  5. package/dist/cjs/debug.d.cts +1 -0
  6. package/dist/cjs/nitro-plugin/build-sitemap.cjs +3 -3
  7. package/dist/cjs/nitro-plugin/build-sitemap.cjs.map +1 -1
  8. package/dist/cjs/nitro-plugin/plugin.cjs +2 -2
  9. package/dist/cjs/nitro-plugin/plugin.cjs.map +1 -1
  10. package/dist/cjs/nitro-plugin/prerender.cjs +3 -3
  11. package/dist/cjs/nitro-plugin/prerender.cjs.map +1 -1
  12. package/dist/cjs/plugin.cjs +19 -30
  13. package/dist/cjs/plugin.cjs.map +1 -1
  14. package/dist/cjs/plugin.d.cts +2 -4
  15. package/dist/cjs/schema.cjs +5 -5
  16. package/dist/cjs/schema.cjs.map +1 -1
  17. package/dist/cjs/schema.d.cts +32 -16
  18. package/dist/cjs/start-compiler-plugin.cjs +19 -17
  19. package/dist/cjs/start-compiler-plugin.cjs.map +1 -1
  20. package/dist/cjs/start-manifest-plugin/plugin.cjs +207 -0
  21. package/dist/cjs/start-manifest-plugin/plugin.cjs.map +1 -0
  22. package/dist/cjs/start-manifest-plugin/plugin.d.cts +3 -0
  23. package/dist/cjs/start-router-plugin/generator-plugins/routes-manifest-plugin.cjs +39 -0
  24. package/dist/cjs/start-router-plugin/generator-plugins/routes-manifest-plugin.cjs.map +1 -0
  25. package/dist/cjs/start-router-plugin/generator-plugins/routes-manifest-plugin.d.cts +6 -0
  26. package/dist/cjs/start-router-plugin/generator-plugins/server-routes-plugin.cjs +121 -0
  27. package/dist/cjs/start-router-plugin/generator-plugins/server-routes-plugin.cjs.map +1 -0
  28. package/dist/cjs/start-router-plugin/generator-plugins/server-routes-plugin.d.cts +2 -0
  29. package/dist/cjs/start-router-plugin/plugin.cjs +21 -0
  30. package/dist/cjs/start-router-plugin/plugin.cjs.map +1 -0
  31. package/dist/cjs/start-router-plugin/plugin.d.cts +3 -0
  32. package/dist/cjs/start-router-plugin/route-tree-client-plugin.cjs +72 -0
  33. package/dist/cjs/start-router-plugin/route-tree-client-plugin.cjs.map +1 -0
  34. package/dist/cjs/start-router-plugin/route-tree-client-plugin.d.cts +6 -0
  35. package/dist/cjs/start-router-plugin/virtual-route-tree-plugin.cjs +30 -0
  36. package/dist/cjs/start-router-plugin/virtual-route-tree-plugin.cjs.map +1 -0
  37. package/dist/cjs/start-router-plugin/virtual-route-tree-plugin.d.cts +4 -0
  38. package/dist/esm/compilers.js +24 -10
  39. package/dist/esm/compilers.js.map +1 -1
  40. package/dist/esm/debug.d.ts +1 -0
  41. package/dist/esm/debug.js +5 -0
  42. package/dist/esm/debug.js.map +1 -0
  43. package/dist/esm/plugin.d.ts +2 -4
  44. package/dist/esm/plugin.js +10 -21
  45. package/dist/esm/plugin.js.map +1 -1
  46. package/dist/esm/schema.d.ts +32 -16
  47. package/dist/esm/start-compiler-plugin.js +19 -17
  48. package/dist/esm/start-compiler-plugin.js.map +1 -1
  49. package/dist/esm/start-manifest-plugin/plugin.d.ts +3 -0
  50. package/dist/esm/start-manifest-plugin/plugin.js +207 -0
  51. package/dist/esm/start-manifest-plugin/plugin.js.map +1 -0
  52. package/dist/esm/start-router-plugin/generator-plugins/routes-manifest-plugin.d.ts +6 -0
  53. package/dist/esm/start-router-plugin/generator-plugins/routes-manifest-plugin.js +39 -0
  54. package/dist/esm/start-router-plugin/generator-plugins/routes-manifest-plugin.js.map +1 -0
  55. package/dist/esm/start-router-plugin/generator-plugins/server-routes-plugin.d.ts +2 -0
  56. package/dist/esm/start-router-plugin/generator-plugins/server-routes-plugin.js +121 -0
  57. package/dist/esm/start-router-plugin/generator-plugins/server-routes-plugin.js.map +1 -0
  58. package/dist/esm/start-router-plugin/plugin.d.ts +3 -0
  59. package/dist/esm/start-router-plugin/plugin.js +21 -0
  60. package/dist/esm/start-router-plugin/plugin.js.map +1 -0
  61. package/dist/esm/start-router-plugin/route-tree-client-plugin.d.ts +6 -0
  62. package/dist/esm/start-router-plugin/route-tree-client-plugin.js +55 -0
  63. package/dist/esm/start-router-plugin/route-tree-client-plugin.js.map +1 -0
  64. package/dist/esm/start-router-plugin/virtual-route-tree-plugin.d.ts +4 -0
  65. package/dist/esm/start-router-plugin/virtual-route-tree-plugin.js +30 -0
  66. package/dist/esm/start-router-plugin/virtual-route-tree-plugin.js.map +1 -0
  67. package/package.json +6 -5
  68. package/src/compilers.ts +31 -131
  69. package/src/debug.ts +3 -0
  70. package/src/global.d.ts +8 -0
  71. package/src/plugin.ts +8 -24
  72. package/src/start-compiler-plugin.ts +24 -24
  73. package/src/start-manifest-plugin/plugin.ts +275 -0
  74. package/src/start-router-plugin/generator-plugins/routes-manifest-plugin.ts +43 -0
  75. package/src/start-router-plugin/generator-plugins/server-routes-plugin.ts +138 -0
  76. package/src/start-router-plugin/plugin.ts +35 -0
  77. package/src/start-router-plugin/route-tree-client-plugin.ts +76 -0
  78. package/src/start-router-plugin/virtual-route-tree-plugin.ts +30 -0
  79. package/dist/cjs/start-routes-manifest-plugin/plugin.cjs +0 -207
  80. package/dist/cjs/start-routes-manifest-plugin/plugin.cjs.map +0 -1
  81. package/dist/cjs/start-routes-manifest-plugin/plugin.d.cts +0 -3
  82. package/dist/cjs/start-server-routes-plugin/config.d.cts +0 -49
  83. package/dist/cjs/start-server-routes-plugin/plugin.cjs +0 -614
  84. package/dist/cjs/start-server-routes-plugin/plugin.cjs.map +0 -1
  85. package/dist/cjs/start-server-routes-plugin/plugin.d.cts +0 -3
  86. package/dist/cjs/start-server-routes-plugin/template.cjs +0 -111
  87. package/dist/cjs/start-server-routes-plugin/template.cjs.map +0 -1
  88. package/dist/cjs/start-server-routes-plugin/template.d.cts +0 -34
  89. package/dist/esm/start-routes-manifest-plugin/plugin.d.ts +0 -3
  90. package/dist/esm/start-routes-manifest-plugin/plugin.js +0 -207
  91. package/dist/esm/start-routes-manifest-plugin/plugin.js.map +0 -1
  92. package/dist/esm/start-server-routes-plugin/config.d.ts +0 -49
  93. package/dist/esm/start-server-routes-plugin/plugin.d.ts +0 -3
  94. package/dist/esm/start-server-routes-plugin/plugin.js +0 -614
  95. package/dist/esm/start-server-routes-plugin/plugin.js.map +0 -1
  96. package/dist/esm/start-server-routes-plugin/template.d.ts +0 -34
  97. package/dist/esm/start-server-routes-plugin/template.js +0 -111
  98. package/dist/esm/start-server-routes-plugin/template.js.map +0 -1
  99. package/src/start-routes-manifest-plugin/plugin.ts +0 -282
  100. package/src/start-server-routes-plugin/config.ts +0 -8
  101. package/src/start-server-routes-plugin/plugin.ts +0 -900
  102. package/src/start-server-routes-plugin/template.ts +0 -164
@@ -0,0 +1,121 @@
1
+ import { hasChildWithExport, checkRouteFullPathUniqueness, ensureStringArgument } from "@tanstack/router-generator";
2
+ const EXPORT_NAME = "ServerRoute";
3
+ function serverRoutesPlugin() {
4
+ return {
5
+ name: "server-routes-plugin",
6
+ transformPlugin: {
7
+ name: "server-routes-transform",
8
+ exportName: EXPORT_NAME,
9
+ imports: (ctx) => {
10
+ const targetModule = `@tanstack/${ctx.target}-start/server`;
11
+ const imports = {};
12
+ if (ctx.verboseFileRoutes === false) {
13
+ imports.banned = [
14
+ {
15
+ source: targetModule,
16
+ specifiers: [{ imported: "createServerFileRoute" }]
17
+ }
18
+ ];
19
+ } else {
20
+ imports.required = [
21
+ {
22
+ source: targetModule,
23
+ specifiers: [{ imported: "createServerFileRoute" }]
24
+ }
25
+ ];
26
+ }
27
+ return imports;
28
+ },
29
+ onExportFound: ({ ctx, decl }) => {
30
+ var _a;
31
+ let appliedChanges = false;
32
+ if (((_a = decl.init) == null ? void 0 : _a.type) === "CallExpression") {
33
+ let call = decl.init;
34
+ let callee = call.callee;
35
+ while (callee.type === "MemberExpression" && callee.object.type === "CallExpression") {
36
+ call = callee.object;
37
+ callee = call.callee;
38
+ }
39
+ if (call.callee.type === "Identifier" && call.callee.name === "createServerFileRoute") {
40
+ if (!ctx.verboseFileRoutes) {
41
+ if (call.arguments.length) {
42
+ call.arguments = [];
43
+ appliedChanges = true;
44
+ }
45
+ } else {
46
+ appliedChanges = ensureStringArgument(
47
+ call,
48
+ ctx.routeId,
49
+ ctx.preferredQuote
50
+ );
51
+ }
52
+ } else {
53
+ throw new Error(
54
+ `Expected "createServerFileRoute" call, but got "${call.callee.type}"`
55
+ );
56
+ }
57
+ }
58
+ return appliedChanges;
59
+ }
60
+ },
61
+ moduleAugmentation: ({ generator }) => ({
62
+ module: `@tanstack/${generator.config.target}-start/server`,
63
+ interfaceName: "ServerFileRoutesByPath"
64
+ }),
65
+ onRouteTreesChanged: ({ routeTrees, generator }) => {
66
+ const tree = routeTrees.find((tree2) => tree2.exportName === EXPORT_NAME);
67
+ if (tree) {
68
+ checkRouteFullPathUniqueness(tree.sortedRouteNodes, generator.config);
69
+ }
70
+ },
71
+ imports: (ctx) => {
72
+ var _a;
73
+ const imports = [];
74
+ const targetModule = `@tanstack/${ctx.generator.config.target}-start/server`;
75
+ if (ctx.generator.config.verboseFileRoutes === false) {
76
+ imports.push({
77
+ specifiers: [
78
+ { imported: "CreateServerFileRoute" },
79
+ { imported: "ServerFileRoutesByPath" }
80
+ ],
81
+ source: targetModule,
82
+ importKind: "type"
83
+ });
84
+ }
85
+ const hasMatchingRouteFiles = ctx.acc.routeNodes.length > 0;
86
+ if (hasMatchingRouteFiles) {
87
+ if (!((_a = ctx.rootRouteNode.exports) == null ? void 0 : _a.includes(EXPORT_NAME))) {
88
+ imports.push({
89
+ specifiers: [{ imported: "createServerRootRoute" }],
90
+ source: targetModule
91
+ });
92
+ }
93
+ }
94
+ return imports;
95
+ },
96
+ routeModuleAugmentation: ({ routeNode }) => {
97
+ if (routeNode._fsRouteType === "lazy") {
98
+ return void 0;
99
+ }
100
+ return `const createServerFileRoute: CreateServerFileRoute<
101
+ ServerFileRoutesByPath['${routeNode.routePath}']['parentRoute'],
102
+ ServerFileRoutesByPath['${routeNode.routePath}']['id'],
103
+ ServerFileRoutesByPath['${routeNode.routePath}']['path'],
104
+ ServerFileRoutesByPath['${routeNode.routePath}']['fullPath'],
105
+ ${hasChildWithExport(routeNode, "ServerRoute") ? `${routeNode.variableName}ServerRouteChildren` : "unknown"}
106
+ >`;
107
+ },
108
+ createRootRouteCode: () => `createServerRootRoute()`,
109
+ createVirtualRouteCode: ({ node }) => `createServerFileRoute('${node.routePath}')`,
110
+ config: ({ sortedRouteNodes }) => {
111
+ const hasMatchingRouteFiles = sortedRouteNodes.length > 0;
112
+ return {
113
+ virtualRootRoute: hasMatchingRouteFiles
114
+ };
115
+ }
116
+ };
117
+ }
118
+ export {
119
+ serverRoutesPlugin
120
+ };
121
+ //# sourceMappingURL=server-routes-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-routes-plugin.js","sources":["../../../../src/start-router-plugin/generator-plugins/server-routes-plugin.ts"],"sourcesContent":["import {\n checkRouteFullPathUniqueness,\n ensureStringArgument,\n hasChildWithExport,\n} from '@tanstack/router-generator'\n\nimport type {\n GeneratorPluginWithTransform,\n ImportDeclaration,\n TransformImportsConfig,\n} from '@tanstack/router-generator'\n\nconst EXPORT_NAME = 'ServerRoute'\nexport function serverRoutesPlugin(): GeneratorPluginWithTransform {\n return {\n name: 'server-routes-plugin',\n transformPlugin: {\n name: 'server-routes-transform',\n exportName: EXPORT_NAME,\n imports: (ctx) => {\n const targetModule = `@tanstack/${ctx.target}-start/server`\n const imports: TransformImportsConfig = {}\n if (ctx.verboseFileRoutes === false) {\n imports.banned = [\n {\n source: targetModule,\n specifiers: [{ imported: 'createServerFileRoute' }],\n },\n ]\n } else {\n imports.required = [\n {\n source: targetModule,\n specifiers: [{ imported: 'createServerFileRoute' }],\n },\n ]\n }\n return imports\n },\n onExportFound: ({ ctx, decl }) => {\n let appliedChanges = false\n if (decl.init?.type === 'CallExpression') {\n let call = decl.init\n let callee = call.callee\n\n while (\n callee.type === 'MemberExpression' &&\n callee.object.type === 'CallExpression'\n ) {\n call = callee.object\n callee = call.callee\n }\n if (\n call.callee.type === 'Identifier' &&\n call.callee.name === 'createServerFileRoute'\n ) {\n if (!ctx.verboseFileRoutes) {\n if (call.arguments.length) {\n call.arguments = []\n appliedChanges = true\n }\n } else {\n appliedChanges = ensureStringArgument(\n call,\n ctx.routeId,\n ctx.preferredQuote,\n )\n }\n } else {\n throw new Error(\n `Expected \"createServerFileRoute\" call, but got \"${call.callee.type}\"`,\n )\n }\n }\n return appliedChanges\n },\n },\n moduleAugmentation: ({ generator }) => ({\n module: `@tanstack/${generator.config.target}-start/server`,\n interfaceName: 'ServerFileRoutesByPath',\n }),\n onRouteTreesChanged: ({ routeTrees, generator }) => {\n const tree = routeTrees.find((tree) => tree.exportName === EXPORT_NAME)\n if (tree) {\n checkRouteFullPathUniqueness(tree.sortedRouteNodes, generator.config)\n }\n },\n imports: (ctx) => {\n const imports: Array<ImportDeclaration> = []\n\n const targetModule = `@tanstack/${ctx.generator.config.target}-start/server`\n if (ctx.generator.config.verboseFileRoutes === false) {\n imports.push({\n specifiers: [\n { imported: 'CreateServerFileRoute' },\n { imported: 'ServerFileRoutesByPath' },\n ],\n source: targetModule,\n importKind: 'type',\n })\n }\n // don't add the import if there are no server routes defined\n const hasMatchingRouteFiles = ctx.acc.routeNodes.length > 0\n if (hasMatchingRouteFiles) {\n // needs a virtual root route\n if (!ctx.rootRouteNode.exports?.includes(EXPORT_NAME)) {\n imports.push({\n specifiers: [{ imported: 'createServerRootRoute' }],\n source: targetModule,\n })\n }\n }\n return imports\n },\n routeModuleAugmentation: ({ routeNode }) => {\n // server routes don't support lazy routes\n if (routeNode._fsRouteType === 'lazy') {\n return undefined\n }\n return `const createServerFileRoute: CreateServerFileRoute<\n ServerFileRoutesByPath['${routeNode.routePath}']['parentRoute'],\n ServerFileRoutesByPath['${routeNode.routePath}']['id'],\n ServerFileRoutesByPath['${routeNode.routePath}']['path'],\n ServerFileRoutesByPath['${routeNode.routePath}']['fullPath'],\n ${hasChildWithExport(routeNode, 'ServerRoute') ? `${routeNode.variableName}ServerRouteChildren` : 'unknown'}\n >`\n },\n createRootRouteCode: () => `createServerRootRoute()`,\n createVirtualRouteCode: ({ node }) =>\n `createServerFileRoute('${node.routePath}')`,\n config: ({ sortedRouteNodes }) => {\n const hasMatchingRouteFiles = sortedRouteNodes.length > 0\n return {\n virtualRootRoute: hasMatchingRouteFiles,\n }\n },\n }\n}\n"],"names":["tree"],"mappings":"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"}
@@ -0,0 +1,3 @@
1
+ import { PluginOption } from 'vite';
2
+ import { Config } from '@tanstack/router-generator';
3
+ export declare function tanStackStartRouter(config: Config): Array<PluginOption>;
@@ -0,0 +1,21 @@
1
+ import { tanstackRouterGenerator, tanStackRouterCodeSplitter, tanstackRouterAutoImport } from "@tanstack/router-plugin/vite";
2
+ import { routeTreeClientPlugin } from "./route-tree-client-plugin.js";
3
+ import { virtualRouteTreePlugin } from "./virtual-route-tree-plugin.js";
4
+ import { routesManifestPlugin } from "./generator-plugins/routes-manifest-plugin.js";
5
+ import { serverRoutesPlugin } from "./generator-plugins/server-routes-plugin.js";
6
+ function tanStackStartRouter(config) {
7
+ return [
8
+ tanstackRouterGenerator({
9
+ ...config,
10
+ plugins: [serverRoutesPlugin(), routesManifestPlugin()]
11
+ }),
12
+ tanStackRouterCodeSplitter(config),
13
+ tanstackRouterAutoImport(config),
14
+ routeTreeClientPlugin(config),
15
+ virtualRouteTreePlugin(config)
16
+ ];
17
+ }
18
+ export {
19
+ tanStackStartRouter
20
+ };
21
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["../../../src/start-router-plugin/plugin.ts"],"sourcesContent":["/*\nwhat is this plugin doing, especially compared to one already existing in the @tanstack/router-plugin package?\n\nit configures:\n1. the generator to generate both the render-route-tree as well as the server-route-tree\n2. the code-splitter plugin, so it could possibly be enabled per environment (e.g. disable on the server)\n3. the auto import plugin for both environments\n4. the route tree client plugin, which removes the server part from the generated route tree\n5. the virtual route tree plugin, which provides the route tree to the server\n*/\n\nimport {\n tanStackRouterCodeSplitter,\n tanstackRouterAutoImport,\n tanstackRouterGenerator,\n} from '@tanstack/router-plugin/vite'\nimport { routeTreeClientPlugin } from './route-tree-client-plugin'\nimport { virtualRouteTreePlugin } from './virtual-route-tree-plugin'\nimport { routesManifestPlugin } from './generator-plugins/routes-manifest-plugin'\nimport { serverRoutesPlugin } from './generator-plugins/server-routes-plugin'\nimport type { PluginOption } from 'vite'\nimport type { Config } from '@tanstack/router-generator'\n\nexport function tanStackStartRouter(config: Config): Array<PluginOption> {\n return [\n tanstackRouterGenerator({\n ...config,\n plugins: [serverRoutesPlugin(), routesManifestPlugin()],\n }),\n tanStackRouterCodeSplitter(config),\n tanstackRouterAutoImport(config),\n routeTreeClientPlugin(config),\n virtualRouteTreePlugin(config),\n ]\n}\n"],"names":[],"mappings":";;;;;AAuBO,SAAS,oBAAoB,QAAqC;AAChE,SAAA;AAAA,IACL,wBAAwB;AAAA,MACtB,GAAG;AAAA,MACH,SAAS,CAAC,mBAAmB,GAAG,qBAAsB,CAAA;AAAA,IAAA,CACvD;AAAA,IACD,2BAA2B,MAAM;AAAA,IACjC,yBAAyB,MAAM;AAAA,IAC/B,sBAAsB,MAAM;AAAA,IAC5B,uBAAuB,MAAM;AAAA,EAC/B;AACF;"}
@@ -0,0 +1,6 @@
1
+ import { Plugin } from 'vite';
2
+ import { Config } from '@tanstack/router-generator';
3
+ /**
4
+ * This removes the server part from the generated route tree so that it can be used on the client.
5
+ */
6
+ export declare function routeTreeClientPlugin(config: Config): Plugin;
@@ -0,0 +1,55 @@
1
+ import path from "node:path";
2
+ import * as t from "@babel/types";
3
+ import { parseAst, generateFromAst, logDiff } from "@tanstack/router-utils";
4
+ import { normalizePath } from "vite";
5
+ import { deadCodeElimination } from "babel-dead-code-elimination";
6
+ import { debug } from "../debug.js";
7
+ function routeTreeClientPlugin(config) {
8
+ const generatedRouteTreePath = normalizePath(
9
+ path.resolve(config.generatedRouteTree)
10
+ );
11
+ return {
12
+ name: "tanstack-start:route-tree-client-plugin",
13
+ enforce: "pre",
14
+ // only run this plugin in the client environment
15
+ applyToEnvironment: (env) => env.config.consumer === "client",
16
+ transform: {
17
+ filter: { id: generatedRouteTreePath },
18
+ handler(code, id) {
19
+ if (id !== generatedRouteTreePath) {
20
+ return null;
21
+ }
22
+ if (debug) console.info(`Compiling route tree for the client`, id);
23
+ const ast = parseAst({ code, sourceFilename: id });
24
+ const filteredBody = ast.program.body.filter((node) => {
25
+ if (t.isExportNamedDeclaration(node)) {
26
+ if (node.declaration && t.isVariableDeclaration(node.declaration) && node.declaration.declarations.length === 1 && node.declaration.declarations[0] && t.isVariableDeclarator(node.declaration.declarations[0]) && t.isIdentifier(node.declaration.declarations[0].id) && node.declaration.declarations[0].id.name === "routeTree") {
27
+ return true;
28
+ }
29
+ return false;
30
+ }
31
+ if (t.isTSInterfaceDeclaration(node) || t.isTSModuleDeclaration(node)) {
32
+ return false;
33
+ }
34
+ return true;
35
+ });
36
+ ast.program.body = filteredBody;
37
+ deadCodeElimination(ast);
38
+ const compiled = generateFromAst(ast, {
39
+ sourceMaps: true,
40
+ sourceFileName: id,
41
+ filename: id
42
+ });
43
+ if (debug) {
44
+ logDiff(code, compiled.code);
45
+ console.log("Output:\n", compiled.code, "\n\n");
46
+ }
47
+ return compiled;
48
+ }
49
+ }
50
+ };
51
+ }
52
+ export {
53
+ routeTreeClientPlugin
54
+ };
55
+ //# sourceMappingURL=route-tree-client-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-tree-client-plugin.js","sources":["../../../src/start-router-plugin/route-tree-client-plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport * as t from '@babel/types'\nimport { generateFromAst, logDiff, parseAst } from '@tanstack/router-utils'\nimport { normalizePath } from 'vite'\nimport { deadCodeElimination } from 'babel-dead-code-elimination'\nimport { debug } from '../debug'\nimport type { Plugin } from 'vite'\nimport type { Config } from '@tanstack/router-generator'\n\n/**\n * This removes the server part from the generated route tree so that it can be used on the client.\n */\nexport function routeTreeClientPlugin(config: Config): Plugin {\n const generatedRouteTreePath = normalizePath(\n path.resolve(config.generatedRouteTree),\n )\n\n return {\n name: 'tanstack-start:route-tree-client-plugin',\n enforce: 'pre',\n // only run this plugin in the client environment\n applyToEnvironment: (env) => env.config.consumer === 'client',\n transform: {\n filter: { id: generatedRouteTreePath },\n handler(code, id) {\n if (id !== generatedRouteTreePath) {\n return null\n }\n if (debug) console.info(`Compiling route tree for the client`, id)\n const ast = parseAst({ code, sourceFilename: id })\n\n // only keep `export const routeTree = ... `\n const filteredBody = ast.program.body.filter((node) => {\n if (t.isExportNamedDeclaration(node)) {\n if (\n node.declaration &&\n t.isVariableDeclaration(node.declaration) &&\n node.declaration.declarations.length === 1 &&\n node.declaration.declarations[0] &&\n t.isVariableDeclarator(node.declaration.declarations[0]) &&\n t.isIdentifier(node.declaration.declarations[0].id) &&\n node.declaration.declarations[0].id.name === 'routeTree'\n ) {\n return true\n }\n return false\n }\n // strip off the typescript interface & module declarations since they also reference the server routes\n if (\n t.isTSInterfaceDeclaration(node) ||\n t.isTSModuleDeclaration(node)\n ) {\n return false\n }\n return true\n })\n\n ast.program.body = filteredBody\n\n deadCodeElimination(ast)\n\n const compiled = generateFromAst(ast, {\n sourceMaps: true,\n sourceFileName: id,\n filename: id,\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 },\n }\n}\n"],"names":[],"mappings":";;;;;;AAYO,SAAS,sBAAsB,QAAwB;AAC5D,QAAM,yBAAyB;AAAA,IAC7B,KAAK,QAAQ,OAAO,kBAAkB;AAAA,EACxC;AAEO,SAAA;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,IAET,oBAAoB,CAAC,QAAQ,IAAI,OAAO,aAAa;AAAA,IACrD,WAAW;AAAA,MACT,QAAQ,EAAE,IAAI,uBAAuB;AAAA,MACrC,QAAQ,MAAM,IAAI;AAChB,YAAI,OAAO,wBAAwB;AAC1B,iBAAA;AAAA,QAAA;AAET,YAAI,MAAO,SAAQ,KAAK,uCAAuC,EAAE;AACjE,cAAM,MAAM,SAAS,EAAE,MAAM,gBAAgB,IAAI;AAGjD,cAAM,eAAe,IAAI,QAAQ,KAAK,OAAO,CAAC,SAAS;AACjD,cAAA,EAAE,yBAAyB,IAAI,GAAG;AACpC,gBACE,KAAK,eACL,EAAE,sBAAsB,KAAK,WAAW,KACxC,KAAK,YAAY,aAAa,WAAW,KACzC,KAAK,YAAY,aAAa,CAAC,KAC/B,EAAE,qBAAqB,KAAK,YAAY,aAAa,CAAC,CAAC,KACvD,EAAE,aAAa,KAAK,YAAY,aAAa,CAAC,EAAE,EAAE,KAClD,KAAK,YAAY,aAAa,CAAC,EAAE,GAAG,SAAS,aAC7C;AACO,qBAAA;AAAA,YAAA;AAEF,mBAAA;AAAA,UAAA;AAGT,cACE,EAAE,yBAAyB,IAAI,KAC/B,EAAE,sBAAsB,IAAI,GAC5B;AACO,mBAAA;AAAA,UAAA;AAEF,iBAAA;AAAA,QAAA,CACR;AAED,YAAI,QAAQ,OAAO;AAEnB,4BAAoB,GAAG;AAEjB,cAAA,WAAW,gBAAgB,KAAK;AAAA,UACpC,YAAY;AAAA,UACZ,gBAAgB;AAAA,UAChB,UAAU;AAAA,QAAA,CACX;AACD,YAAI,OAAO;AACD,kBAAA,MAAM,SAAS,IAAI;AAC3B,kBAAQ,IAAI,aAAa,SAAS,MAAM,MAAM;AAAA,QAAA;AAGzC,eAAA;AAAA,MAAA;AAAA,IACT;AAAA,EAEJ;AACF;"}
@@ -0,0 +1,4 @@
1
+ import { Config } from '@tanstack/router-generator';
2
+ import { Plugin } from 'vite';
3
+ export declare const moduleId = "tanstack-start-route-tree:v";
4
+ export declare function virtualRouteTreePlugin(config: Config): Plugin;
@@ -0,0 +1,30 @@
1
+ import path from "node:path";
2
+ import { normalizePath } from "vite";
3
+ import { debug } from "../debug.js";
4
+ const moduleId = "tanstack-start-route-tree:v";
5
+ function virtualRouteTreePlugin(config) {
6
+ const generatedRouteTreePath = normalizePath(
7
+ path.resolve(config.generatedRouteTree)
8
+ );
9
+ return {
10
+ name: "tanstack-start:virtual-route-tree",
11
+ enforce: "pre",
12
+ sharedDuringBuild: true,
13
+ resolveId: {
14
+ filter: { id: new RegExp(moduleId) },
15
+ handler(id) {
16
+ let resolvedId = null;
17
+ if (id === moduleId) {
18
+ if (debug) console.info("resolving id", id, generatedRouteTreePath);
19
+ resolvedId = generatedRouteTreePath;
20
+ }
21
+ return resolvedId;
22
+ }
23
+ }
24
+ };
25
+ }
26
+ export {
27
+ moduleId,
28
+ virtualRouteTreePlugin
29
+ };
30
+ //# sourceMappingURL=virtual-route-tree-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtual-route-tree-plugin.js","sources":["../../../src/start-router-plugin/virtual-route-tree-plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { normalizePath } from 'vite'\nimport { debug } from '../debug'\nimport type { Config } from '@tanstack/router-generator'\nimport type { Plugin } from 'vite'\n\nexport const moduleId = 'tanstack-start-route-tree:v'\n\nexport function virtualRouteTreePlugin(config: Config): Plugin {\n const generatedRouteTreePath = normalizePath(\n path.resolve(config.generatedRouteTree),\n )\n\n return {\n name: 'tanstack-start:virtual-route-tree',\n enforce: 'pre',\n sharedDuringBuild: true,\n resolveId: {\n filter: { id: new RegExp(moduleId) },\n handler(id) {\n let resolvedId: string | null = null\n if (id === moduleId) {\n if (debug) console.info('resolving id', id, generatedRouteTreePath)\n resolvedId = generatedRouteTreePath\n }\n return resolvedId\n },\n },\n }\n}\n"],"names":[],"mappings":";;;AAMO,MAAM,WAAW;AAEjB,SAAS,uBAAuB,QAAwB;AAC7D,QAAM,yBAAyB;AAAA,IAC7B,KAAK,QAAQ,OAAO,kBAAkB;AAAA,EACxC;AAEO,SAAA;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,mBAAmB;AAAA,IACnB,WAAW;AAAA,MACT,QAAQ,EAAE,IAAI,IAAI,OAAO,QAAQ,EAAE;AAAA,MACnC,QAAQ,IAAI;AACV,YAAI,aAA4B;AAChC,YAAI,OAAO,UAAU;AACnB,cAAI,MAAO,SAAQ,KAAK,gBAAgB,IAAI,sBAAsB;AACrD,uBAAA;AAAA,QAAA;AAER,eAAA;AAAA,MAAA;AAAA,IACT;AAAA,EAEJ;AACF;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/start-plugin-core",
3
- "version": "1.121.0-alpha.24",
3
+ "version": "1.121.0-alpha.26",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -64,10 +64,11 @@
64
64
  "xmlbuilder2": "^3.1.1",
65
65
  "zod": "^3.24.2",
66
66
  "@tanstack/router-core": "^1.121.0-alpha.22",
67
- "@tanstack/router-generator": "^1.121.0-alpha.22",
68
- "@tanstack/router-plugin": "^1.121.0-alpha.22",
69
- "@tanstack/router-utils": "^1.121.0-alpha.2",
70
- "@tanstack/server-functions-plugin": "^1.121.0-alpha.8"
67
+ "@tanstack/router-utils": "^1.121.0-alpha.26",
68
+ "@tanstack/router-generator": "^1.121.0-alpha.26",
69
+ "@tanstack/server-functions-plugin": "^1.121.0-alpha.26",
70
+ "@tanstack/router-plugin": "^1.121.0-alpha.26",
71
+ "@tanstack/start-server-core": "^1.121.0-alpha.26"
71
72
  },
72
73
  "devDependencies": {
73
74
  "vite": "^6.0.0"
package/src/compilers.ts CHANGED
@@ -25,17 +25,40 @@ export function compileStartOutputFactory(
25
25
  Program: {
26
26
  enter(programPath) {
27
27
  const identifiers: {
28
+ createServerRoute: IdentifierConfig
28
29
  createServerFileRoute: IdentifierConfig
29
30
  createServerFn: IdentifierConfig
30
31
  createMiddleware: IdentifierConfig
31
32
  serverOnly: IdentifierConfig
32
33
  clientOnly: IdentifierConfig
33
34
  createIsomorphicFn: IdentifierConfig
35
+ createServerRootRoute: IdentifierConfig
34
36
  } = {
37
+ createServerRootRoute: {
38
+ name: 'createServerRootRoute',
39
+ handleCallExpression:
40
+ handleCreateServerFileRouteCallExpressionFactory(
41
+ framework,
42
+ 'createServerRootRoute',
43
+ ),
44
+ paths: [],
45
+ },
46
+ createServerRoute: {
47
+ name: 'createServerRoute',
48
+ handleCallExpression:
49
+ handleCreateServerFileRouteCallExpressionFactory(
50
+ framework,
51
+ 'createServerRoute',
52
+ ),
53
+ paths: [],
54
+ },
35
55
  createServerFileRoute: {
36
56
  name: 'createServerFileRoute',
37
57
  handleCallExpression:
38
- handleCreateServerFileRouteCallExpressionFactory(framework),
58
+ handleCreateServerFileRouteCallExpressionFactory(
59
+ framework,
60
+ 'createServerFileRoute',
61
+ ),
39
62
  paths: [],
40
63
  },
41
64
  createServerFn: {
@@ -71,10 +94,7 @@ export function compileStartOutputFactory(
71
94
 
72
95
  programPath.traverse({
73
96
  ImportDeclaration: (path) => {
74
- if (
75
- path.node.source.value !== '@tanstack/react-start' &&
76
- path.node.source.value !== '@tanstack/solid-start'
77
- ) {
97
+ if (path.node.source.value !== `@tanstack/${framework}-start`) {
78
98
  return
79
99
  }
80
100
 
@@ -169,6 +189,10 @@ export function compileStartOutputFactory(
169
189
 
170
190
  function handleCreateServerFileRouteCallExpressionFactory(
171
191
  factory: CompileStartFrameworkOptions,
192
+ method:
193
+ | 'createServerFileRoute'
194
+ | 'createServerRoute'
195
+ | 'createServerRootRoute',
172
196
  ) {
173
197
  return function handleCreateServerFileRouteCallExpression(
174
198
  path: babel.NodePath<t.CallExpression>,
@@ -184,95 +208,6 @@ function handleCreateServerFileRouteCallExpressionFactory(
184
208
 
185
209
  const programPath = highestParent.parentPath as babel.NodePath<t.Program>
186
210
 
187
- // // Find the root call expression and all of the methods that are called on it
188
- // const rootCallExpression = getRootCallExpression(path)
189
-
190
- // const callExpressionPaths = {
191
- // validator: null as babel.NodePath<t.CallExpression> | null,
192
- // middleware: null as babel.NodePath<t.CallExpression> | null,
193
- // methods: null as babel.NodePath<t.CallExpression> | null,
194
- // }
195
-
196
- // const validMethods = Object.keys(callExpressionPaths)
197
-
198
- // rootCallExpression.traverse({
199
- // MemberExpression(memberExpressionPath) {
200
- // if (t.isIdentifier(memberExpressionPath.node.property)) {
201
- // const name = memberExpressionPath.node.property
202
- // .name as keyof typeof callExpressionPaths
203
-
204
- // if (
205
- // validMethods.includes(name) &&
206
- // memberExpressionPath.parentPath.isCallExpression()
207
- // ) {
208
- // callExpressionPaths[name] = memberExpressionPath.parentPath
209
- // }
210
- // }
211
- // },
212
- // })
213
-
214
- // const manifest = { middleware: false, methods: {} as any }
215
-
216
- // Object.entries(callExpressionPaths).forEach(([key, callPath]) => {
217
- // if (callPath && t.isMemberExpression(callPath.node.callee)) {
218
- // if (key === 'middleware') {
219
- // manifest.middleware = true
220
- // } else if (key === 'methods') {
221
- // // Get the methods object from the methods call
222
- // const methodsArg = callPath.node.arguments[0]
223
-
224
- // // Handle the case where methods is a function that returns an object
225
- // if (
226
- // t.isArrowFunctionExpression(methodsArg) &&
227
- // t.isObjectExpression(methodsArg.body)
228
- // ) {
229
- // methodsArg.body.properties.forEach((prop) => {
230
- // if (t.isObjectProperty(prop) && t.isIdentifier(prop.key)) {
231
- // const methodName = prop.key.name
232
- // manifest.methods[methodName] = {
233
- // middleware: false,
234
- // }
235
-
236
- // // Check if this method has a middleware
237
- // if (t.isCallExpression(prop.value)) {
238
- // const method = prop.value
239
- // method.arguments.forEach((arg) => {
240
- // if (t.isObjectExpression(arg)) {
241
- // arg.properties.forEach((methodProp) => {
242
- // if (
243
- // t.isObjectProperty(methodProp) &&
244
- // t.isIdentifier(methodProp.key)
245
- // ) {
246
- // if (methodProp.key.name === 'middleware') {
247
- // manifest.methods[methodName].middleware = true
248
- // }
249
- // }
250
- // })
251
- // }
252
- // })
253
- // }
254
- // }
255
- // })
256
- // }
257
- // // Handle the case where methods is a direct object
258
- // else if (t.isObjectExpression(methodsArg)) {
259
- // methodsArg.properties.forEach((prop) => {
260
- // if (t.isObjectProperty(prop) && t.isIdentifier(prop.key)) {
261
- // const methodName = prop.key.name
262
- // manifest.methods[methodName] = {
263
- // middleware: false,
264
- // }
265
- // }
266
- // })
267
- // }
268
- // }
269
-
270
- // if (opts.env === 'client') {
271
- // callPath.replaceWith(callPath.node.callee.object)
272
- // }
273
- // }
274
- // })
275
-
276
211
  // If we're on the client, remove the entire variable
277
212
  if (opts.env === 'client') {
278
213
  // console.debug('createServerFileRoute -> manifest:\n', manifest)
@@ -280,36 +215,6 @@ function handleCreateServerFileRouteCallExpressionFactory(
280
215
  return
281
216
  }
282
217
 
283
- // path.replaceWith(
284
- // t.callExpression(t.identifier('createServerFileRoute'), [
285
- // t.identifier('undefined'),
286
- // t.callExpression(
287
- // t.memberExpression(t.identifier('Object'), t.identifier('assign')),
288
- // [
289
- // t.objectExpression(
290
- // path.node.arguments
291
- // .map((arg) => {
292
- // if (t.isIdentifier(arg)) {
293
- // return t.objectProperty(t.identifier(arg.name), arg)
294
- // }
295
- // // Handle other cases or return a default value if necessary
296
- // return null // or throw an error, or handle accordingly
297
- // })
298
- // .filter(
299
- // (property): property is t.ObjectProperty => property !== null,
300
- // ),
301
- // ),
302
- // t.objectExpression([
303
- // t.objectProperty(
304
- // t.identifier('manifest'),
305
- // t.valueToNode(manifest),
306
- // ),
307
- // ]),
308
- // ],
309
- // ),
310
- // ]),
311
- // )
312
-
313
218
  let isCreateServerFileRouteImported = false as boolean
314
219
 
315
220
  programPath.traverse({
@@ -321,7 +226,7 @@ function handleCreateServerFileRouteCallExpressionFactory(
321
226
  return (
322
227
  t.isImportSpecifier(specifier) &&
323
228
  t.isIdentifier(specifier.imported) &&
324
- specifier.imported.name === 'createServerFileRoute'
229
+ specifier.imported.name === method
325
230
  )
326
231
  })
327
232
  }
@@ -330,12 +235,7 @@ function handleCreateServerFileRouteCallExpressionFactory(
330
235
 
331
236
  if (!isCreateServerFileRouteImported) {
332
237
  const importDeclaration = t.importDeclaration(
333
- [
334
- t.importSpecifier(
335
- t.identifier('createServerFileRoute'),
336
- t.identifier('createServerFileRoute'),
337
- ),
338
- ],
238
+ [t.importSpecifier(t.identifier(method), t.identifier(method))],
339
239
  t.stringLiteral(PACKAGES.start),
340
240
  )
341
241
  programPath.node.body.unshift(importDeclaration)
package/src/debug.ts ADDED
@@ -0,0 +1,3 @@
1
+ export const debug =
2
+ process.env.TSR_VITE_DEBUG &&
3
+ ['true', 'start-plugin-core'].includes(process.env.TSR_VITE_DEBUG)
@@ -0,0 +1,8 @@
1
+ import type { Manifest } from '@tanstack/router-core'
2
+
3
+ /* eslint-disable no-var */
4
+ declare global {
5
+ var TSS_APP_BASE: string
6
+ var TSS_ROUTES_MANIFEST: Manifest
7
+ }
8
+ export {}
package/src/plugin.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import path from 'node:path'
2
2
  import { createNitro } from 'nitropack'
3
3
  import { trimPathRight } from '@tanstack/router-core'
4
- import { tanstackRouter } from '@tanstack/router-plugin/vite'
4
+ import { VIRTUAL_MODULES } from '@tanstack/start-server-core'
5
5
  import { TanStackServerFnPluginEnv } from '@tanstack/server-functions-plugin'
6
6
  import * as vite from 'vite'
7
7
  import { createTanStackConfig } from './schema'
8
8
  import { nitroPlugin } from './nitro-plugin/plugin'
9
- import { startRoutesManifestPlugin } from './start-routes-manifest-plugin/plugin'
9
+ import { startManifestPlugin } from './start-manifest-plugin/plugin'
10
10
  import { startCompilerPlugin } from './start-compiler-plugin'
11
11
  import {
12
12
  CLIENT_DIST_DIR,
13
13
  SSR_ENTRY_FILE,
14
14
  VITE_ENVIRONMENT_NAMES,
15
15
  } from './constants'
16
- import { TanStackStartServerRoutesVite } from './start-server-routes-plugin/plugin'
16
+ import { tanStackStartRouter } from './start-router-plugin/plugin'
17
17
  import { loadEnvPlugin } from './load-env-plugin/plugin'
18
18
  import { devServerPlugin } from './dev-server-plugin/plugin'
19
19
  import { resolveVirtualEntriesPlugin } from './resolve-virtual-entries-plugin/plugin'
@@ -35,11 +35,6 @@ export type TanStackStartOutputConfig = ReturnType<
35
35
  typeof getTanStackStartOptions
36
36
  >
37
37
 
38
- declare global {
39
- // eslint-disable-next-line no-var
40
- var TSS_APP_BASE: string
41
- }
42
-
43
38
  export interface TanStackStartVitePluginCoreOptions {
44
39
  framework: CompileStartFrameworkOptions
45
40
  getVirtualServerRootHandler: (ctx: {
@@ -57,11 +52,9 @@ export function TanStackStartVitePluginCore(
57
52
  startConfig: TanStackStartOutputConfig,
58
53
  ): Array<PluginOption> {
59
54
  return [
60
- tanstackRouter({
61
- verboseFileRoutes: false,
55
+ tanStackStartRouter({
62
56
  ...startConfig.tsr,
63
57
  target: opts.framework,
64
- enableRouteGeneration: true,
65
58
  autoCodeSplitting: true,
66
59
  }),
67
60
  resolveVirtualEntriesPlugin(opts, startConfig),
@@ -162,18 +155,13 @@ export function TanStackStartVitePluginCore(
162
155
  '@tanstack/start-router-manifest',
163
156
  '@tanstack/start-config',
164
157
  '@tanstack/server-functions-plugin',
165
- 'tanstack-start-router-manifest:v',
166
- 'tanstack-start-server-fn-manifest:v',
167
158
  'nitropack',
168
159
  '@tanstack/**start**',
160
+ ...Object.values(VIRTUAL_MODULES),
169
161
  ],
170
162
  },
171
163
  optimizeDeps: {
172
- exclude: [
173
- 'tanstack-start-server-fn-manifest:v',
174
- 'tanstack-start-router-manifest:v',
175
- 'tanstack-start-server-routes-manifest:v',
176
- ],
164
+ exclude: [...Object.values(VIRTUAL_MODULES)],
177
165
  },
178
166
  /* prettier-ignore */
179
167
  define: {
@@ -197,7 +185,7 @@ export function TanStackStartVitePluginCore(
197
185
  TanStackServerFnPluginEnv({
198
186
  // This is the ID that will be available to look up and import
199
187
  // our server function manifest and resolve its module
200
- manifestVirtualImportId: 'tanstack-start-server-fn-manifest:v',
188
+ manifestVirtualImportId: VIRTUAL_MODULES.serverFnManifest,
201
189
  manifestOutputFilename:
202
190
  '.tanstack-start/build/server/server-functions-manifest.json',
203
191
  client: {
@@ -225,13 +213,9 @@ export function TanStackStartVitePluginCore(
225
213
  },
226
214
  }),
227
215
  loadEnvPlugin(startConfig),
228
- startRoutesManifestPlugin(startConfig),
216
+ startManifestPlugin(startConfig),
229
217
  devServerPlugin(),
230
218
  nitroPlugin(startConfig, () => ssrBundle),
231
- TanStackStartServerRoutesVite({
232
- ...startConfig.tsr,
233
- target: opts.framework,
234
- }),
235
219
  ]
236
220
  }
237
221