@tanstack/start-plugin-core 1.132.1 → 1.132.3
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.
- package/dist/esm/dev-server-plugin/plugin.js +1 -1
- package/dist/esm/dev-server-plugin/plugin.js.map +1 -1
- package/dist/esm/start-compiler-plugin/plugin.js +20 -23
- package/dist/esm/start-compiler-plugin/plugin.js.map +1 -1
- package/package.json +6 -5
- package/src/dev-server-plugin/plugin.ts +1 -1
- package/src/start-compiler-plugin/plugin.ts +20 -24
|
@@ -151,7 +151,7 @@ function devServerPlugin({
|
|
|
151
151
|
function prepareError(req, error) {
|
|
152
152
|
const e = error;
|
|
153
153
|
return {
|
|
154
|
-
message: `An error
|
|
154
|
+
message: `An error occurred while server rendering ${req.url}:
|
|
155
155
|
|
|
156
156
|
${typeof e === "string" ? e : e.message} `,
|
|
157
157
|
stack: typeof e === "string" ? "" : e.stack
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../../src/dev-server-plugin/plugin.ts"],"sourcesContent":["import { isRunnableDevEnvironment } from 'vite'\nimport { VIRTUAL_MODULES } from '@tanstack/start-server-core'\nimport { NodeRequest, sendNodeResponse } from 'srvx/node'\nimport { ENTRY_POINTS, VITE_ENVIRONMENT_NAMES } from '../constants'\nimport { resolveViteId } from '../utils'\nimport { extractHtmlScripts } from './extract-html-scripts'\nimport type { Connect, DevEnvironment, PluginOption } from 'vite'\nimport type { TanStackStartOutputConfig } from '../schema'\n\nexport function devServerPlugin({\n getConfig,\n}: {\n getConfig: () => { startConfig: TanStackStartOutputConfig }\n}): PluginOption {\n let isTest = false\n\n let injectedHeadScripts: string | undefined\n\n return [\n {\n name: 'tanstack-start-core:dev-server',\n config(_userConfig, { mode }) {\n isTest = isTest ? isTest : mode === 'test'\n },\n async configureServer(viteDevServer) {\n if (isTest) {\n return\n }\n\n // Extract the scripts that Vite plugins would inject into the initial HTML\n const templateHtml = `<html><head></head><body></body></html>`\n const transformedHtml = await viteDevServer.transformIndexHtml(\n '/',\n templateHtml,\n )\n const scripts = extractHtmlScripts(transformedHtml)\n injectedHeadScripts = scripts\n .flatMap((script) => script.content ?? [])\n .join(';')\n\n return () => {\n const serverEnv = viteDevServer.environments[\n VITE_ENVIRONMENT_NAMES.server\n ] as DevEnvironment | undefined\n\n if (!serverEnv) {\n throw new Error(\n `Server environment ${VITE_ENVIRONMENT_NAMES.server} not found`,\n )\n }\n const { startConfig } = getConfig()\n const installMiddleware = startConfig.vite?.installDevServerMiddleware\n if (installMiddleware === false) {\n return\n }\n if (installMiddleware == undefined) {\n // do not install middleware in middlewareMode by default\n if (viteDevServer.config.server.middlewareMode) {\n return\n }\n\n // do not install middleware if SSR env in case another plugin already did\n if (\n !isRunnableDevEnvironment(serverEnv) ||\n // do not check via `isFetchableDevEnvironment` since nitro does implement the `FetchableDevEnvironment` interface but not via inheritance (which this helper checks)\n 'dispatchFetch' in serverEnv\n ) {\n return\n }\n }\n\n if (!isRunnableDevEnvironment(serverEnv)) {\n throw new Error(\n 'cannot install vite dev server middleware for TanStack Start since the SSR environment is not a RunnableDevEnvironment',\n )\n }\n\n viteDevServer.middlewares.use(async (req, res) => {\n // fix the request URL to match the original URL\n // otherwise, the request URL will '/index.html'\n if (req.originalUrl) {\n req.url = req.originalUrl\n }\n const webReq = new NodeRequest({ req, res })\n\n try {\n // Import and resolve the request by running the server request entry point\n // this request entry point must implement the `fetch` API as follows:\n /**\n * export default {\n * fetch(req: Request): Promise<Response>\n * }\n */\n const serverEntry = await serverEnv.runner.import(\n ENTRY_POINTS.server,\n )\n const webRes = await serverEntry['default'].fetch(webReq)\n\n return sendNodeResponse(res, webRes)\n } catch (e) {\n console.error(e)\n try {\n viteDevServer.ssrFixStacktrace(e as Error)\n } catch (_e) {}\n\n if (\n webReq.headers.get('content-type')?.includes('application/json')\n ) {\n return sendNodeResponse(\n res,\n new Response(\n JSON.stringify(\n {\n status: 500,\n error: 'Internal Server Error',\n message:\n 'An unexpected error occurred. Please try again later.',\n timestamp: new Date().toISOString(),\n },\n null,\n 2,\n ),\n {\n status: 500,\n headers: {\n 'Content-Type': 'application/json',\n },\n },\n ),\n )\n }\n\n return sendNodeResponse(\n res,\n new Response(\n `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <title>Error</title>\n <script type=\"module\">\n import { ErrorOverlay } from '/@vite/client'\n document.body.appendChild(new ErrorOverlay(${JSON.stringify(\n prepareError(req, e),\n ).replace(/</g, '\\\\u003c')}))\n </script>\n </head>\n <body>\n </body>\n </html>\n `,\n {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n },\n ),\n )\n }\n })\n }\n },\n },\n {\n name: 'tanstack-start-core:dev-server:injected-head-scripts',\n sharedDuringBuild: true,\n applyToEnvironment: (env) => env.config.consumer === 'server',\n resolveId: {\n filter: { id: new RegExp(VIRTUAL_MODULES.injectedHeadScripts) },\n handler(_id) {\n return resolveViteId(VIRTUAL_MODULES.injectedHeadScripts)\n },\n },\n load: {\n filter: {\n id: new RegExp(resolveViteId(VIRTUAL_MODULES.injectedHeadScripts)),\n },\n handler() {\n const mod = `\n export const injectedHeadScripts = ${JSON.stringify(injectedHeadScripts) || 'undefined'}`\n return mod\n },\n },\n },\n ]\n}\n\n/**\n * Formats error for SSR message in error overlay\n * @param req\n * @param error\n * @returns\n */\nfunction prepareError(req: Connect.IncomingMessage, error: unknown) {\n const e = error as Error\n return {\n message: `An error
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../../src/dev-server-plugin/plugin.ts"],"sourcesContent":["import { isRunnableDevEnvironment } from 'vite'\nimport { VIRTUAL_MODULES } from '@tanstack/start-server-core'\nimport { NodeRequest, sendNodeResponse } from 'srvx/node'\nimport { ENTRY_POINTS, VITE_ENVIRONMENT_NAMES } from '../constants'\nimport { resolveViteId } from '../utils'\nimport { extractHtmlScripts } from './extract-html-scripts'\nimport type { Connect, DevEnvironment, PluginOption } from 'vite'\nimport type { TanStackStartOutputConfig } from '../schema'\n\nexport function devServerPlugin({\n getConfig,\n}: {\n getConfig: () => { startConfig: TanStackStartOutputConfig }\n}): PluginOption {\n let isTest = false\n\n let injectedHeadScripts: string | undefined\n\n return [\n {\n name: 'tanstack-start-core:dev-server',\n config(_userConfig, { mode }) {\n isTest = isTest ? isTest : mode === 'test'\n },\n async configureServer(viteDevServer) {\n if (isTest) {\n return\n }\n\n // Extract the scripts that Vite plugins would inject into the initial HTML\n const templateHtml = `<html><head></head><body></body></html>`\n const transformedHtml = await viteDevServer.transformIndexHtml(\n '/',\n templateHtml,\n )\n const scripts = extractHtmlScripts(transformedHtml)\n injectedHeadScripts = scripts\n .flatMap((script) => script.content ?? [])\n .join(';')\n\n return () => {\n const serverEnv = viteDevServer.environments[\n VITE_ENVIRONMENT_NAMES.server\n ] as DevEnvironment | undefined\n\n if (!serverEnv) {\n throw new Error(\n `Server environment ${VITE_ENVIRONMENT_NAMES.server} not found`,\n )\n }\n const { startConfig } = getConfig()\n const installMiddleware = startConfig.vite?.installDevServerMiddleware\n if (installMiddleware === false) {\n return\n }\n if (installMiddleware == undefined) {\n // do not install middleware in middlewareMode by default\n if (viteDevServer.config.server.middlewareMode) {\n return\n }\n\n // do not install middleware if SSR env in case another plugin already did\n if (\n !isRunnableDevEnvironment(serverEnv) ||\n // do not check via `isFetchableDevEnvironment` since nitro does implement the `FetchableDevEnvironment` interface but not via inheritance (which this helper checks)\n 'dispatchFetch' in serverEnv\n ) {\n return\n }\n }\n\n if (!isRunnableDevEnvironment(serverEnv)) {\n throw new Error(\n 'cannot install vite dev server middleware for TanStack Start since the SSR environment is not a RunnableDevEnvironment',\n )\n }\n\n viteDevServer.middlewares.use(async (req, res) => {\n // fix the request URL to match the original URL\n // otherwise, the request URL will '/index.html'\n if (req.originalUrl) {\n req.url = req.originalUrl\n }\n const webReq = new NodeRequest({ req, res })\n\n try {\n // Import and resolve the request by running the server request entry point\n // this request entry point must implement the `fetch` API as follows:\n /**\n * export default {\n * fetch(req: Request): Promise<Response>\n * }\n */\n const serverEntry = await serverEnv.runner.import(\n ENTRY_POINTS.server,\n )\n const webRes = await serverEntry['default'].fetch(webReq)\n\n return sendNodeResponse(res, webRes)\n } catch (e) {\n console.error(e)\n try {\n viteDevServer.ssrFixStacktrace(e as Error)\n } catch (_e) {}\n\n if (\n webReq.headers.get('content-type')?.includes('application/json')\n ) {\n return sendNodeResponse(\n res,\n new Response(\n JSON.stringify(\n {\n status: 500,\n error: 'Internal Server Error',\n message:\n 'An unexpected error occurred. Please try again later.',\n timestamp: new Date().toISOString(),\n },\n null,\n 2,\n ),\n {\n status: 500,\n headers: {\n 'Content-Type': 'application/json',\n },\n },\n ),\n )\n }\n\n return sendNodeResponse(\n res,\n new Response(\n `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <title>Error</title>\n <script type=\"module\">\n import { ErrorOverlay } from '/@vite/client'\n document.body.appendChild(new ErrorOverlay(${JSON.stringify(\n prepareError(req, e),\n ).replace(/</g, '\\\\u003c')}))\n </script>\n </head>\n <body>\n </body>\n </html>\n `,\n {\n status: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n },\n ),\n )\n }\n })\n }\n },\n },\n {\n name: 'tanstack-start-core:dev-server:injected-head-scripts',\n sharedDuringBuild: true,\n applyToEnvironment: (env) => env.config.consumer === 'server',\n resolveId: {\n filter: { id: new RegExp(VIRTUAL_MODULES.injectedHeadScripts) },\n handler(_id) {\n return resolveViteId(VIRTUAL_MODULES.injectedHeadScripts)\n },\n },\n load: {\n filter: {\n id: new RegExp(resolveViteId(VIRTUAL_MODULES.injectedHeadScripts)),\n },\n handler() {\n const mod = `\n export const injectedHeadScripts = ${JSON.stringify(injectedHeadScripts) || 'undefined'}`\n return mod\n },\n },\n },\n ]\n}\n\n/**\n * Formats error for SSR message in error overlay\n * @param req\n * @param error\n * @returns\n */\nfunction prepareError(req: Connect.IncomingMessage, error: unknown) {\n const e = error as Error\n return {\n message: `An error occurred while server rendering ${req.url}:\\n\\n\\t${\n typeof e === 'string' ? e : e.message\n } `,\n stack: typeof e === 'string' ? '' : e.stack,\n }\n}\n"],"names":[],"mappings":";;;;;;AASO,SAAS,gBAAgB;AAAA,EAC9B;AACF,GAEiB;AACf,MAAI,SAAS;AAEb,MAAI;AAEJ,SAAO;AAAA,IACL;AAAA,MACE,MAAM;AAAA,MACN,OAAO,aAAa,EAAE,QAAQ;AAC5B,iBAAS,SAAS,SAAS,SAAS;AAAA,MACtC;AAAA,MACA,MAAM,gBAAgB,eAAe;AACnC,YAAI,QAAQ;AACV;AAAA,QACF;AAGA,cAAM,eAAe;AACrB,cAAM,kBAAkB,MAAM,cAAc;AAAA,UAC1C;AAAA,UACA;AAAA,QAAA;AAEF,cAAM,UAAU,mBAAmB,eAAe;AAClD,8BAAsB,QACnB,QAAQ,CAAC,WAAW,OAAO,WAAW,CAAA,CAAE,EACxC,KAAK,GAAG;AAEX,eAAO,MAAM;AACX,gBAAM,YAAY,cAAc,aAC9B,uBAAuB,MACzB;AAEA,cAAI,CAAC,WAAW;AACd,kBAAM,IAAI;AAAA,cACR,sBAAsB,uBAAuB,MAAM;AAAA,YAAA;AAAA,UAEvD;AACA,gBAAM,EAAE,YAAA,IAAgB,UAAA;AACxB,gBAAM,oBAAoB,YAAY,MAAM;AAC5C,cAAI,sBAAsB,OAAO;AAC/B;AAAA,UACF;AACA,cAAI,qBAAqB,QAAW;AAElC,gBAAI,cAAc,OAAO,OAAO,gBAAgB;AAC9C;AAAA,YACF;AAGA,gBACE,CAAC,yBAAyB,SAAS;AAAA,YAEnC,mBAAmB,WACnB;AACA;AAAA,YACF;AAAA,UACF;AAEA,cAAI,CAAC,yBAAyB,SAAS,GAAG;AACxC,kBAAM,IAAI;AAAA,cACR;AAAA,YAAA;AAAA,UAEJ;AAEA,wBAAc,YAAY,IAAI,OAAO,KAAK,QAAQ;AAGhD,gBAAI,IAAI,aAAa;AACnB,kBAAI,MAA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;AAAA,MACN,mBAAmB;AAAA,MACnB,oBAAoB,CAAC,QAAQ,IAAI,OAAO,aAAa;AAAA,MACrD,WAAW;AAAA,QACT,QAAQ,EAAE,IAAI,IAAI,OAAO,gBAAgB,mBAAmB,EAAA;AAAA,QAC5D,QAAQ,KAAK;AACX,iBAAO,cAAc,gBAAgB,mBAAmB;AAAA,QAC1D;AAAA,MAAA;AAAA,MAEF,MAAM;AAAA,QACJ,QAAQ;AAAA,UACN,IAAI,IAAI,OAAO,cAAc,gBAAgB,mBAAmB,CAAC;AAAA,QAAA;AAAA,QAEnE,UAAU;AACR,gBAAM,MAAM;AAAA,6CACuB,KAAK,UAAU,mBAAmB,KAAK,WAAW;AACrF,iBAAO;AAAA,QACT;AAAA,MAAA;AAAA,IACF;AAAA,EACF;AAEJ;AAQA,SAAS,aAAa,KAA8B,OAAgB;AAClE,QAAM,IAAI;AACV,SAAO;AAAA,IACL,SAAS,4CAA4C,IAAI,GAAG;AAAA;AAAA,GAC1D,OAAO,MAAM,WAAW,IAAI,EAAE,OAChC;AAAA,IACA,OAAO,OAAO,MAAM,WAAW,KAAK,EAAE;AAAA,EAAA;AAE1C;"}
|
|
@@ -4,6 +4,7 @@ import { logDiff } from "@tanstack/router-utils";
|
|
|
4
4
|
import { VIRTUAL_MODULES } from "@tanstack/start-server-core";
|
|
5
5
|
import { normalizePath } from "vite";
|
|
6
6
|
import path from "pathe";
|
|
7
|
+
import { makeIdFiltersToMatchWithQuery } from "@rolldown/pluginutils";
|
|
7
8
|
import { VITE_ENVIRONMENT_NAMES } from "../constants.js";
|
|
8
9
|
import { compileStartOutputFactory } from "./compilers.js";
|
|
9
10
|
import { transformFuncs } from "./constants.js";
|
|
@@ -40,29 +41,25 @@ function startCompilerPlugin(framework) {
|
|
|
40
41
|
// we do not want to include them in the transformation
|
|
41
42
|
// however, those packages (especially start-client-core ATM) also USE these functions
|
|
42
43
|
// (namely `createIsomorphicFn` in `packages/start-client-core/src/getRouterInstance.ts`) and thus need to be transformed
|
|
43
|
-
...
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
...resolveRuntimeFiles({
|
|
63
|
-
package: `@tanstack/${framework}-start-client`,
|
|
64
|
-
files: ["index.js"]
|
|
65
|
-
})
|
|
44
|
+
...makeIdFiltersToMatchWithQuery([
|
|
45
|
+
...resolveRuntimeFiles({
|
|
46
|
+
package: "@tanstack/start-client-core",
|
|
47
|
+
files: [
|
|
48
|
+
"index.js",
|
|
49
|
+
"createIsomorphicFn.js",
|
|
50
|
+
"envOnly.js",
|
|
51
|
+
"serverFnFetcher.js"
|
|
52
|
+
]
|
|
53
|
+
}),
|
|
54
|
+
...resolveRuntimeFiles({
|
|
55
|
+
package: "@tanstack/start-server-core",
|
|
56
|
+
files: ["index.js", "server-functions-handler.js"]
|
|
57
|
+
}),
|
|
58
|
+
...resolveRuntimeFiles({
|
|
59
|
+
package: `@tanstack/${framework}-start-client`,
|
|
60
|
+
files: ["index.js"]
|
|
61
|
+
})
|
|
62
|
+
])
|
|
66
63
|
]
|
|
67
64
|
}
|
|
68
65
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../../src/start-compiler-plugin/plugin.ts"],"sourcesContent":["import { fileURLToPath, pathToFileURL } from 'node:url'\nimport { createRequire } from 'node:module'\nimport { logDiff } from '@tanstack/router-utils'\n\nimport { VIRTUAL_MODULES } from '@tanstack/start-server-core'\nimport { normalizePath } from 'vite'\nimport path from 'pathe'\nimport { VITE_ENVIRONMENT_NAMES } from '../constants'\nimport { compileStartOutputFactory } from './compilers'\nimport { transformFuncs } from './constants'\nimport type { ViteEnvironmentNames } from '../constants'\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 tokenRegex = new RegExp(transformFuncs.join('|'))\n\nconst require = createRequire(import.meta.url)\n\nfunction resolveRuntimeFiles(opts: { package: string; files: Array<string> }) {\n const pkgRoot = resolvePackage(opts.package)\n const basePath = path.join(pkgRoot, 'dist', 'esm')\n
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../../src/start-compiler-plugin/plugin.ts"],"sourcesContent":["import { fileURLToPath, pathToFileURL } from 'node:url'\nimport { createRequire } from 'node:module'\nimport { logDiff } from '@tanstack/router-utils'\n\nimport { VIRTUAL_MODULES } from '@tanstack/start-server-core'\nimport { normalizePath } from 'vite'\nimport path from 'pathe'\nimport { makeIdFiltersToMatchWithQuery } from '@rolldown/pluginutils'\nimport { VITE_ENVIRONMENT_NAMES } from '../constants'\nimport { compileStartOutputFactory } from './compilers'\nimport { transformFuncs } from './constants'\nimport type { ViteEnvironmentNames } from '../constants'\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 tokenRegex = new RegExp(transformFuncs.join('|'))\n\nconst require = createRequire(import.meta.url)\n\nfunction resolveRuntimeFiles(opts: { package: string; files: Array<string> }) {\n const pkgRoot = resolvePackage(opts.package)\n const basePath = path.join(pkgRoot, 'dist', 'esm')\n return opts.files.map((file) => normalizePath(path.join(basePath, file)))\n}\n\nfunction resolvePackage(packageName: string): string {\n const pkgRoot = path.dirname(require.resolve(packageName + '/package.json'))\n return pkgRoot\n}\n\nexport function startCompilerPlugin(\n framework: CompileStartFrameworkOptions,\n): Plugin {\n const compileStartOutput = compileStartOutputFactory(framework)\n\n return {\n name: 'tanstack-start-core:compiler',\n enforce: 'pre',\n applyToEnvironment(env) {\n return [\n VITE_ENVIRONMENT_NAMES.client,\n VITE_ENVIRONMENT_NAMES.server,\n ].includes(env.name as ViteEnvironmentNames)\n },\n transform: {\n filter: {\n code: tokenRegex,\n id: {\n exclude: [\n VIRTUAL_MODULES.serverFnManifest,\n // N.B. the following files either just re-export or provide the runtime implementation of those functions\n // we do not want to include them in the transformation\n // however, those packages (especially start-client-core ATM) also USE these functions\n // (namely `createIsomorphicFn` in `packages/start-client-core/src/getRouterInstance.ts`) and thus need to be transformed\n ...makeIdFiltersToMatchWithQuery([\n ...resolveRuntimeFiles({\n package: '@tanstack/start-client-core',\n files: [\n 'index.js',\n 'createIsomorphicFn.js',\n 'envOnly.js',\n 'serverFnFetcher.js',\n ],\n }),\n ...resolveRuntimeFiles({\n package: '@tanstack/start-server-core',\n files: ['index.js', 'server-functions-handler.js'],\n }),\n ...resolveRuntimeFiles({\n package: `@tanstack/${framework}-start-client`,\n files: ['index.js'],\n }),\n ]),\n ],\n },\n },\n handler(code, id) {\n const env =\n this.environment.name === VITE_ENVIRONMENT_NAMES.client\n ? 'client'\n : this.environment.name === VITE_ENVIRONMENT_NAMES.server\n ? 'server'\n : (() => {\n throw new Error(\n `Environment ${this.environment.name} not configured`,\n )\n })()\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 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 },\n }\n}\n"],"names":["require"],"mappings":";;;;;;;;;;AAeA,MAAM,QACJ,QAAQ,IAAI,kBACZ,CAAC,QAAQ,cAAc,EAAE,SAAS,QAAQ,IAAI,cAAc;AAM9D,MAAM,aAAa,I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,YAAY,SAAS,uBAAuB,SAC7C,WACA,KAAK,YAAY,SAAS,uBAAuB,SAC/C,YACC,MAAM;AACL,gBAAM,IAAI;AAAA,YACR,eAAe,KAAK,YAAY,IAAI;AAAA,UAAA;AAAA,QAExC,GAAA;AAER,cAAM,MAAM,cAAc,EAAE;AAC5B,YAAI,aAAa,OAAO,GAAG;AAC3B,aAAK,cAAc,GAAG,EAAE,QAAQ,OAAO,GAAG;AAE1C,YAAI,MAAO,SAAQ,KAAK,GAAG,GAAG,sBAAsB,EAAE;AAEtD,cAAM,WAAW,mBAAmB;AAAA,UAClC;AAAA,UACA,UAAU;AAAA,UACV;AAAA,QAAA,CACD;AAED,YAAI,OAAO;AACT,kBAAQ,MAAM,SAAS,IAAI;AAC3B,kBAAQ,IAAI,aAAa,SAAS,OAAO,MAAM;AAAA,QACjD;AAEA,eAAO;AAAA,MACT;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/start-plugin-core",
|
|
3
|
-
"version": "1.132.
|
|
3
|
+
"version": "1.132.3",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"@babel/code-frame": "7.26.2",
|
|
49
49
|
"@babel/core": "^7.26.8",
|
|
50
50
|
"@babel/types": "^7.26.8",
|
|
51
|
+
"@rolldown/pluginutils": "1.0.0-beta.40",
|
|
51
52
|
"babel-dead-code-elimination": "^1.0.9",
|
|
52
53
|
"cheerio": "^1.0.0",
|
|
53
54
|
"exsolve": "^1.0.7",
|
|
@@ -57,12 +58,12 @@
|
|
|
57
58
|
"vitefu": "^1.1.1",
|
|
58
59
|
"xmlbuilder2": "^3.1.1",
|
|
59
60
|
"zod": "^3.24.2",
|
|
60
|
-
"@tanstack/router-core": "1.132.
|
|
61
|
-
"@tanstack/router-generator": "1.132.0",
|
|
62
|
-
"@tanstack/router-plugin": "1.132.0",
|
|
61
|
+
"@tanstack/router-core": "1.132.2",
|
|
63
62
|
"@tanstack/router-utils": "1.132.0",
|
|
63
|
+
"@tanstack/router-plugin": "1.132.3",
|
|
64
|
+
"@tanstack/router-generator": "1.132.2",
|
|
64
65
|
"@tanstack/server-functions-plugin": "1.132.0",
|
|
65
|
-
"@tanstack/start-server-core": "1.132.
|
|
66
|
+
"@tanstack/start-server-core": "1.132.3"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
69
|
"@types/babel__code-frame": "^7.0.6",
|
|
@@ -196,7 +196,7 @@ export function devServerPlugin({
|
|
|
196
196
|
function prepareError(req: Connect.IncomingMessage, error: unknown) {
|
|
197
197
|
const e = error as Error
|
|
198
198
|
return {
|
|
199
|
-
message: `An error
|
|
199
|
+
message: `An error occurred while server rendering ${req.url}:\n\n\t${
|
|
200
200
|
typeof e === 'string' ? e : e.message
|
|
201
201
|
} `,
|
|
202
202
|
stack: typeof e === 'string' ? '' : e.stack,
|
|
@@ -5,6 +5,7 @@ import { logDiff } from '@tanstack/router-utils'
|
|
|
5
5
|
import { VIRTUAL_MODULES } from '@tanstack/start-server-core'
|
|
6
6
|
import { normalizePath } from 'vite'
|
|
7
7
|
import path from 'pathe'
|
|
8
|
+
import { makeIdFiltersToMatchWithQuery } from '@rolldown/pluginutils'
|
|
8
9
|
import { VITE_ENVIRONMENT_NAMES } from '../constants'
|
|
9
10
|
import { compileStartOutputFactory } from './compilers'
|
|
10
11
|
import { transformFuncs } from './constants'
|
|
@@ -27,7 +28,6 @@ const require = createRequire(import.meta.url)
|
|
|
27
28
|
function resolveRuntimeFiles(opts: { package: string; files: Array<string> }) {
|
|
28
29
|
const pkgRoot = resolvePackage(opts.package)
|
|
29
30
|
const basePath = path.join(pkgRoot, 'dist', 'esm')
|
|
30
|
-
|
|
31
31
|
return opts.files.map((file) => normalizePath(path.join(basePath, file)))
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -60,29 +60,25 @@ export function startCompilerPlugin(
|
|
|
60
60
|
// we do not want to include them in the transformation
|
|
61
61
|
// however, those packages (especially start-client-core ATM) also USE these functions
|
|
62
62
|
// (namely `createIsomorphicFn` in `packages/start-client-core/src/getRouterInstance.ts`) and thus need to be transformed
|
|
63
|
-
...
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
'
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
...resolveRuntimeFiles({
|
|
83
|
-
package: `@tanstack/${framework}-start-client`,
|
|
84
|
-
files: ['index.js'],
|
|
85
|
-
}),
|
|
63
|
+
...makeIdFiltersToMatchWithQuery([
|
|
64
|
+
...resolveRuntimeFiles({
|
|
65
|
+
package: '@tanstack/start-client-core',
|
|
66
|
+
files: [
|
|
67
|
+
'index.js',
|
|
68
|
+
'createIsomorphicFn.js',
|
|
69
|
+
'envOnly.js',
|
|
70
|
+
'serverFnFetcher.js',
|
|
71
|
+
],
|
|
72
|
+
}),
|
|
73
|
+
...resolveRuntimeFiles({
|
|
74
|
+
package: '@tanstack/start-server-core',
|
|
75
|
+
files: ['index.js', 'server-functions-handler.js'],
|
|
76
|
+
}),
|
|
77
|
+
...resolveRuntimeFiles({
|
|
78
|
+
package: `@tanstack/${framework}-start-client`,
|
|
79
|
+
files: ['index.js'],
|
|
80
|
+
}),
|
|
81
|
+
]),
|
|
86
82
|
],
|
|
87
83
|
},
|
|
88
84
|
},
|