@tanstack/start-plugin-core 1.121.20 → 1.121.22

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/compilers.cjs +416 -0
  2. package/dist/cjs/compilers.cjs.map +1 -0
  3. package/dist/cjs/compilers.d.cts +21 -0
  4. package/dist/cjs/constants.cjs +20 -0
  5. package/dist/cjs/constants.cjs.map +1 -0
  6. package/dist/cjs/constants.d.cts +6 -0
  7. package/dist/cjs/debug.cjs +5 -0
  8. package/dist/cjs/debug.cjs.map +1 -0
  9. package/dist/cjs/debug.d.cts +1 -0
  10. package/dist/cjs/dev-server-plugin/extract-html-scripts.cjs +35 -0
  11. package/dist/cjs/dev-server-plugin/extract-html-scripts.cjs.map +1 -0
  12. package/dist/cjs/dev-server-plugin/extract-html-scripts.d.cts +4 -0
  13. package/dist/cjs/dev-server-plugin/plugin.cjs +136 -0
  14. package/dist/cjs/dev-server-plugin/plugin.cjs.map +1 -0
  15. package/dist/cjs/dev-server-plugin/plugin.d.cts +5 -0
  16. package/dist/cjs/index.cjs +11 -0
  17. package/dist/cjs/index.cjs.map +1 -0
  18. package/dist/cjs/index.d.cts +3 -0
  19. package/dist/cjs/load-env-plugin/plugin.cjs +34 -0
  20. package/dist/cjs/load-env-plugin/plugin.cjs.map +1 -0
  21. package/dist/cjs/load-env-plugin/plugin.d.cts +3 -0
  22. package/dist/cjs/nitro-plugin/build-sitemap.cjs +138 -0
  23. package/dist/cjs/nitro-plugin/build-sitemap.cjs.map +1 -0
  24. package/dist/cjs/nitro-plugin/build-sitemap.d.cts +31 -0
  25. package/dist/cjs/nitro-plugin/plugin.cjs +181 -0
  26. package/dist/cjs/nitro-plugin/plugin.cjs.map +1 -0
  27. package/dist/cjs/nitro-plugin/plugin.d.cts +3 -0
  28. package/dist/cjs/nitro-plugin/prerender.cjs +174 -0
  29. package/dist/cjs/nitro-plugin/prerender.cjs.map +1 -0
  30. package/dist/cjs/nitro-plugin/prerender.d.cts +8 -0
  31. package/dist/cjs/nitro-plugin/queue.cjs +131 -0
  32. package/dist/cjs/nitro-plugin/queue.cjs.map +1 -0
  33. package/dist/cjs/nitro-plugin/queue.d.cts +32 -0
  34. package/dist/cjs/plugin.cjs +207 -0
  35. package/dist/cjs/plugin.cjs.map +1 -0
  36. package/dist/cjs/plugin.d.cts +291 -0
  37. package/dist/cjs/resolve-virtual-entries-plugin/plugin.cjs +66 -0
  38. package/dist/cjs/resolve-virtual-entries-plugin/plugin.cjs.map +1 -0
  39. package/dist/cjs/resolve-virtual-entries-plugin/plugin.d.cts +3 -0
  40. package/dist/cjs/schema.cjs +157 -0
  41. package/dist/cjs/schema.cjs.map +1 -0
  42. package/dist/cjs/schema.d.cts +8779 -0
  43. package/dist/cjs/start-compiler-plugin.cjs +74 -0
  44. package/dist/cjs/start-compiler-plugin.cjs.map +1 -0
  45. package/dist/cjs/start-compiler-plugin.d.cts +13 -0
  46. package/dist/cjs/start-manifest-plugin/plugin.cjs +187 -0
  47. package/dist/cjs/start-manifest-plugin/plugin.cjs.map +1 -0
  48. package/dist/cjs/start-manifest-plugin/plugin.d.cts +5 -0
  49. package/dist/cjs/start-router-plugin/generator-plugins/routes-manifest-plugin.cjs +39 -0
  50. package/dist/cjs/start-router-plugin/generator-plugins/routes-manifest-plugin.cjs.map +1 -0
  51. package/dist/cjs/start-router-plugin/generator-plugins/routes-manifest-plugin.d.cts +6 -0
  52. package/dist/cjs/start-router-plugin/generator-plugins/server-routes-plugin.cjs +121 -0
  53. package/dist/cjs/start-router-plugin/generator-plugins/server-routes-plugin.cjs.map +1 -0
  54. package/dist/cjs/start-router-plugin/generator-plugins/server-routes-plugin.d.cts +2 -0
  55. package/dist/cjs/start-router-plugin/plugin.cjs +21 -0
  56. package/dist/cjs/start-router-plugin/plugin.cjs.map +1 -0
  57. package/dist/cjs/start-router-plugin/plugin.d.cts +3 -0
  58. package/dist/cjs/start-router-plugin/route-tree-client-plugin.cjs +72 -0
  59. package/dist/cjs/start-router-plugin/route-tree-client-plugin.cjs.map +1 -0
  60. package/dist/cjs/start-router-plugin/route-tree-client-plugin.d.cts +6 -0
  61. package/dist/cjs/start-router-plugin/virtual-route-tree-plugin.cjs +30 -0
  62. package/dist/cjs/start-router-plugin/virtual-route-tree-plugin.cjs.map +1 -0
  63. package/dist/cjs/start-router-plugin/virtual-route-tree-plugin.d.cts +4 -0
  64. package/dist/cjs/utils.cjs +18 -0
  65. package/dist/cjs/utils.cjs.map +1 -0
  66. package/dist/cjs/utils.d.cts +8 -0
  67. package/dist/esm/compilers.d.ts +21 -0
  68. package/dist/esm/compilers.js +398 -0
  69. package/dist/esm/compilers.js.map +1 -0
  70. package/dist/esm/constants.d.ts +6 -0
  71. package/dist/esm/constants.js +20 -0
  72. package/dist/esm/constants.js.map +1 -0
  73. package/dist/esm/debug.d.ts +1 -0
  74. package/dist/esm/debug.js +5 -0
  75. package/dist/esm/debug.js.map +1 -0
  76. package/dist/esm/dev-server-plugin/extract-html-scripts.d.ts +4 -0
  77. package/dist/esm/dev-server-plugin/extract-html-scripts.js +18 -0
  78. package/dist/esm/dev-server-plugin/extract-html-scripts.js.map +1 -0
  79. package/dist/esm/dev-server-plugin/plugin.d.ts +5 -0
  80. package/dist/esm/dev-server-plugin/plugin.js +136 -0
  81. package/dist/esm/dev-server-plugin/plugin.js.map +1 -0
  82. package/dist/esm/index.d.ts +3 -0
  83. package/dist/esm/index.js +11 -0
  84. package/dist/esm/index.js.map +1 -0
  85. package/dist/esm/load-env-plugin/plugin.d.ts +3 -0
  86. package/dist/esm/load-env-plugin/plugin.js +17 -0
  87. package/dist/esm/load-env-plugin/plugin.js.map +1 -0
  88. package/dist/esm/nitro-plugin/build-sitemap.d.ts +31 -0
  89. package/dist/esm/nitro-plugin/build-sitemap.js +138 -0
  90. package/dist/esm/nitro-plugin/build-sitemap.js.map +1 -0
  91. package/dist/esm/nitro-plugin/plugin.d.ts +3 -0
  92. package/dist/esm/nitro-plugin/plugin.js +181 -0
  93. package/dist/esm/nitro-plugin/plugin.js.map +1 -0
  94. package/dist/esm/nitro-plugin/prerender.d.ts +8 -0
  95. package/dist/esm/nitro-plugin/prerender.js +174 -0
  96. package/dist/esm/nitro-plugin/prerender.js.map +1 -0
  97. package/dist/esm/nitro-plugin/queue.d.ts +32 -0
  98. package/dist/esm/nitro-plugin/queue.js +131 -0
  99. package/dist/esm/nitro-plugin/queue.js.map +1 -0
  100. package/dist/esm/plugin.d.ts +291 -0
  101. package/dist/esm/plugin.js +190 -0
  102. package/dist/esm/plugin.js.map +1 -0
  103. package/dist/esm/resolve-virtual-entries-plugin/plugin.d.ts +3 -0
  104. package/dist/esm/resolve-virtual-entries-plugin/plugin.js +49 -0
  105. package/dist/esm/resolve-virtual-entries-plugin/plugin.js.map +1 -0
  106. package/dist/esm/schema.d.ts +8779 -0
  107. package/dist/esm/schema.js +157 -0
  108. package/dist/esm/schema.js.map +1 -0
  109. package/dist/esm/start-compiler-plugin.d.ts +13 -0
  110. package/dist/esm/start-compiler-plugin.js +74 -0
  111. package/dist/esm/start-compiler-plugin.js.map +1 -0
  112. package/dist/esm/start-manifest-plugin/plugin.d.ts +5 -0
  113. package/dist/esm/start-manifest-plugin/plugin.js +187 -0
  114. package/dist/esm/start-manifest-plugin/plugin.js.map +1 -0
  115. package/dist/esm/start-router-plugin/generator-plugins/routes-manifest-plugin.d.ts +6 -0
  116. package/dist/esm/start-router-plugin/generator-plugins/routes-manifest-plugin.js +39 -0
  117. package/dist/esm/start-router-plugin/generator-plugins/routes-manifest-plugin.js.map +1 -0
  118. package/dist/esm/start-router-plugin/generator-plugins/server-routes-plugin.d.ts +2 -0
  119. package/dist/esm/start-router-plugin/generator-plugins/server-routes-plugin.js +121 -0
  120. package/dist/esm/start-router-plugin/generator-plugins/server-routes-plugin.js.map +1 -0
  121. package/dist/esm/start-router-plugin/plugin.d.ts +3 -0
  122. package/dist/esm/start-router-plugin/plugin.js +21 -0
  123. package/dist/esm/start-router-plugin/plugin.js.map +1 -0
  124. package/dist/esm/start-router-plugin/route-tree-client-plugin.d.ts +6 -0
  125. package/dist/esm/start-router-plugin/route-tree-client-plugin.js +55 -0
  126. package/dist/esm/start-router-plugin/route-tree-client-plugin.js.map +1 -0
  127. package/dist/esm/start-router-plugin/virtual-route-tree-plugin.d.ts +4 -0
  128. package/dist/esm/start-router-plugin/virtual-route-tree-plugin.js +30 -0
  129. package/dist/esm/start-router-plugin/virtual-route-tree-plugin.js.map +1 -0
  130. package/dist/esm/utils.d.ts +8 -0
  131. package/dist/esm/utils.js +18 -0
  132. package/dist/esm/utils.js.map +1 -0
  133. package/package.json +7 -7
  134. package/src/global.d.ts +2 -0
  135. package/src/plugin.ts +10 -0
  136. package/src/start-manifest-plugin/plugin.ts +93 -99
  137. package/src/start-router-plugin/generator-plugins/routes-manifest-plugin.ts +2 -2
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const node_url = require("node:url");
4
+ const routerUtils = require("@tanstack/router-utils");
5
+ const compilers = require("./compilers.cjs");
6
+ const debug = process.env.TSR_VITE_DEBUG && ["true", "start-plugin"].includes(process.env.TSR_VITE_DEBUG);
7
+ const transformFuncs = [
8
+ "createServerFn",
9
+ "createMiddleware",
10
+ "serverOnly",
11
+ "clientOnly",
12
+ "createIsomorphicFn",
13
+ "createServerFileRoute",
14
+ "createServerRootRoute"
15
+ ];
16
+ const tokenRegex = new RegExp(transformFuncs.join("|"));
17
+ function startCompilerPlugin(framework, inputOpts) {
18
+ const opts = {
19
+ client: {
20
+ envName: "client",
21
+ ...inputOpts == null ? void 0 : inputOpts.client
22
+ },
23
+ server: {
24
+ envName: "server",
25
+ ...inputOpts == null ? void 0 : inputOpts.server
26
+ }
27
+ };
28
+ return {
29
+ name: "vite-plugin-tanstack-start-create-server-fn",
30
+ enforce: "pre",
31
+ applyToEnvironment(env) {
32
+ return [opts.client.envName, opts.server.envName].includes(env.name);
33
+ },
34
+ transform: {
35
+ filter: {
36
+ code: tokenRegex
37
+ },
38
+ handler(code, id) {
39
+ const env = this.environment.name === opts.client.envName ? "client" : this.environment.name === opts.server.envName ? "server" : (() => {
40
+ throw new Error(
41
+ `Environment ${this.environment.name} not configured`
42
+ );
43
+ })();
44
+ return transformCode({
45
+ code,
46
+ id,
47
+ env,
48
+ framework
49
+ });
50
+ }
51
+ }
52
+ };
53
+ }
54
+ function transformCode(opts) {
55
+ const { code, env, framework } = opts;
56
+ let { id } = opts;
57
+ const url = node_url.pathToFileURL(id);
58
+ url.searchParams.delete("v");
59
+ id = node_url.fileURLToPath(url).replace(/\\/g, "/");
60
+ if (debug) console.info(`${env} Compiling Start: `, id);
61
+ const compileStartOutput = compilers.compileStartOutputFactory(framework);
62
+ const compiled = compileStartOutput({
63
+ code,
64
+ filename: id,
65
+ env
66
+ });
67
+ if (debug) {
68
+ routerUtils.logDiff(code, compiled.code);
69
+ console.log("Output:\n", compiled.code + "\n\n");
70
+ }
71
+ return compiled;
72
+ }
73
+ exports.startCompilerPlugin = startCompilerPlugin;
74
+ //# sourceMappingURL=start-compiler-plugin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-compiler-plugin.cjs","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 'createServerRootRoute',\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: {\n filter: {\n code: tokenRegex,\n },\n handler(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}\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 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":["pathToFileURL","fileURLToPath","compileStartOutputFactory","logDiff"],"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;AAAA,EACA;AACF;AAEA,MAAM,aAAa,IAAI,OAAO,eAAe,KAAK,GAAG,CAAC;AAEtC,SAAA,oBACd,WACA,WAQQ;AACR,QAAM,OAAO;AAAA,IACX,QAAQ;AAAA,MACN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Plugin } from 'vite';
2
+ import { CompileStartFrameworkOptions } from './compilers.cjs';
3
+ export type TanStackStartViteOptions = {
4
+ globalMiddlewareEntry: string;
5
+ };
6
+ export declare function startCompilerPlugin(framework: CompileStartFrameworkOptions, inputOpts?: {
7
+ client?: {
8
+ envName?: string;
9
+ };
10
+ server?: {
11
+ envName?: string;
12
+ };
13
+ }): Plugin;
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const path = require("node:path");
4
+ const ufo = require("ufo");
5
+ const routerCore = require("@tanstack/router-core");
6
+ const startServerCore = require("@tanstack/start-server-core");
7
+ const routerPlugin = require("@tanstack/router-plugin");
8
+ const utils = require("../utils.cjs");
9
+ const getCSSRecursively = (chunk, chunksByFileName, basePath) => {
10
+ var _a;
11
+ const result = [];
12
+ for (const cssFile of ((_a = chunk.viteMetadata) == null ? void 0 : _a.importedCss) ?? []) {
13
+ result.push({
14
+ tag: "link",
15
+ attrs: {
16
+ rel: "stylesheet",
17
+ href: ufo.joinURL(basePath, cssFile),
18
+ type: "text/css"
19
+ }
20
+ });
21
+ }
22
+ for (const importedFileName of chunk.imports) {
23
+ const importedChunk = chunksByFileName.get(importedFileName);
24
+ if (importedChunk) {
25
+ result.push(
26
+ ...getCSSRecursively(importedChunk, chunksByFileName, basePath)
27
+ );
28
+ }
29
+ }
30
+ return result;
31
+ };
32
+ const resolvedModuleId = utils.resolveViteId(startServerCore.VIRTUAL_MODULES.startManifest);
33
+ function startManifestPlugin(opts) {
34
+ let config;
35
+ return {
36
+ name: "tanstack-start:start-manifest-plugin",
37
+ enforce: "pre",
38
+ configResolved(resolvedConfig) {
39
+ config = resolvedConfig;
40
+ },
41
+ resolveId: {
42
+ filter: { id: new RegExp(startServerCore.VIRTUAL_MODULES.startManifest) },
43
+ handler(id) {
44
+ if (id === startServerCore.VIRTUAL_MODULES.startManifest) {
45
+ return resolvedModuleId;
46
+ }
47
+ return void 0;
48
+ }
49
+ },
50
+ load: {
51
+ filter: {
52
+ id: new RegExp(resolvedModuleId)
53
+ },
54
+ handler(id) {
55
+ if (id === resolvedModuleId) {
56
+ if (this.environment.config.consumer !== "server") {
57
+ return `export default {}`;
58
+ }
59
+ if (config.command === "serve") {
60
+ return `export const tsrStartManifest = () => ({
61
+ routes: {}
62
+ })`;
63
+ }
64
+ const APP_BASE = globalThis.TSS_APP_BASE;
65
+ const routeTreeRoutes = globalThis.TSS_ROUTES_MANIFEST.routes;
66
+ let entryFile;
67
+ const clientBundle = globalThis.TSS_CLIENT_BUNDLE;
68
+ const chunksByFileName = /* @__PURE__ */ new Map();
69
+ const routeChunks = {};
70
+ for (const bundleEntry of Object.values(clientBundle)) {
71
+ if (bundleEntry.type === "chunk") {
72
+ chunksByFileName.set(bundleEntry.fileName, bundleEntry);
73
+ if (bundleEntry.isEntry) {
74
+ if (entryFile) {
75
+ throw new Error(
76
+ `multiple entries detected: ${entryFile.fileName} ${bundleEntry.fileName}`
77
+ );
78
+ }
79
+ entryFile = bundleEntry;
80
+ }
81
+ const routePieces = bundleEntry.moduleIds.flatMap((m) => {
82
+ const [id2, query] = m.split("?");
83
+ if (id2 === void 0) {
84
+ throw new Error("expected id to be defined");
85
+ }
86
+ if (query === void 0) {
87
+ return [];
88
+ }
89
+ const searchParams = new URLSearchParams(query);
90
+ const split = searchParams.get(routerPlugin.tsrSplit);
91
+ if (split !== null) {
92
+ return {
93
+ id: id2,
94
+ split
95
+ };
96
+ }
97
+ return [];
98
+ });
99
+ if (routePieces.length > 0) {
100
+ routePieces.forEach((r) => {
101
+ let array = routeChunks[r.id];
102
+ if (array === void 0) {
103
+ array = [];
104
+ routeChunks[r.id] = array;
105
+ }
106
+ array.push(bundleEntry);
107
+ });
108
+ }
109
+ }
110
+ }
111
+ Object.entries(routeTreeRoutes).forEach(([routeId, v]) => {
112
+ if (!v.filePath) {
113
+ throw new Error(`expected filePath to be set for ${routeId}`);
114
+ }
115
+ const chunks = routeChunks[v.filePath];
116
+ if (chunks) {
117
+ chunks.forEach((chunk) => {
118
+ const preloads = chunk.imports.map((d) => {
119
+ const assetPath = ufo.joinURL(APP_BASE, d);
120
+ return assetPath;
121
+ });
122
+ preloads.unshift(path.join(APP_BASE, chunk.fileName));
123
+ const cssAssetsList = getCSSRecursively(
124
+ chunk,
125
+ chunksByFileName,
126
+ APP_BASE
127
+ );
128
+ routeTreeRoutes[routeId] = {
129
+ ...v,
130
+ assets: [...v.assets || [], ...cssAssetsList],
131
+ preloads: [...v.preloads || [], ...preloads]
132
+ };
133
+ });
134
+ }
135
+ });
136
+ if (entryFile) {
137
+ routeTreeRoutes[routerCore.rootRouteId].preloads = [
138
+ ufo.joinURL(APP_BASE, entryFile.fileName),
139
+ ...entryFile.imports.map((d) => ufo.joinURL(APP_BASE, d))
140
+ ];
141
+ const entryCssAssetsList = getCSSRecursively(
142
+ entryFile,
143
+ chunksByFileName,
144
+ APP_BASE
145
+ );
146
+ routeTreeRoutes[routerCore.rootRouteId].assets = [
147
+ ...routeTreeRoutes[routerCore.rootRouteId].assets || [],
148
+ ...entryCssAssetsList,
149
+ {
150
+ tag: "script",
151
+ attrs: {
152
+ src: ufo.joinURL(APP_BASE, entryFile.fileName),
153
+ type: "module"
154
+ }
155
+ }
156
+ ];
157
+ }
158
+ const recurseRoute = (route, seenPreloads = {}) => {
159
+ var _a;
160
+ route.preloads = (_a = route.preloads) == null ? void 0 : _a.filter((preload) => {
161
+ if (seenPreloads[preload]) {
162
+ return false;
163
+ }
164
+ seenPreloads[preload] = true;
165
+ return true;
166
+ });
167
+ if (route.children) {
168
+ route.children.forEach((child) => {
169
+ const childRoute = routeTreeRoutes[child];
170
+ recurseRoute(childRoute, { ...seenPreloads });
171
+ });
172
+ }
173
+ };
174
+ recurseRoute(routeTreeRoutes[routerCore.rootRouteId]);
175
+ const routesManifest = {
176
+ routes: routeTreeRoutes
177
+ };
178
+ return `export const tsrStartManifest = () => (${JSON.stringify(routesManifest)})`;
179
+ }
180
+ return void 0;
181
+ }
182
+ }
183
+ };
184
+ }
185
+ exports.getCSSRecursively = getCSSRecursively;
186
+ exports.startManifestPlugin = startManifestPlugin;
187
+ //# sourceMappingURL=plugin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs","sources":["../../../src/start-manifest-plugin/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { joinURL } from 'ufo'\nimport { rootRouteId } from '@tanstack/router-core'\nimport { VIRTUAL_MODULES } from '@tanstack/start-server-core'\nimport { tsrSplit } from '@tanstack/router-plugin'\nimport { resolveViteId } from '../utils'\nimport type { PluginOption, ResolvedConfig, Rollup } from 'vite'\nimport type { RouterManagedTag } from '@tanstack/router-core'\nimport type { TanStackStartOutputConfig } from '../plugin'\n\nexport const getCSSRecursively = (\n chunk: Rollup.OutputChunk,\n chunksByFileName: Map<string, Rollup.OutputChunk>,\n basePath: string,\n) => {\n const result: Array<RouterManagedTag> = []\n\n // Get all css imports from the file\n for (const cssFile of chunk.viteMetadata?.importedCss ?? []) {\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 importedFileName of chunk.imports) {\n const importedChunk = chunksByFileName.get(importedFileName)\n if (importedChunk) {\n result.push(\n ...getCSSRecursively(importedChunk, chunksByFileName, basePath),\n )\n }\n }\n\n return result\n}\n\nconst resolvedModuleId = resolveViteId(VIRTUAL_MODULES.startManifest)\nexport function startManifestPlugin(\n opts: TanStackStartOutputConfig,\n): PluginOption {\n let config: ResolvedConfig\n\n return {\n name: 'tanstack-start:start-manifest-plugin',\n enforce: 'pre',\n\n configResolved(resolvedConfig) {\n config = resolvedConfig\n },\n resolveId: {\n filter: { id: new RegExp(VIRTUAL_MODULES.startManifest) },\n handler(id) {\n if (id === VIRTUAL_MODULES.startManifest) {\n return resolvedModuleId\n }\n return undefined\n },\n },\n load: {\n filter: {\n id: new RegExp(resolvedModuleId),\n },\n handler(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 // This the manifest pulled from the generated route tree and later used by the Router.\n // i.e what's located in `src/routeTree.gen.ts`\n const routeTreeRoutes = globalThis.TSS_ROUTES_MANIFEST.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: Rollup.OutputChunk | undefined\n\n const clientBundle = globalThis.TSS_CLIENT_BUNDLE\n const chunksByFileName = new Map<string, Rollup.OutputChunk>()\n\n const routeChunks: Record<\n string /** fullPath of route file **/,\n Array<Rollup.OutputChunk>\n > = {}\n for (const bundleEntry of Object.values(clientBundle)) {\n if (bundleEntry.type === 'chunk') {\n chunksByFileName.set(bundleEntry.fileName, bundleEntry)\n if (bundleEntry.isEntry) {\n if (entryFile) {\n throw new Error(\n `multiple entries detected: ${entryFile.fileName} ${bundleEntry.fileName}`,\n )\n }\n entryFile = bundleEntry\n }\n const routePieces = bundleEntry.moduleIds.flatMap((m) => {\n const [id, query] = m.split('?')\n if (id === undefined) {\n throw new Error('expected id to be defined')\n }\n if (query === undefined) {\n return []\n }\n const searchParams = new URLSearchParams(query)\n const split = searchParams.get(tsrSplit)\n\n if (split !== null) {\n return {\n id,\n split,\n }\n }\n return []\n })\n if (routePieces.length > 0) {\n routePieces.forEach((r) => {\n let array = routeChunks[r.id]\n if (array === undefined) {\n array = []\n routeChunks[r.id] = array\n }\n array.push(bundleEntry)\n })\n }\n }\n }\n\n // Add preloads to the routes from the vite manifest\n Object.entries(routeTreeRoutes).forEach(([routeId, v]) => {\n if (!v.filePath) {\n throw new Error(`expected filePath to be set for ${routeId}`)\n }\n const chunks = routeChunks[v.filePath]\n if (chunks) {\n chunks.forEach((chunk) => {\n // Map the relevant imports to their route paths,\n // so that it can be imported in the browser.\n const preloads = chunk.imports.map((d) => {\n const assetPath = joinURL(APP_BASE, d)\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 preloads.unshift(path.join(APP_BASE, chunk.fileName))\n\n const cssAssetsList = getCSSRecursively(\n chunk,\n chunksByFileName,\n APP_BASE,\n )\n\n routeTreeRoutes[routeId] = {\n ...v,\n assets: [...(v.assets || []), ...cssAssetsList],\n preloads: [...(v.preloads || []), ...preloads],\n }\n })\n }\n })\n\n if (entryFile) {\n routeTreeRoutes[rootRouteId]!.preloads = [\n joinURL(APP_BASE, entryFile.fileName),\n ...entryFile.imports.map((d) => joinURL(APP_BASE, d)),\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 chunksByFileName,\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.fileName),\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 recurseRoute(routeTreeRoutes[rootRouteId]!)\n\n const routesManifest = {\n routes: routeTreeRoutes,\n }\n\n return `export const tsrStartManifest = () => (${JSON.stringify(routesManifest)})`\n }\n\n return undefined\n },\n },\n }\n}\n"],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GF,gBAAM,eAAe,CACnB,OAIA,eAAe,CAAA,MACZ;;AACH,kBAAM,YAAW,WAAM,aAAN,mBAAgB,OAAO,CAAC,YAAY;AAC/C,kBAAA,aAAa,OAAO,GAAG;AAClB,uBAAA;AAAA,cAAA;AAET,2BAAa,OAAO,IAAI;AACjB,qBAAA;AAAA,YAAA;AAGT,gBAAI,MAAM,UAAU;AACZ,oBAAA,SAAS,QAAQ,CAAC,UAAU;AAC1B,sBAAA,aAAa,gBAAgB,KAAK;AACxC,6BAAa,YAAY,EAAE,GAAG,cAAc;AAAA,cAAA,CAC7C;AAAA,YAAA;AAAA,UAEL;AAEa,uBAAA,gBAAgBK,WAAAA,WAAW,CAAE;AAE1C,gBAAM,iBAAiB;AAAA,YACrB,QAAQ;AAAA,UACV;AAEA,iBAAO,0CAA0C,KAAK,UAAU,cAAc,CAAC;AAAA,QAAA;AAG1E,eAAA;AAAA,MAAA;AAAA,IACT;AAAA,EAEJ;AACF;;;"}
@@ -0,0 +1,5 @@
1
+ import { PluginOption, Rollup } from 'vite';
2
+ import { RouterManagedTag } from '@tanstack/router-core';
3
+ import { TanStackStartOutputConfig } from '../plugin.cjs';
4
+ export declare const getCSSRecursively: (chunk: Rollup.OutputChunk, chunksByFileName: Map<string, Rollup.OutputChunk>, basePath: string) => RouterManagedTag[];
5
+ export declare function startManifestPlugin(opts: TanStackStartOutputConfig): PluginOption;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const routerCore = require("@tanstack/router-core");
4
+ function routesManifestPlugin() {
5
+ return {
6
+ name: "routes-manifest-plugin",
7
+ onRouteTreesChanged: ({ routeTrees, rootRouteNode }) => {
8
+ const routeTree = routeTrees.find((tree) => tree.exportName === "Route");
9
+ if (!routeTree) {
10
+ throw new Error(
11
+ 'No route tree found with export name "Route". Please ensure your routes are correctly defined.'
12
+ );
13
+ }
14
+ const routesManifest = {
15
+ [routerCore.rootRouteId]: {
16
+ filePath: rootRouteNode.fullPath,
17
+ children: routeTree.acc.routeTree.map((d) => d.routePath)
18
+ },
19
+ ...Object.fromEntries(
20
+ routeTree.acc.routeNodes.map((d) => {
21
+ var _a, _b;
22
+ const filePathId = d.routePath;
23
+ return [
24
+ filePathId,
25
+ {
26
+ filePath: d.fullPath,
27
+ parent: ((_a = d.parent) == null ? void 0 : _a.routePath) ? d.parent.routePath : void 0,
28
+ children: (_b = d.children) == null ? void 0 : _b.map((childRoute) => childRoute.routePath)
29
+ }
30
+ ];
31
+ })
32
+ )
33
+ };
34
+ globalThis.TSS_ROUTES_MANIFEST = { routes: routesManifest };
35
+ }
36
+ };
37
+ }
38
+ exports.routesManifestPlugin = routesManifestPlugin;
39
+ //# sourceMappingURL=routes-manifest-plugin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes-manifest-plugin.cjs","sources":["../../../../src/start-router-plugin/generator-plugins/routes-manifest-plugin.ts"],"sourcesContent":["import { rootRouteId } from '@tanstack/router-core'\n\nimport type { GeneratorPlugin } from '@tanstack/router-generator'\n\n/**\n * this plugin builds the routes manifest and stores it on globalThis\n * so that it can be accessed later (e.g. from a vite plugin)\n */\nexport function routesManifestPlugin(): GeneratorPlugin {\n return {\n name: 'routes-manifest-plugin',\n onRouteTreesChanged: ({ routeTrees, rootRouteNode }) => {\n const routeTree = routeTrees.find((tree) => tree.exportName === 'Route')\n if (!routeTree) {\n throw new Error(\n 'No route tree found with export name \"Route\". Please ensure your routes are correctly defined.',\n )\n }\n const routesManifest = {\n [rootRouteId]: {\n filePath: rootRouteNode.fullPath,\n children: routeTree.acc.routeTree.map((d) => d.routePath),\n },\n ...Object.fromEntries(\n routeTree.acc.routeNodes.map((d) => {\n const filePathId = d.routePath\n\n return [\n filePathId,\n {\n filePath: d.fullPath,\n parent: d.parent?.routePath ? d.parent.routePath : undefined,\n children: d.children?.map((childRoute) => childRoute.routePath),\n },\n ]\n }),\n ),\n }\n\n globalThis.TSS_ROUTES_MANIFEST = { routes: routesManifest }\n },\n }\n}\n"],"names":["rootRouteId"],"mappings":";;;AAQO,SAAS,uBAAwC;AAC/C,SAAA;AAAA,IACL,MAAM;AAAA,IACN,qBAAqB,CAAC,EAAE,YAAY,oBAAoB;AACtD,YAAM,YAAY,WAAW,KAAK,CAAC,SAAS,KAAK,eAAe,OAAO;AACvE,UAAI,CAAC,WAAW;AACd,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAAA,MAAA;AAEF,YAAM,iBAAiB;AAAA,QACrB,CAACA,sBAAW,GAAG;AAAA,UACb,UAAU,cAAc;AAAA,UACxB,UAAU,UAAU,IAAI,UAAU,IAAI,CAAC,MAAM,EAAE,SAAS;AAAA,QAC1D;AAAA,QACA,GAAG,OAAO;AAAA,UACR,UAAU,IAAI,WAAW,IAAI,CAAC,MAAM;;AAClC,kBAAM,aAAa,EAAE;AAEd,mBAAA;AAAA,cACL;AAAA,cACA;AAAA,gBACE,UAAU,EAAE;AAAA,gBACZ,UAAQ,OAAE,WAAF,mBAAU,aAAY,EAAE,OAAO,YAAY;AAAA,gBACnD,WAAU,OAAE,aAAF,mBAAY,IAAI,CAAC,eAAe,WAAW;AAAA,cAAS;AAAA,YAElE;AAAA,UACD,CAAA;AAAA,QAAA;AAAA,MAEL;AAEW,iBAAA,sBAAsB,EAAE,QAAQ,eAAe;AAAA,IAAA;AAAA,EAE9D;AACF;;"}
@@ -0,0 +1,6 @@
1
+ import { GeneratorPlugin } from '@tanstack/router-generator';
2
+ /**
3
+ * this plugin builds the routes manifest and stores it on globalThis
4
+ * so that it can be accessed later (e.g. from a vite plugin)
5
+ */
6
+ export declare function routesManifestPlugin(): GeneratorPlugin;
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const routerGenerator = require("@tanstack/router-generator");
4
+ const EXPORT_NAME = "ServerRoute";
5
+ function serverRoutesPlugin() {
6
+ return {
7
+ name: "server-routes-plugin",
8
+ transformPlugin: {
9
+ name: "server-routes-transform",
10
+ exportName: EXPORT_NAME,
11
+ imports: (ctx) => {
12
+ const targetModule = `@tanstack/${ctx.target}-start/server`;
13
+ const imports = {};
14
+ if (ctx.verboseFileRoutes === false) {
15
+ imports.banned = [
16
+ {
17
+ source: targetModule,
18
+ specifiers: [{ imported: "createServerFileRoute" }]
19
+ }
20
+ ];
21
+ } else {
22
+ imports.required = [
23
+ {
24
+ source: targetModule,
25
+ specifiers: [{ imported: "createServerFileRoute" }]
26
+ }
27
+ ];
28
+ }
29
+ return imports;
30
+ },
31
+ onExportFound: ({ ctx, decl }) => {
32
+ var _a;
33
+ let appliedChanges = false;
34
+ if (((_a = decl.init) == null ? void 0 : _a.type) === "CallExpression") {
35
+ let call = decl.init;
36
+ let callee = call.callee;
37
+ while (callee.type === "MemberExpression" && callee.object.type === "CallExpression") {
38
+ call = callee.object;
39
+ callee = call.callee;
40
+ }
41
+ if (call.callee.type === "Identifier" && call.callee.name === "createServerFileRoute") {
42
+ if (!ctx.verboseFileRoutes) {
43
+ if (call.arguments.length) {
44
+ call.arguments = [];
45
+ appliedChanges = true;
46
+ }
47
+ } else {
48
+ appliedChanges = routerGenerator.ensureStringArgument(
49
+ call,
50
+ ctx.routeId,
51
+ ctx.preferredQuote
52
+ );
53
+ }
54
+ } else {
55
+ throw new Error(
56
+ `Expected "createServerFileRoute" call, but got "${call.callee.type}"`
57
+ );
58
+ }
59
+ }
60
+ return appliedChanges;
61
+ }
62
+ },
63
+ moduleAugmentation: ({ generator }) => ({
64
+ module: `@tanstack/${generator.config.target}-start/server`,
65
+ interfaceName: "ServerFileRoutesByPath"
66
+ }),
67
+ onRouteTreesChanged: ({ routeTrees, generator }) => {
68
+ const tree = routeTrees.find((tree2) => tree2.exportName === EXPORT_NAME);
69
+ if (tree) {
70
+ routerGenerator.checkRouteFullPathUniqueness(tree.sortedRouteNodes, generator.config);
71
+ }
72
+ },
73
+ imports: (ctx) => {
74
+ var _a;
75
+ const imports = [];
76
+ const targetModule = `@tanstack/${ctx.generator.config.target}-start/server`;
77
+ if (ctx.generator.config.verboseFileRoutes === false) {
78
+ imports.push({
79
+ specifiers: [
80
+ { imported: "CreateServerFileRoute" },
81
+ { imported: "ServerFileRoutesByPath" }
82
+ ],
83
+ source: targetModule,
84
+ importKind: "type"
85
+ });
86
+ }
87
+ const hasMatchingRouteFiles = ctx.acc.routeNodes.length > 0;
88
+ if (hasMatchingRouteFiles) {
89
+ if (!((_a = ctx.rootRouteNode.exports) == null ? void 0 : _a.includes(EXPORT_NAME))) {
90
+ imports.push({
91
+ specifiers: [{ imported: "createServerRootRoute" }],
92
+ source: targetModule
93
+ });
94
+ }
95
+ }
96
+ return imports;
97
+ },
98
+ routeModuleAugmentation: ({ routeNode }) => {
99
+ if (routeNode._fsRouteType === "lazy") {
100
+ return void 0;
101
+ }
102
+ return `const createServerFileRoute: CreateServerFileRoute<
103
+ ServerFileRoutesByPath['${routeNode.routePath}']['parentRoute'],
104
+ ServerFileRoutesByPath['${routeNode.routePath}']['id'],
105
+ ServerFileRoutesByPath['${routeNode.routePath}']['path'],
106
+ ServerFileRoutesByPath['${routeNode.routePath}']['fullPath'],
107
+ ${routerGenerator.hasChildWithExport(routeNode, "ServerRoute") ? `${routeNode.variableName}ServerRouteChildren` : "unknown"}
108
+ >`;
109
+ },
110
+ createRootRouteCode: () => `createServerRootRoute()`,
111
+ createVirtualRouteCode: ({ node }) => `createServerFileRoute('${node.routePath}')`,
112
+ config: ({ sortedRouteNodes }) => {
113
+ const hasMatchingRouteFiles = sortedRouteNodes.length > 0;
114
+ return {
115
+ virtualRootRoute: hasMatchingRouteFiles
116
+ };
117
+ }
118
+ };
119
+ }
120
+ exports.serverRoutesPlugin = serverRoutesPlugin;
121
+ //# sourceMappingURL=server-routes-plugin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-routes-plugin.cjs","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":["ensureStringArgument","tree","checkRouteFullPathUniqueness","hasChildWithExport"],"mappings":";;;AAYA,MAAM,cAAc;AACb,SAAS,qBAAmD;AAC1D,SAAA;AAAA,IACL,MAAM;AAAA,IACN,iBAAiB;AAAA,MACf,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,SAAS,CAAC,QAAQ;AACV,cAAA,eAAe,aAAa,IAAI,MAAM;AAC5C,cAAM,UAAkC,CAAC;AACrC,YAAA,IAAI,sBAAsB,OAAO;AACnC,kBAAQ,SAAS;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 import { GeneratorPluginWithTransform } from '@tanstack/router-generator';
2
+ export declare function serverRoutesPlugin(): GeneratorPluginWithTransform;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const vite = require("@tanstack/router-plugin/vite");
4
+ const routeTreeClientPlugin = require("./route-tree-client-plugin.cjs");
5
+ const virtualRouteTreePlugin = require("./virtual-route-tree-plugin.cjs");
6
+ const routesManifestPlugin = require("./generator-plugins/routes-manifest-plugin.cjs");
7
+ const serverRoutesPlugin = require("./generator-plugins/server-routes-plugin.cjs");
8
+ function tanStackStartRouter(config) {
9
+ return [
10
+ vite.tanstackRouterGenerator({
11
+ ...config,
12
+ plugins: [serverRoutesPlugin.serverRoutesPlugin(), routesManifestPlugin.routesManifestPlugin()]
13
+ }),
14
+ vite.tanStackRouterCodeSplitter(config),
15
+ vite.tanstackRouterAutoImport(config),
16
+ routeTreeClientPlugin.routeTreeClientPlugin(config),
17
+ virtualRouteTreePlugin.virtualRouteTreePlugin(config)
18
+ ];
19
+ }
20
+ exports.tanStackStartRouter = tanStackStartRouter;
21
+ //# sourceMappingURL=plugin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs","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":["tanstackRouterGenerator","serverRoutesPlugin","routesManifestPlugin","tanStackRouterCodeSplitter","tanstackRouterAutoImport","routeTreeClientPlugin","virtualRouteTreePlugin"],"mappings":";;;;;;;AAuBO,SAAS,oBAAoB,QAAqC;AAChE,SAAA;AAAA,IACLA,6BAAwB;AAAA,MACtB,GAAG;AAAA,MACH,SAAS,CAACC,sCAAmB,GAAGC,0CAAsB,CAAA;AAAA,IAAA,CACvD;AAAA,IACDC,KAAAA,2BAA2B,MAAM;AAAA,IACjCC,KAAAA,yBAAyB,MAAM;AAAA,IAC/BC,sBAAAA,sBAAsB,MAAM;AAAA,IAC5BC,uBAAAA,uBAAuB,MAAM;AAAA,EAC/B;AACF;;"}
@@ -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,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const path = require("node:path");
4
+ const t = require("@babel/types");
5
+ const routerUtils = require("@tanstack/router-utils");
6
+ const vite = require("vite");
7
+ const babelDeadCodeElimination = require("babel-dead-code-elimination");
8
+ const debug = require("../debug.cjs");
9
+ function _interopNamespaceDefault(e) {
10
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
11
+ if (e) {
12
+ for (const k in e) {
13
+ if (k !== "default") {
14
+ const d = Object.getOwnPropertyDescriptor(e, k);
15
+ Object.defineProperty(n, k, d.get ? d : {
16
+ enumerable: true,
17
+ get: () => e[k]
18
+ });
19
+ }
20
+ }
21
+ }
22
+ n.default = e;
23
+ return Object.freeze(n);
24
+ }
25
+ const t__namespace = /* @__PURE__ */ _interopNamespaceDefault(t);
26
+ function routeTreeClientPlugin(config) {
27
+ const generatedRouteTreePath = vite.normalizePath(
28
+ path.resolve(config.generatedRouteTree)
29
+ );
30
+ return {
31
+ name: "tanstack-start:route-tree-client-plugin",
32
+ enforce: "pre",
33
+ // only run this plugin in the client environment
34
+ applyToEnvironment: (env) => env.config.consumer === "client",
35
+ transform: {
36
+ filter: { id: generatedRouteTreePath },
37
+ handler(code, id) {
38
+ if (id !== generatedRouteTreePath) {
39
+ return null;
40
+ }
41
+ if (debug.debug) console.info(`Compiling route tree for the client`, id);
42
+ const ast = routerUtils.parseAst({ code, sourceFilename: id });
43
+ const filteredBody = ast.program.body.filter((node) => {
44
+ if (t__namespace.isExportNamedDeclaration(node)) {
45
+ if (node.declaration && t__namespace.isVariableDeclaration(node.declaration) && node.declaration.declarations.length === 1 && node.declaration.declarations[0] && t__namespace.isVariableDeclarator(node.declaration.declarations[0]) && t__namespace.isIdentifier(node.declaration.declarations[0].id) && node.declaration.declarations[0].id.name === "routeTree") {
46
+ return true;
47
+ }
48
+ return false;
49
+ }
50
+ if (t__namespace.isTSInterfaceDeclaration(node) || t__namespace.isTSModuleDeclaration(node)) {
51
+ return false;
52
+ }
53
+ return true;
54
+ });
55
+ ast.program.body = filteredBody;
56
+ babelDeadCodeElimination.deadCodeElimination(ast);
57
+ const compiled = routerUtils.generateFromAst(ast, {
58
+ sourceMaps: true,
59
+ sourceFileName: id,
60
+ filename: id
61
+ });
62
+ if (debug.debug) {
63
+ routerUtils.logDiff(code, compiled.code);
64
+ console.log("Output:\n", compiled.code, "\n\n");
65
+ }
66
+ return compiled;
67
+ }
68
+ }
69
+ };
70
+ }
71
+ exports.routeTreeClientPlugin = routeTreeClientPlugin;
72
+ //# sourceMappingURL=route-tree-client-plugin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-tree-client-plugin.cjs","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 },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AAgB;AAAA,UAChB,UAAU;AAAA,QAAA,CACX;AACD,YAAIJ,aAAO;AACDK,8BAAA,MAAM,SAAS,IAAI;AAC3B,kBAAQ,IAAI,aAAa,SAAS,MAAM,MAAM;AAAA,QAAA;AAGzC,eAAA;AAAA,MAAA;AAAA,IACT;AAAA,EAEJ;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;