@tanstack/start-plugin-core 1.120.4-alpha.23 → 1.120.4-alpha.25
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.
|
@@ -72,7 +72,18 @@ function nitroPlugin(options, getSsrBundle) {
|
|
|
72
72
|
};
|
|
73
73
|
const nitro = await nitropack.createNitro(nitroConfig);
|
|
74
74
|
await buildNitro.buildNitroEnvironment(nitro, () => nitropack.build(nitro));
|
|
75
|
-
if ((_a = options.
|
|
75
|
+
if (((_a = options.prerender) == null ? void 0 : _a.enabled) !== false) {
|
|
76
|
+
options.prerender = {
|
|
77
|
+
...options.prerender,
|
|
78
|
+
enabled: options.pages.some(
|
|
79
|
+
(d) => {
|
|
80
|
+
var _a2;
|
|
81
|
+
return typeof d === "string" ? false : !!((_a2 = d.prerender) == null ? void 0 : _a2.enabled);
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if ((_b = options.spa) == null ? void 0 : _b.enabled) {
|
|
76
87
|
options.prerender = {
|
|
77
88
|
...options.prerender,
|
|
78
89
|
enabled: true
|
|
@@ -90,7 +101,7 @@ function nitroPlugin(options, getSsrBundle) {
|
|
|
90
101
|
}
|
|
91
102
|
});
|
|
92
103
|
}
|
|
93
|
-
if (
|
|
104
|
+
if (options.prerender.enabled) {
|
|
94
105
|
await prerender.prerender({
|
|
95
106
|
options,
|
|
96
107
|
nitro,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nitro-plugin.cjs","sources":["../../../src/nitro/nitro-plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { rmSync } from 'node:fs'\nimport { build, createNitro } from 'nitropack'\nimport { dirname, resolve } from 'pathe'\nimport { clientDistDir, ssrEntryFile } from '../plugin'\nimport { prerender } from '../prerender'\nimport { VITE_ENVIRONMENT_NAMES } from '../constants'\nimport { devServerPlugin } from './dev-server-plugin'\nimport { buildNitroEnvironment } from './build-nitro'\nimport type { EnvironmentOptions, PluginOption, Rollup } from 'vite'\nimport type { NitroConfig } from 'nitropack'\nimport type { TanStackStartOutputConfig } from '../plugin'\n\nexport function nitroPlugin(\n options: TanStackStartOutputConfig,\n getSsrBundle: () => Rollup.OutputBundle,\n): Array<PluginOption> {\n const buildPreset =\n process.env['START_TARGET'] ?? (options.target as string | undefined)\n\n return [\n devServerPlugin(),\n {\n name: 'tanstack-vite-plugin-nitro',\n configEnvironment(name) {\n if (name === VITE_ENVIRONMENT_NAMES.server) {\n return {\n build: {\n commonjsOptions: {\n include: [],\n },\n ssr: true,\n sourcemap: true,\n rollupOptions: {\n input: '/~start/server-entry',\n },\n },\n } satisfies EnvironmentOptions\n }\n\n return null\n },\n config() {\n return {\n builder: {\n sharedPlugins: true,\n async buildApp(builder) {\n const clientEnv =\n builder.environments[VITE_ENVIRONMENT_NAMES.client]\n const serverEnv =\n builder.environments[VITE_ENVIRONMENT_NAMES.server]\n\n if (!clientEnv) {\n throw new Error('Client environment not found')\n }\n\n if (!serverEnv) {\n throw new Error('SSR environment not found')\n }\n\n const clientOutputDir = resolve(options.root, clientDistDir)\n rmSync(clientOutputDir, { recursive: true, force: true })\n await builder.build(clientEnv)\n\n await builder.build(serverEnv)\n\n const nitroConfig: NitroConfig = {\n dev: false,\n // TODO do we need this? should this be made configurable?\n compatibilityDate: '2024-11-19',\n logLevel: 3,\n preset: buildPreset,\n publicAssets: [\n {\n dir: path.resolve(options.root, clientDistDir),\n },\n ],\n typescript: {\n generateTsConfig: false,\n },\n prerender: undefined,\n renderer: ssrEntryFile,\n rollupConfig: {\n plugins: [virtualBundlePlugin(getSsrBundle())],\n },\n }\n\n const nitro = await createNitro(nitroConfig)\n\n await buildNitroEnvironment(nitro, () => build(nitro))\n\n if (options.spa?.enabled) {\n options.prerender = {\n ...options.prerender,\n enabled: true,\n }\n\n const maskUrl = new URL(\n options.spa.maskPath,\n 'http://localhost',\n )\n\n maskUrl.searchParams.set('__TSS_SHELL', 'true')\n\n options.pages.push({\n path: maskUrl.toString().replace('http://localhost', ''),\n prerender: options.spa.prerender,\n sitemap: {\n exclude: true,\n },\n })\n }\n\n if (options.prerender
|
|
1
|
+
{"version":3,"file":"nitro-plugin.cjs","sources":["../../../src/nitro/nitro-plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { rmSync } from 'node:fs'\nimport { build, createNitro } from 'nitropack'\nimport { dirname, resolve } from 'pathe'\nimport { clientDistDir, ssrEntryFile } from '../plugin'\nimport { prerender } from '../prerender'\nimport { VITE_ENVIRONMENT_NAMES } from '../constants'\nimport { devServerPlugin } from './dev-server-plugin'\nimport { buildNitroEnvironment } from './build-nitro'\nimport type { EnvironmentOptions, PluginOption, Rollup } from 'vite'\nimport type { NitroConfig } from 'nitropack'\nimport type { TanStackStartOutputConfig } from '../plugin'\n\nexport function nitroPlugin(\n options: TanStackStartOutputConfig,\n getSsrBundle: () => Rollup.OutputBundle,\n): Array<PluginOption> {\n const buildPreset =\n process.env['START_TARGET'] ?? (options.target as string | undefined)\n\n return [\n devServerPlugin(),\n {\n name: 'tanstack-vite-plugin-nitro',\n configEnvironment(name) {\n if (name === VITE_ENVIRONMENT_NAMES.server) {\n return {\n build: {\n commonjsOptions: {\n include: [],\n },\n ssr: true,\n sourcemap: true,\n rollupOptions: {\n input: '/~start/server-entry',\n },\n },\n } satisfies EnvironmentOptions\n }\n\n return null\n },\n config() {\n return {\n builder: {\n sharedPlugins: true,\n async buildApp(builder) {\n const clientEnv =\n builder.environments[VITE_ENVIRONMENT_NAMES.client]\n const serverEnv =\n builder.environments[VITE_ENVIRONMENT_NAMES.server]\n\n if (!clientEnv) {\n throw new Error('Client environment not found')\n }\n\n if (!serverEnv) {\n throw new Error('SSR environment not found')\n }\n\n const clientOutputDir = resolve(options.root, clientDistDir)\n rmSync(clientOutputDir, { recursive: true, force: true })\n await builder.build(clientEnv)\n\n await builder.build(serverEnv)\n\n const nitroConfig: NitroConfig = {\n dev: false,\n // TODO do we need this? should this be made configurable?\n compatibilityDate: '2024-11-19',\n logLevel: 3,\n preset: buildPreset,\n publicAssets: [\n {\n dir: path.resolve(options.root, clientDistDir),\n },\n ],\n typescript: {\n generateTsConfig: false,\n },\n prerender: undefined,\n renderer: ssrEntryFile,\n rollupConfig: {\n plugins: [virtualBundlePlugin(getSsrBundle())],\n },\n }\n\n const nitro = await createNitro(nitroConfig)\n\n await buildNitroEnvironment(nitro, () => build(nitro))\n\n // If the user has not set a prerender option, we need to set it to true\n // if the pages array is not empty and has sub options requiring for prerendering\n if (options.prerender?.enabled !== false) {\n options.prerender = {\n ...options.prerender,\n enabled: options.pages.some((d) =>\n typeof d === 'string' ? false : !!d.prerender?.enabled,\n ),\n }\n }\n\n // Setup the options for prerendering the SPA shell (i.e `src/routes/__root.tsx`)\n if (options.spa?.enabled) {\n options.prerender = {\n ...options.prerender,\n enabled: true,\n }\n\n const maskUrl = new URL(\n options.spa.maskPath,\n 'http://localhost',\n )\n\n maskUrl.searchParams.set('__TSS_SHELL', 'true')\n\n options.pages.push({\n path: maskUrl.toString().replace('http://localhost', ''),\n prerender: options.spa.prerender,\n sitemap: {\n exclude: true,\n },\n })\n }\n\n // Start prerendering!!!\n if (options.prerender.enabled) {\n await prerender({\n options,\n nitro,\n builder,\n })\n }\n\n // if (nitroConfig.prerender?.routes?.length && options.sitemap) {\n // console.log('Building Sitemap...')\n // // sitemap needs to be built after all directories are built\n // await buildSitemap({\n // host: options.sitemap.host,\n // routes: nitroConfig.prerender.routes,\n // outputDir: resolve(options.root, 'dist/public'),\n // })\n // }\n\n // console.log(\n // `\\n\\n✅ Client and server bundles successfully built.`,\n // )\n },\n },\n }\n },\n },\n ]\n}\n\nfunction virtualBundlePlugin(ssrBundle: Rollup.OutputBundle): Rollup.Plugin {\n type VirtualModule = { code: string; map: string | null }\n const _modules = new Map<string, VirtualModule>()\n\n // group chunks and source maps\n for (const [fileName, content] of Object.entries(ssrBundle)) {\n if (content.type === 'chunk') {\n const virtualModule: VirtualModule = {\n code: content.code,\n map: null,\n }\n const maybeMap = ssrBundle[`${fileName}.map`]\n if (maybeMap && maybeMap.type === 'asset') {\n virtualModule.map = maybeMap.source as string\n }\n _modules.set(fileName, virtualModule)\n _modules.set(resolve(fileName), virtualModule)\n }\n }\n\n return {\n name: 'virtual-bundle',\n resolveId(id, importer) {\n if (_modules.has(id)) {\n return resolve(id)\n }\n\n if (importer) {\n const resolved = resolve(dirname(importer), id)\n if (_modules.has(resolved)) {\n return resolved\n }\n }\n return null\n },\n load(id) {\n const m = _modules.get(id)\n if (!m) {\n return null\n }\n return m\n },\n }\n}\n"],"names":["devServerPlugin","VITE_ENVIRONMENT_NAMES","resolve","clientDistDir","rmSync","ssrEntryFile","createNitro","buildNitroEnvironment","build","_a","prerender","dirname"],"mappings":";;;;;;;;;;;AAagB,SAAA,YACd,SACA,cACqB;AACrB,QAAM,cACJ,QAAQ,IAAI,cAAc,KAAM,QAAQ;AAEnC,SAAA;AAAA,IACLA,gCAAgB;AAAA,IAChB;AAAA,MACE,MAAM;AAAA,MACN,kBAAkB,MAAM;AAClB,YAAA,SAASC,iCAAuB,QAAQ;AACnC,iBAAA;AAAA,YACL,OAAO;AAAA,cACL,iBAAiB;AAAA,gBACf,SAAS,CAAA;AAAA,cACX;AAAA,cACA,KAAK;AAAA,cACL,WAAW;AAAA,cACX,eAAe;AAAA,gBACb,OAAO;AAAA,cAAA;AAAA,YACT;AAAA,UAEJ;AAAA,QAAA;AAGK,eAAA;AAAA,MACT;AAAA,MACA,SAAS;AACA,eAAA;AAAA,UACL,SAAS;AAAA,YACP,eAAe;AAAA,YACf,MAAM,SAAS,SAAS;;AACtB,oBAAM,YACJ,QAAQ,aAAaA,UAAAA,uBAAuB,MAAM;AACpD,oBAAM,YACJ,QAAQ,aAAaA,UAAAA,uBAAuB,MAAM;AAEpD,kBAAI,CAAC,WAAW;AACR,sBAAA,IAAI,MAAM,8BAA8B;AAAA,cAAA;AAGhD,kBAAI,CAAC,WAAW;AACR,sBAAA,IAAI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,IAAI,EAAE;AACzB,UAAI,CAAC,GAAG;AACC,eAAA;AAAA,MAAA;AAEF,aAAA;AAAA,IAAA;AAAA,EAEX;AACF;;"}
|
|
@@ -70,7 +70,18 @@ function nitroPlugin(options, getSsrBundle) {
|
|
|
70
70
|
};
|
|
71
71
|
const nitro = await createNitro(nitroConfig);
|
|
72
72
|
await buildNitroEnvironment(nitro, () => build(nitro));
|
|
73
|
-
if ((_a = options.
|
|
73
|
+
if (((_a = options.prerender) == null ? void 0 : _a.enabled) !== false) {
|
|
74
|
+
options.prerender = {
|
|
75
|
+
...options.prerender,
|
|
76
|
+
enabled: options.pages.some(
|
|
77
|
+
(d) => {
|
|
78
|
+
var _a2;
|
|
79
|
+
return typeof d === "string" ? false : !!((_a2 = d.prerender) == null ? void 0 : _a2.enabled);
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if ((_b = options.spa) == null ? void 0 : _b.enabled) {
|
|
74
85
|
options.prerender = {
|
|
75
86
|
...options.prerender,
|
|
76
87
|
enabled: true
|
|
@@ -88,7 +99,7 @@ function nitroPlugin(options, getSsrBundle) {
|
|
|
88
99
|
}
|
|
89
100
|
});
|
|
90
101
|
}
|
|
91
|
-
if (
|
|
102
|
+
if (options.prerender.enabled) {
|
|
92
103
|
await prerender({
|
|
93
104
|
options,
|
|
94
105
|
nitro,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nitro-plugin.js","sources":["../../../src/nitro/nitro-plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { rmSync } from 'node:fs'\nimport { build, createNitro } from 'nitropack'\nimport { dirname, resolve } from 'pathe'\nimport { clientDistDir, ssrEntryFile } from '../plugin'\nimport { prerender } from '../prerender'\nimport { VITE_ENVIRONMENT_NAMES } from '../constants'\nimport { devServerPlugin } from './dev-server-plugin'\nimport { buildNitroEnvironment } from './build-nitro'\nimport type { EnvironmentOptions, PluginOption, Rollup } from 'vite'\nimport type { NitroConfig } from 'nitropack'\nimport type { TanStackStartOutputConfig } from '../plugin'\n\nexport function nitroPlugin(\n options: TanStackStartOutputConfig,\n getSsrBundle: () => Rollup.OutputBundle,\n): Array<PluginOption> {\n const buildPreset =\n process.env['START_TARGET'] ?? (options.target as string | undefined)\n\n return [\n devServerPlugin(),\n {\n name: 'tanstack-vite-plugin-nitro',\n configEnvironment(name) {\n if (name === VITE_ENVIRONMENT_NAMES.server) {\n return {\n build: {\n commonjsOptions: {\n include: [],\n },\n ssr: true,\n sourcemap: true,\n rollupOptions: {\n input: '/~start/server-entry',\n },\n },\n } satisfies EnvironmentOptions\n }\n\n return null\n },\n config() {\n return {\n builder: {\n sharedPlugins: true,\n async buildApp(builder) {\n const clientEnv =\n builder.environments[VITE_ENVIRONMENT_NAMES.client]\n const serverEnv =\n builder.environments[VITE_ENVIRONMENT_NAMES.server]\n\n if (!clientEnv) {\n throw new Error('Client environment not found')\n }\n\n if (!serverEnv) {\n throw new Error('SSR environment not found')\n }\n\n const clientOutputDir = resolve(options.root, clientDistDir)\n rmSync(clientOutputDir, { recursive: true, force: true })\n await builder.build(clientEnv)\n\n await builder.build(serverEnv)\n\n const nitroConfig: NitroConfig = {\n dev: false,\n // TODO do we need this? should this be made configurable?\n compatibilityDate: '2024-11-19',\n logLevel: 3,\n preset: buildPreset,\n publicAssets: [\n {\n dir: path.resolve(options.root, clientDistDir),\n },\n ],\n typescript: {\n generateTsConfig: false,\n },\n prerender: undefined,\n renderer: ssrEntryFile,\n rollupConfig: {\n plugins: [virtualBundlePlugin(getSsrBundle())],\n },\n }\n\n const nitro = await createNitro(nitroConfig)\n\n await buildNitroEnvironment(nitro, () => build(nitro))\n\n if (options.spa?.enabled) {\n options.prerender = {\n ...options.prerender,\n enabled: true,\n }\n\n const maskUrl = new URL(\n options.spa.maskPath,\n 'http://localhost',\n )\n\n maskUrl.searchParams.set('__TSS_SHELL', 'true')\n\n options.pages.push({\n path: maskUrl.toString().replace('http://localhost', ''),\n prerender: options.spa.prerender,\n sitemap: {\n exclude: true,\n },\n })\n }\n\n if (options.prerender
|
|
1
|
+
{"version":3,"file":"nitro-plugin.js","sources":["../../../src/nitro/nitro-plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { rmSync } from 'node:fs'\nimport { build, createNitro } from 'nitropack'\nimport { dirname, resolve } from 'pathe'\nimport { clientDistDir, ssrEntryFile } from '../plugin'\nimport { prerender } from '../prerender'\nimport { VITE_ENVIRONMENT_NAMES } from '../constants'\nimport { devServerPlugin } from './dev-server-plugin'\nimport { buildNitroEnvironment } from './build-nitro'\nimport type { EnvironmentOptions, PluginOption, Rollup } from 'vite'\nimport type { NitroConfig } from 'nitropack'\nimport type { TanStackStartOutputConfig } from '../plugin'\n\nexport function nitroPlugin(\n options: TanStackStartOutputConfig,\n getSsrBundle: () => Rollup.OutputBundle,\n): Array<PluginOption> {\n const buildPreset =\n process.env['START_TARGET'] ?? (options.target as string | undefined)\n\n return [\n devServerPlugin(),\n {\n name: 'tanstack-vite-plugin-nitro',\n configEnvironment(name) {\n if (name === VITE_ENVIRONMENT_NAMES.server) {\n return {\n build: {\n commonjsOptions: {\n include: [],\n },\n ssr: true,\n sourcemap: true,\n rollupOptions: {\n input: '/~start/server-entry',\n },\n },\n } satisfies EnvironmentOptions\n }\n\n return null\n },\n config() {\n return {\n builder: {\n sharedPlugins: true,\n async buildApp(builder) {\n const clientEnv =\n builder.environments[VITE_ENVIRONMENT_NAMES.client]\n const serverEnv =\n builder.environments[VITE_ENVIRONMENT_NAMES.server]\n\n if (!clientEnv) {\n throw new Error('Client environment not found')\n }\n\n if (!serverEnv) {\n throw new Error('SSR environment not found')\n }\n\n const clientOutputDir = resolve(options.root, clientDistDir)\n rmSync(clientOutputDir, { recursive: true, force: true })\n await builder.build(clientEnv)\n\n await builder.build(serverEnv)\n\n const nitroConfig: NitroConfig = {\n dev: false,\n // TODO do we need this? should this be made configurable?\n compatibilityDate: '2024-11-19',\n logLevel: 3,\n preset: buildPreset,\n publicAssets: [\n {\n dir: path.resolve(options.root, clientDistDir),\n },\n ],\n typescript: {\n generateTsConfig: false,\n },\n prerender: undefined,\n renderer: ssrEntryFile,\n rollupConfig: {\n plugins: [virtualBundlePlugin(getSsrBundle())],\n },\n }\n\n const nitro = await createNitro(nitroConfig)\n\n await buildNitroEnvironment(nitro, () => build(nitro))\n\n // If the user has not set a prerender option, we need to set it to true\n // if the pages array is not empty and has sub options requiring for prerendering\n if (options.prerender?.enabled !== false) {\n options.prerender = {\n ...options.prerender,\n enabled: options.pages.some((d) =>\n typeof d === 'string' ? false : !!d.prerender?.enabled,\n ),\n }\n }\n\n // Setup the options for prerendering the SPA shell (i.e `src/routes/__root.tsx`)\n if (options.spa?.enabled) {\n options.prerender = {\n ...options.prerender,\n enabled: true,\n }\n\n const maskUrl = new URL(\n options.spa.maskPath,\n 'http://localhost',\n )\n\n maskUrl.searchParams.set('__TSS_SHELL', 'true')\n\n options.pages.push({\n path: maskUrl.toString().replace('http://localhost', ''),\n prerender: options.spa.prerender,\n sitemap: {\n exclude: true,\n },\n })\n }\n\n // Start prerendering!!!\n if (options.prerender.enabled) {\n await prerender({\n options,\n nitro,\n builder,\n })\n }\n\n // if (nitroConfig.prerender?.routes?.length && options.sitemap) {\n // console.log('Building Sitemap...')\n // // sitemap needs to be built after all directories are built\n // await buildSitemap({\n // host: options.sitemap.host,\n // routes: nitroConfig.prerender.routes,\n // outputDir: resolve(options.root, 'dist/public'),\n // })\n // }\n\n // console.log(\n // `\\n\\n✅ Client and server bundles successfully built.`,\n // )\n },\n },\n }\n },\n },\n ]\n}\n\nfunction virtualBundlePlugin(ssrBundle: Rollup.OutputBundle): Rollup.Plugin {\n type VirtualModule = { code: string; map: string | null }\n const _modules = new Map<string, VirtualModule>()\n\n // group chunks and source maps\n for (const [fileName, content] of Object.entries(ssrBundle)) {\n if (content.type === 'chunk') {\n const virtualModule: VirtualModule = {\n code: content.code,\n map: null,\n }\n const maybeMap = ssrBundle[`${fileName}.map`]\n if (maybeMap && maybeMap.type === 'asset') {\n virtualModule.map = maybeMap.source as string\n }\n _modules.set(fileName, virtualModule)\n _modules.set(resolve(fileName), virtualModule)\n }\n }\n\n return {\n name: 'virtual-bundle',\n resolveId(id, importer) {\n if (_modules.has(id)) {\n return resolve(id)\n }\n\n if (importer) {\n const resolved = resolve(dirname(importer), id)\n if (_modules.has(resolved)) {\n return resolved\n }\n }\n return null\n },\n load(id) {\n const m = _modules.get(id)\n if (!m) {\n return null\n }\n return m\n },\n }\n}\n"],"names":["_a"],"mappings":";;;;;;;;;AAagB,SAAA,YACd,SACA,cACqB;AACrB,QAAM,cACJ,QAAQ,IAAI,cAAc,KAAM,QAAQ;AAEnC,SAAA;AAAA,IACL,gBAAgB;AAAA,IAChB;AAAA,MACE,MAAM;AAAA,MACN,kBAAkB,MAAM;AAClB,YAAA,SAAS,uBAAuB,QAAQ;AACnC,iBAAA;AAAA,YACL,OAAO;AAAA,cACL,iBAAiB;AAAA,gBACf,SAAS,CAAA;AAAA,cACX;AAAA,cACA,KAAK;AAAA,cACL,WAAW;AAAA,cACX,eAAe;AAAA,gBACb,OAAO;AAAA,cAAA;AAAA,YACT;AAAA,UAEJ;AAAA,QAAA;AAGK,eAAA;AAAA,MACT;AAAA,MACA,SAAS;AACA,eAAA;AAAA,UACL,SAAS;AAAA,YACP,eAAe;AAAA,YACf,MAAM,SAAS,SAAS;;AACtB,oBAAM,YACJ,QAAQ,aAAa,uBAAuB,MAAM;AACpD,oBAAM,YACJ,QAAQ,aAAa,uBAAuB,MAAM;AAEpD,kBAAI,CAAC,WAAW;AACR,sBAAA,IAAI,MAAM,8BAA8B;AAAA,cAAA;AAGhD,kBAAI,CAAC,WAAW;AACR,sBAAA,IAAI,MAAM,2BAA2B;AAAA,cAAA;AAG7C,oBAAM,kBAAkB,QAAQ,QAAQ,MAAM,aAAa;AAC3D,qBAAO,iBAAiB,EAAE,WAAW,MAAM,OAAO,MAAM;AAClD,oBAAA,QAAQ,MAAM,SAAS;AAE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|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"ufo": "^1.5.4",
|
|
64
64
|
"xmlbuilder2": "^3.1.1",
|
|
65
65
|
"zod": "^3.24.2",
|
|
66
|
-
"@tanstack/router-core": "^1.120.4-alpha.19",
|
|
67
66
|
"@tanstack/router-generator": "^1.120.4-alpha.19",
|
|
67
|
+
"@tanstack/router-core": "^1.120.4-alpha.19",
|
|
68
68
|
"@tanstack/router-utils": "^1.120.4-alpha.1",
|
|
69
69
|
"@tanstack/server-functions-plugin": "^1.120.4-alpha.16"
|
|
70
70
|
},
|
|
@@ -89,6 +89,18 @@ export function nitroPlugin(
|
|
|
89
89
|
|
|
90
90
|
await buildNitroEnvironment(nitro, () => build(nitro))
|
|
91
91
|
|
|
92
|
+
// If the user has not set a prerender option, we need to set it to true
|
|
93
|
+
// if the pages array is not empty and has sub options requiring for prerendering
|
|
94
|
+
if (options.prerender?.enabled !== false) {
|
|
95
|
+
options.prerender = {
|
|
96
|
+
...options.prerender,
|
|
97
|
+
enabled: options.pages.some((d) =>
|
|
98
|
+
typeof d === 'string' ? false : !!d.prerender?.enabled,
|
|
99
|
+
),
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Setup the options for prerendering the SPA shell (i.e `src/routes/__root.tsx`)
|
|
92
104
|
if (options.spa?.enabled) {
|
|
93
105
|
options.prerender = {
|
|
94
106
|
...options.prerender,
|
|
@@ -111,7 +123,8 @@ export function nitroPlugin(
|
|
|
111
123
|
})
|
|
112
124
|
}
|
|
113
125
|
|
|
114
|
-
|
|
126
|
+
// Start prerendering!!!
|
|
127
|
+
if (options.prerender.enabled) {
|
|
115
128
|
await prerender({
|
|
116
129
|
options,
|
|
117
130
|
nitro,
|