@tanstack/start-plugin-core 1.120.4-alpha.9 → 1.121.0-alpha.10
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/cjs/build-sitemap.cjs +138 -0
- package/dist/cjs/build-sitemap.cjs.map +1 -0
- package/dist/cjs/build-sitemap.d.cts +31 -0
- package/dist/cjs/constants.cjs +10 -0
- package/dist/cjs/constants.cjs.map +1 -0
- package/dist/cjs/constants.d.cts +4 -0
- package/dist/cjs/index.cjs +2 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -5
- package/dist/cjs/nitro/dev-server-plugin.cjs +11 -3
- package/dist/cjs/nitro/dev-server-plugin.cjs.map +1 -1
- package/dist/cjs/nitro/nitro-plugin.cjs +78 -13
- package/dist/cjs/nitro/nitro-plugin.cjs.map +1 -1
- package/dist/cjs/plugin.cjs +88 -17
- package/dist/cjs/plugin.cjs.map +1 -1
- package/dist/cjs/plugin.d.cts +836 -615
- package/dist/cjs/prerender.cjs +23 -24
- package/dist/cjs/prerender.cjs.map +1 -1
- package/dist/cjs/routesManifestPlugin.cjs +6 -3
- package/dist/cjs/routesManifestPlugin.cjs.map +1 -1
- package/dist/cjs/schema.cjs +27 -6
- package/dist/cjs/schema.cjs.map +1 -1
- package/dist/cjs/schema.d.cts +2729 -2094
- package/dist/cjs/start-server-routes-plugin/plugin.cjs +2 -1
- package/dist/cjs/start-server-routes-plugin/plugin.cjs.map +1 -1
- package/dist/cjs/utils.cjs +18 -0
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/cjs/utils.d.cts +8 -0
- package/dist/esm/build-sitemap.d.ts +31 -0
- package/dist/esm/build-sitemap.js +138 -0
- package/dist/esm/build-sitemap.js.map +1 -0
- package/dist/esm/constants.d.ts +4 -0
- package/dist/esm/constants.js +10 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.d.ts +1 -5
- package/dist/esm/index.js +3 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/nitro/dev-server-plugin.js +11 -3
- package/dist/esm/nitro/dev-server-plugin.js.map +1 -1
- package/dist/esm/nitro/nitro-plugin.js +62 -14
- package/dist/esm/nitro/nitro-plugin.js.map +1 -1
- package/dist/esm/plugin.d.ts +836 -615
- package/dist/esm/plugin.js +71 -17
- package/dist/esm/plugin.js.map +1 -1
- package/dist/esm/prerender.js +23 -24
- package/dist/esm/prerender.js.map +1 -1
- package/dist/esm/routesManifestPlugin.js +6 -3
- package/dist/esm/routesManifestPlugin.js.map +1 -1
- package/dist/esm/schema.d.ts +2729 -2094
- package/dist/esm/schema.js +28 -7
- package/dist/esm/schema.js.map +1 -1
- package/dist/esm/start-server-routes-plugin/plugin.js +6 -5
- package/dist/esm/start-server-routes-plugin/plugin.js.map +1 -1
- package/dist/esm/utils.d.ts +8 -0
- package/dist/esm/utils.js +18 -0
- package/dist/esm/utils.js.map +1 -0
- package/package.json +6 -4
- package/src/build-sitemap.ts +213 -0
- package/src/constants.ts +6 -0
- package/src/index.ts +1 -8
- package/src/nitro/dev-server-plugin.ts +14 -4
- package/src/nitro/nitro-plugin.ts +104 -30
- package/src/plugin.ts +88 -17
- package/src/prerender.ts +30 -30
- package/src/routesManifestPlugin.ts +7 -3
- package/src/schema.ts +37 -10
- package/src/start-server-routes-plugin/plugin.ts +2 -1
- package/src/utils.ts +14 -0
- package/dist/cjs/nitro/build-nitro.cjs +0 -18
- package/dist/cjs/nitro/build-nitro.cjs.map +0 -1
- package/dist/cjs/nitro/build-nitro.d.cts +0 -2
- package/dist/cjs/nitro/build-sitemap.cjs +0 -54
- package/dist/cjs/nitro/build-sitemap.cjs.map +0 -1
- package/dist/cjs/nitro/build-sitemap.d.cts +0 -9
- package/dist/esm/nitro/build-nitro.d.ts +0 -2
- package/dist/esm/nitro/build-nitro.js +0 -18
- package/dist/esm/nitro/build-nitro.js.map +0 -1
- package/dist/esm/nitro/build-sitemap.d.ts +0 -9
- package/dist/esm/nitro/build-sitemap.js +0 -54
- package/dist/esm/nitro/build-sitemap.js.map +0 -1
- package/src/nitro/build-nitro.ts +0 -27
- package/src/nitro/build-sitemap.ts +0 -79
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const xmlbuilder2 = require("xmlbuilder2");
|
|
6
|
+
const utils = require("./utils.cjs");
|
|
7
|
+
function buildSitemapJson(pages, host) {
|
|
8
|
+
const slash = checkSlash(host);
|
|
9
|
+
const urls = pages.filter((page) => {
|
|
10
|
+
var _a;
|
|
11
|
+
return ((_a = page.sitemap) == null ? void 0 : _a.exclude) !== true;
|
|
12
|
+
}).map((page) => {
|
|
13
|
+
var _a, _b, _c, _d, _e, _f;
|
|
14
|
+
return {
|
|
15
|
+
loc: `${host}${slash}${page.path.replace(/^\/+/g, "")}`,
|
|
16
|
+
lastmod: ((_a = page.sitemap) == null ? void 0 : _a.lastmod) ? new Date(page.sitemap.lastmod).toISOString().split("T")[0] : (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
|
|
17
|
+
priority: (_b = page.sitemap) == null ? void 0 : _b.priority,
|
|
18
|
+
changefreq: (_c = page.sitemap) == null ? void 0 : _c.changefreq,
|
|
19
|
+
alternateRefs: (_d = page.sitemap) == null ? void 0 : _d.alternateRefs,
|
|
20
|
+
images: (_e = page.sitemap) == null ? void 0 : _e.images,
|
|
21
|
+
news: (_f = page.sitemap) == null ? void 0 : _f.news
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
return { urls };
|
|
25
|
+
}
|
|
26
|
+
function jsonToXml(sitemapData) {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
const sitemap = createXml("urlset");
|
|
29
|
+
for (const item of sitemapData.urls) {
|
|
30
|
+
const page = sitemap.ele("url");
|
|
31
|
+
page.ele("loc").txt(item.loc);
|
|
32
|
+
page.ele("lastmod").txt(item.lastmod);
|
|
33
|
+
if (item.priority !== void 0) {
|
|
34
|
+
page.ele("priority").txt(item.priority.toString());
|
|
35
|
+
}
|
|
36
|
+
if (item.changefreq) {
|
|
37
|
+
page.ele("changefreq").txt(item.changefreq);
|
|
38
|
+
}
|
|
39
|
+
if ((_a = item.alternateRefs) == null ? void 0 : _a.length) {
|
|
40
|
+
for (const ref of item.alternateRefs) {
|
|
41
|
+
const alternateRef = page.ele("xhtml:link");
|
|
42
|
+
alternateRef.att("rel", "alternate");
|
|
43
|
+
alternateRef.att("href", ref.href);
|
|
44
|
+
if (ref.hreflang) {
|
|
45
|
+
alternateRef.att("hreflang", ref.hreflang);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if ((_b = item.images) == null ? void 0 : _b.length) {
|
|
50
|
+
for (const image of item.images) {
|
|
51
|
+
const imageElement = page.ele("image:image");
|
|
52
|
+
imageElement.ele("image:loc").txt(image.loc);
|
|
53
|
+
if (image.title) {
|
|
54
|
+
imageElement.ele("image:title").txt(image.title);
|
|
55
|
+
}
|
|
56
|
+
if (image.caption) {
|
|
57
|
+
imageElement.ele("image:caption").txt(image.caption);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (item.news) {
|
|
62
|
+
const newsElement = page.ele("news:news");
|
|
63
|
+
const publication = newsElement.ele("news:publication");
|
|
64
|
+
publication.ele("news:name").txt(item.news.publication.name);
|
|
65
|
+
publication.ele("news:language").txt(item.news.publication.language);
|
|
66
|
+
newsElement.ele("news:publication_date").txt(new Date(item.news.publicationDate).toISOString().split("T")[0]);
|
|
67
|
+
newsElement.ele("news:title").txt(item.news.title);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return sitemap.end({ prettyPrint: true });
|
|
71
|
+
}
|
|
72
|
+
function buildSitemap({
|
|
73
|
+
options,
|
|
74
|
+
publicDir
|
|
75
|
+
}) {
|
|
76
|
+
const logger = utils.createLogger("sitemap");
|
|
77
|
+
let sitemapOptions = options.sitemap;
|
|
78
|
+
if (!sitemapOptions && options.pages.length) {
|
|
79
|
+
sitemapOptions = { enabled: true, outputPath: "sitemap.xml" };
|
|
80
|
+
}
|
|
81
|
+
if (!(sitemapOptions == null ? void 0 : sitemapOptions.enabled)) {
|
|
82
|
+
throw new Error("Sitemap is not enabled");
|
|
83
|
+
}
|
|
84
|
+
const { host, outputPath } = sitemapOptions;
|
|
85
|
+
if (!host) {
|
|
86
|
+
if (!options.sitemap) {
|
|
87
|
+
logger.info(
|
|
88
|
+
"Hint: Pages found, but no sitemap host has been set. To enable sitemap generation, set the `sitemap.host` option."
|
|
89
|
+
);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
throw new Error(
|
|
93
|
+
"Sitemap host is not set and required to build the sitemap."
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
if (!outputPath) {
|
|
97
|
+
throw new Error("Sitemap output path is not set");
|
|
98
|
+
}
|
|
99
|
+
const { pages } = options;
|
|
100
|
+
if (!pages.length) {
|
|
101
|
+
logger.info("No pages were found to build the sitemap. Skipping...");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
logger.info("Building Sitemap...");
|
|
105
|
+
const sitemapData = buildSitemapJson(pages, host);
|
|
106
|
+
const xmlOutputPath = path.join(publicDir, outputPath);
|
|
107
|
+
const pagesOutputPath = path.join(publicDir, "pages.json");
|
|
108
|
+
try {
|
|
109
|
+
logger.info(`Writing sitemap XML at ${xmlOutputPath}`);
|
|
110
|
+
fs.writeFileSync(xmlOutputPath, jsonToXml(sitemapData));
|
|
111
|
+
logger.info(`Writing pages data at ${pagesOutputPath}`);
|
|
112
|
+
fs.writeFileSync(
|
|
113
|
+
pagesOutputPath,
|
|
114
|
+
JSON.stringify(
|
|
115
|
+
{
|
|
116
|
+
pages,
|
|
117
|
+
host,
|
|
118
|
+
lastBuilt: (/* @__PURE__ */ new Date()).toISOString()
|
|
119
|
+
},
|
|
120
|
+
null,
|
|
121
|
+
2
|
|
122
|
+
)
|
|
123
|
+
);
|
|
124
|
+
} catch (e) {
|
|
125
|
+
logger.error(`Unable to write sitemap files`, e);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function createXml(elementName) {
|
|
129
|
+
return xmlbuilder2.create({ version: "1.0", encoding: "UTF-8" }).ele(elementName, {
|
|
130
|
+
xmlns: "https://www.sitemaps.org/schemas/sitemap/0.9"
|
|
131
|
+
}).com(`This file was automatically generated by TanStack Start.`);
|
|
132
|
+
}
|
|
133
|
+
function checkSlash(host) {
|
|
134
|
+
const finalChar = host.slice(-1);
|
|
135
|
+
return finalChar === "/" ? "" : "/";
|
|
136
|
+
}
|
|
137
|
+
exports.buildSitemap = buildSitemap;
|
|
138
|
+
//# sourceMappingURL=build-sitemap.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-sitemap.cjs","sources":["../../src/build-sitemap.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs'\nimport path from 'node:path'\nimport { create } from 'xmlbuilder2'\nimport { createLogger } from './utils'\nimport type { TanStackStartOutputConfig } from './plugin'\nimport type { XMLBuilder } from 'xmlbuilder2/lib/interfaces'\n\nexport type SitemapUrl = {\n loc: string\n lastmod: string\n priority?: number\n changefreq?:\n | 'always'\n | 'hourly'\n | 'daily'\n | 'weekly'\n | 'monthly'\n | 'yearly'\n | 'never'\n alternateRefs?: Array<{\n href: string\n hreflang?: string\n }>\n images?: Array<{\n loc: string\n title?: string\n caption?: string\n }>\n news?: {\n publication: {\n name: string\n language: string\n }\n publicationDate: string | Date\n title: string\n }\n}\n\nexport type SitemapData = {\n urls: Array<SitemapUrl>\n}\n\nfunction buildSitemapJson(\n pages: TanStackStartOutputConfig['pages'],\n host: string,\n): SitemapData {\n const slash = checkSlash(host)\n\n const urls: Array<SitemapUrl> = pages\n .filter((page) => {\n return page.sitemap?.exclude !== true\n })\n .map((page) => ({\n loc: `${host}${slash}${page.path.replace(/^\\/+/g, '')}`,\n lastmod: page.sitemap?.lastmod\n ? new Date(page.sitemap.lastmod).toISOString().split('T')[0]!\n : new Date().toISOString().split('T')[0]!,\n priority: page.sitemap?.priority,\n changefreq: page.sitemap?.changefreq,\n alternateRefs: page.sitemap?.alternateRefs,\n images: page.sitemap?.images,\n news: page.sitemap?.news,\n }))\n\n return { urls }\n}\n\nfunction jsonToXml(sitemapData: SitemapData): string {\n const sitemap = createXml('urlset')\n\n for (const item of sitemapData.urls) {\n const page = sitemap.ele('url')\n page.ele('loc').txt(item.loc)\n page.ele('lastmod').txt(item.lastmod)\n\n if (item.priority !== undefined) {\n page.ele('priority').txt(item.priority.toString())\n }\n if (item.changefreq) {\n page.ele('changefreq').txt(item.changefreq)\n }\n\n // Add alternate references\n if (item.alternateRefs?.length) {\n for (const ref of item.alternateRefs) {\n const alternateRef = page.ele('xhtml:link')\n alternateRef.att('rel', 'alternate')\n alternateRef.att('href', ref.href)\n if (ref.hreflang) {\n alternateRef.att('hreflang', ref.hreflang)\n }\n }\n }\n\n // Add images\n if (item.images?.length) {\n for (const image of item.images) {\n const imageElement = page.ele('image:image')\n imageElement.ele('image:loc').txt(image.loc)\n if (image.title) {\n imageElement.ele('image:title').txt(image.title)\n }\n if (image.caption) {\n imageElement.ele('image:caption').txt(image.caption)\n }\n }\n }\n\n // Add news\n if (item.news) {\n const newsElement = page.ele('news:news')\n const publication = newsElement.ele('news:publication')\n publication.ele('news:name').txt(item.news.publication.name)\n publication.ele('news:language').txt(item.news.publication.language)\n newsElement\n .ele('news:publication_date')\n .txt(new Date(item.news.publicationDate).toISOString().split('T')[0]!)\n newsElement.ele('news:title').txt(item.news.title)\n }\n }\n\n return sitemap.end({ prettyPrint: true })\n}\n\nexport function buildSitemap({\n options,\n publicDir,\n}: {\n options: TanStackStartOutputConfig\n publicDir: string\n}) {\n const logger = createLogger('sitemap')\n\n let sitemapOptions = options.sitemap\n\n if (!sitemapOptions && options.pages.length) {\n sitemapOptions = { enabled: true, outputPath: 'sitemap.xml' }\n }\n\n if (!sitemapOptions?.enabled) {\n throw new Error('Sitemap is not enabled')\n }\n\n const { host, outputPath } = sitemapOptions\n\n if (!host) {\n if (!options.sitemap) {\n logger.info(\n 'Hint: Pages found, but no sitemap host has been set. To enable sitemap generation, set the `sitemap.host` option.',\n )\n return\n }\n throw new Error(\n 'Sitemap host is not set and required to build the sitemap.',\n )\n }\n\n if (!outputPath) {\n throw new Error('Sitemap output path is not set')\n }\n\n const { pages } = options\n\n if (!pages.length) {\n logger.info('No pages were found to build the sitemap. Skipping...')\n return\n }\n\n logger.info('Building Sitemap...')\n\n // Build the sitemap data\n const sitemapData = buildSitemapJson(pages, host)\n\n // Generate output paths\n const xmlOutputPath = path.join(publicDir, outputPath)\n const pagesOutputPath = path.join(publicDir, 'pages.json')\n\n try {\n // Write XML sitemap\n logger.info(`Writing sitemap XML at ${xmlOutputPath}`)\n writeFileSync(xmlOutputPath, jsonToXml(sitemapData))\n\n // Write pages data for runtime use\n logger.info(`Writing pages data at ${pagesOutputPath}`)\n writeFileSync(\n pagesOutputPath,\n JSON.stringify(\n {\n pages,\n host,\n lastBuilt: new Date().toISOString(),\n },\n null,\n 2,\n ),\n )\n } catch (e) {\n logger.error(`Unable to write sitemap files`, e)\n }\n}\n\nfunction createXml(elementName: 'urlset' | 'sitemapindex'): XMLBuilder {\n return create({ version: '1.0', encoding: 'UTF-8' })\n .ele(elementName, {\n xmlns: 'https://www.sitemaps.org/schemas/sitemap/0.9',\n })\n .com(`This file was automatically generated by TanStack Start.`)\n}\n\nfunction checkSlash(host: string): string {\n const finalChar = host.slice(-1)\n return finalChar === '/' ? '' : '/'\n}\n"],"names":["createLogger","writeFileSync","create"],"mappings":";;;;;;AA0CA,SAAS,iBACP,OACA,MACa;AACP,QAAA,QAAQ,WAAW,IAAI;AAE7B,QAAM,OAA0B,MAC7B,OAAO,CAAC,SAAS;;AACT,aAAA,UAAK,YAAL,mBAAc,aAAY;AAAA,EAAA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,QACL;AAAA,MACF;AACA;AAAA,IAAA;AAEF,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAGF,MAAI,CAAC,YAAY;AACT,UAAA,IAAI,MAAM,gCAAgC;AAAA,EAAA;AAG5C,QAAA,EAAE,UAAU;AAEd,MAAA,CAAC,MAAM,QAAQ;AACjB,WAAO,KAAK,uDAAuD;AACnE;AAAA,EAAA;AAGF,SAAO,KAAK,qBAAqB;AAG3B,QAAA,cAAc,iBAAiB,OAAO,IAAI;AAGhD,QAAM,gBAAgB,KAAK,KAAK,WAAW,UAAU;AACrD,QAAM,kBAAkB,KAAK,KAAK,WAAW,YAAY;AAErD,MAAA;AAEK,WAAA,KAAK,0BAA0B,aAAa,EAAE;AACvCC,OAAAA,cAAA,eAAe,UAAU,WAAW,CAAC;AAG5C,WAAA,KAAK,yBAAyB,eAAe,EAAE;AACtDA,OAAA;AAAA,MACE;AAAA,MACA,KAAK;AAAA,QACH;AAAA,UACE;AAAA,UACA;AAAA,UACA,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,QACpC;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAEJ;AAAA,WACO,GAAG;AACH,WAAA,MAAM,iCAAiC,CAAC;AAAA,EAAA;AAEnD;AAEA,SAAS,UAAU,aAAoD;AAC9D,SAAAC,YAAA,OAAO,EAAE,SAAS,OAAO,UAAU,QAAS,CAAA,EAChD,IAAI,aAAa;AAAA,IAChB,OAAO;AAAA,EAAA,CACR,EACA,IAAI,0DAA0D;AACnE;AAEA,SAAS,WAAW,MAAsB;AAClC,QAAA,YAAY,KAAK,MAAM,EAAE;AACxB,SAAA,cAAc,MAAM,KAAK;AAClC;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TanStackStartOutputConfig } from './plugin.cjs';
|
|
2
|
+
export type SitemapUrl = {
|
|
3
|
+
loc: string;
|
|
4
|
+
lastmod: string;
|
|
5
|
+
priority?: number;
|
|
6
|
+
changefreq?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
7
|
+
alternateRefs?: Array<{
|
|
8
|
+
href: string;
|
|
9
|
+
hreflang?: string;
|
|
10
|
+
}>;
|
|
11
|
+
images?: Array<{
|
|
12
|
+
loc: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
caption?: string;
|
|
15
|
+
}>;
|
|
16
|
+
news?: {
|
|
17
|
+
publication: {
|
|
18
|
+
name: string;
|
|
19
|
+
language: string;
|
|
20
|
+
};
|
|
21
|
+
publicationDate: string | Date;
|
|
22
|
+
title: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type SitemapData = {
|
|
26
|
+
urls: Array<SitemapUrl>;
|
|
27
|
+
};
|
|
28
|
+
export declare function buildSitemap({ options, publicDir, }: {
|
|
29
|
+
options: TanStackStartOutputConfig;
|
|
30
|
+
publicDir: string;
|
|
31
|
+
}): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const VITE_ENVIRONMENT_NAMES = {
|
|
4
|
+
// 'ssr' is chosen as the name for the server environment to ensure backwards compatibility
|
|
5
|
+
// with vite plugins that are not compatible with the new vite environment API (e.g. tailwindcss)
|
|
6
|
+
server: "ssr",
|
|
7
|
+
client: "client"
|
|
8
|
+
};
|
|
9
|
+
exports.VITE_ENVIRONMENT_NAMES = VITE_ENVIRONMENT_NAMES;
|
|
10
|
+
//# sourceMappingURL=constants.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs","sources":["../../src/constants.ts"],"sourcesContent":["export const VITE_ENVIRONMENT_NAMES = {\n // 'ssr' is chosen as the name for the server environment to ensure backwards compatibility\n // with vite plugins that are not compatible with the new vite environment API (e.g. tailwindcss)\n server: 'ssr',\n client: 'client',\n} as const\n"],"names":[],"mappings":";;AAAO,MAAM,yBAAyB;AAAA;AAAA;AAAA,EAGpC,QAAQ;AAAA,EACR,QAAQ;AACV;;"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const compilers = require("./compilers.cjs");
|
|
4
|
-
const buildSitemap = require("./nitro/build-sitemap.cjs");
|
|
5
3
|
const schema = require("./schema.cjs");
|
|
6
4
|
const plugin = require("./plugin.cjs");
|
|
7
|
-
const
|
|
8
|
-
exports.compileStartOutputFactory = compilers.compileStartOutputFactory;
|
|
9
|
-
exports.buildSitemap = buildSitemap.buildSitemap;
|
|
5
|
+
const utils = require("./utils.cjs");
|
|
10
6
|
exports.createTanStackConfig = schema.createTanStackConfig;
|
|
11
7
|
exports.createTanStackStartOptionsSchema = schema.createTanStackStartOptionsSchema;
|
|
12
8
|
exports.pageSchema = schema.pageSchema;
|
|
13
9
|
exports.TanStackStartVitePluginCore = plugin.TanStackStartVitePluginCore;
|
|
14
|
-
exports.
|
|
10
|
+
exports.resolveViteId = utils.resolveViteId;
|
|
15
11
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
export type { CompileOptions, IdentifierConfig } from './compilers.cjs';
|
|
2
|
-
export { compileStartOutputFactory } from './compilers.cjs';
|
|
3
|
-
export type { PagesJson } from './nitro/build-sitemap.cjs';
|
|
4
|
-
export { buildSitemap } from './nitro/build-sitemap.cjs';
|
|
5
1
|
export { createTanStackConfig, createTanStackStartOptionsSchema, pageSchema, } from './schema.cjs';
|
|
6
2
|
export { TanStackStartVitePluginCore } from './plugin.cjs';
|
|
7
|
-
export {
|
|
3
|
+
export { resolveViteId } from './utils.cjs';
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const h3 = require("h3");
|
|
4
4
|
const vite = require("vite");
|
|
5
5
|
const extractHtmlScripts = require("../extractHtmlScripts.cjs");
|
|
6
|
+
const constants = require("../constants.cjs");
|
|
6
7
|
function devServerPlugin() {
|
|
7
8
|
let isTest = false;
|
|
8
9
|
return {
|
|
@@ -21,10 +22,17 @@ function devServerPlugin() {
|
|
|
21
22
|
viteDevServer.middlewares.use(async (req, res) => {
|
|
22
23
|
var _a;
|
|
23
24
|
const event = h3.createEvent(req, res);
|
|
24
|
-
const serverEnv = viteDevServer.environments[
|
|
25
|
+
const serverEnv = viteDevServer.environments[constants.VITE_ENVIRONMENT_NAMES.server];
|
|
25
26
|
try {
|
|
26
|
-
if (!serverEnv
|
|
27
|
-
throw new Error(
|
|
27
|
+
if (!serverEnv) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Server environment ${constants.VITE_ENVIRONMENT_NAMES.server} not found`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
if (!vite.isRunnableDevEnvironment(serverEnv)) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`Expected server environment ${constants.VITE_ENVIRONMENT_NAMES.server} to be a RunnableDevEnvironment. This can be caused by multiple vite versions being installed in the project.`
|
|
35
|
+
);
|
|
28
36
|
}
|
|
29
37
|
if (cachedScripts === void 0) {
|
|
30
38
|
const templateHtml = `<html><head></head><body></body></html>`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server-plugin.cjs","sources":["../../../src/nitro/dev-server-plugin.ts"],"sourcesContent":["import { createEvent, getHeader, sendWebResponse } from 'h3'\nimport { isRunnableDevEnvironment } from 'vite'\nimport { extractHtmlScripts } from '../extractHtmlScripts'\nimport type { Connect, Plugin, ViteDevServer } from 'vite'\n\ndeclare global {\n // eslint-disable-next-line no-var\n var TSS_INJECTED_HEAD_SCRIPTS: string | undefined\n}\n\nexport function devServerPlugin(): Plugin {\n // let config: UserConfig\n let isTest = false\n\n return {\n name: 'start-dev-ssr-plugin',\n config(userConfig, { mode }) {\n // config = userConfig\n isTest = isTest ? isTest : mode === 'test'\n },\n configureServer(viteDevServer) {\n if (isTest) {\n return\n }\n\n ;(globalThis as any).viteDevServer = viteDevServer\n\n return () => {\n remove_html_middlewares(viteDevServer.middlewares)\n let cachedScripts: string | undefined\n viteDevServer.middlewares.use(async (req, res) => {\n const event = createEvent(req, res)\n const serverEnv = viteDevServer.environments[
|
|
1
|
+
{"version":3,"file":"dev-server-plugin.cjs","sources":["../../../src/nitro/dev-server-plugin.ts"],"sourcesContent":["import { createEvent, getHeader, sendWebResponse } from 'h3'\nimport { isRunnableDevEnvironment } from 'vite'\nimport { extractHtmlScripts } from '../extractHtmlScripts'\nimport { VITE_ENVIRONMENT_NAMES } from '../constants'\nimport type { Connect, DevEnvironment, Plugin, ViteDevServer } from 'vite'\n\ndeclare global {\n // eslint-disable-next-line no-var\n var TSS_INJECTED_HEAD_SCRIPTS: string | undefined\n}\n\nexport function devServerPlugin(): Plugin {\n // let config: UserConfig\n let isTest = false\n\n return {\n name: 'start-dev-ssr-plugin',\n config(userConfig, { mode }) {\n // config = userConfig\n isTest = isTest ? isTest : mode === 'test'\n },\n configureServer(viteDevServer) {\n if (isTest) {\n return\n }\n\n ;(globalThis as any).viteDevServer = viteDevServer\n\n return () => {\n remove_html_middlewares(viteDevServer.middlewares)\n let cachedScripts: string | undefined\n viteDevServer.middlewares.use(async (req, res) => {\n const event = createEvent(req, res)\n const serverEnv = viteDevServer.environments[\n VITE_ENVIRONMENT_NAMES.server\n ] as DevEnvironment | undefined\n\n try {\n if (!serverEnv) {\n throw new Error(\n `Server environment ${VITE_ENVIRONMENT_NAMES.server} not found`,\n )\n }\n if (!isRunnableDevEnvironment(serverEnv)) {\n throw new Error(\n `Expected server environment ${VITE_ENVIRONMENT_NAMES.server} to be a RunnableDevEnvironment. This can be caused by multiple vite versions being installed in the project.`,\n )\n }\n if (cachedScripts === undefined) {\n const templateHtml = `<html><head></head><body></body></html>`\n const transformedHtml = await viteDevServer.transformIndexHtml(\n req.url || '/',\n templateHtml,\n )\n const scripts = extractHtmlScripts(transformedHtml)\n globalThis.TSS_INJECTED_HEAD_SCRIPTS = scripts\n .map((script) => script.content ?? '')\n .join(';')\n }\n const serverEntry = await serverEnv.runner.import(\n '/~start/server-entry',\n )\n const response = await serverEntry['default'](event)\n\n return sendWebResponse(event, response)\n } catch (e) {\n console.error(e)\n viteDevServer.ssrFixStacktrace(e as Error)\n\n if (\n getHeader(event, 'content-type')?.includes('application/json')\n ) {\n return sendWebResponse(\n event,\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 sendWebResponse(\n event,\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\n/**\n * Removes Vite internal middleware\n *\n * @param server\n */\nfunction remove_html_middlewares(server: ViteDevServer['middlewares']) {\n const html_middlewares = [\n 'viteIndexHtmlMiddleware',\n 'vite404Middleware',\n 'viteSpaFallbackMiddleware',\n ]\n for (let i = server.stack.length - 1; i > 0; i--) {\n if (\n html_middlewares.includes(\n // @ts-expect-error\n server.stack[i].handle.name,\n )\n ) {\n server.stack.splice(i, 1)\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 occured 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":["createEvent","VITE_ENVIRONMENT_NAMES","isRunnableDevEnvironment","extractHtmlScripts","sendWebResponse","getHeader"],"mappings":";;;;;;AAWO,SAAS,kBAA0B;AAExC,MAAI,SAAS;AAEN,SAAA;AAAA,IACL,MAAM;AAAA,IACN,OAAO,YAAY,EAAE,QAAQ;AAElB,eAAA,SAAS,SAAS,SAAS;AAAA,IACtC;AAAA,IACA,gBAAgB,eAAe;AAC7B,UAAI,QAAQ;AACV;AAAA,MAAA;AAGA,iBAAmB,gBAAgB;AAErC,aAAO,MAAM;AACX,gCAAwB,cAAc,WAAW;AAC7C,YAAA;AACJ,sBAAc,YAAY,IAAI,OAAO,KAAK,QAAQ;;AAC1C,gBAAA,QAAQA,GAAAA,YAAY,KAAK,GAAG;AAClC,gBAAM,YAAY,cAAc,aAC9BC,UAAAA,uBAAuB,MACzB;AAEI,cAAA;AACF,gBAAI,CAAC,WAAW;AACd,oBAAM,IAAI;AAAA,gBACR,sBAAsBA,iCAAuB,MAAM;AAAA,cACrD;AAAA,YAAA;AAEE,gBAAA,CAACC,KAAAA,yBAAyB,SAAS,GAAG;AACxC,oBAAM,IAAI;AAAA,gBACR,+BAA+BD,iCAAuB,MAAM;AAAA,cAC9D;AAAA,YAAA;AAEF,gBAAI,kBAAkB,QAAW;AAC/B,oBAAM,eAAe;AACf,oBAAA,kBAAkB,MAAM,cAAc;AAAA,gBAC1C,IAAI,OAAO;AAAA,gBACX;AAAA,cACF;AACM,oBAAA,UAAUE,sCAAmB,eAAe;AACvC,yBAAA,4BAA4B,QACpC,IAAI,CAAC,WAAW,OAA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I,OAAO,MAAM,SAAS,GAAG,IAAI,GAAG,KAAK;AAChD,QACE,iBAAiB;AAAA;AAAA,MAEf,OAAO,MAAM,CAAC,EAAE,OAAO;AAAA,IAAA,GAEzB;AACO,aAAA,MAAM,OAAO,GAAG,CAAC;AAAA,IAAA;AAAA,EAC1B;AAEJ;AAQA,SAAS,aAAa,KAA8B,OAAgB;AAClE,QAAM,IAAI;AACH,SAAA;AAAA,IACL,SAAS,2CAA2C,IAAI,GAAG;AAAA;AAAA,GACzD,OAAO,MAAM,WAAW,IAAI,EAAE,OAChC;AAAA,IACA,OAAO,OAAO,MAAM,WAAW,KAAK,EAAE;AAAA,EACxC;AACF;;"}
|
|
@@ -2,12 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const path = require("node:path");
|
|
4
4
|
const fs = require("node:fs");
|
|
5
|
+
const fsp = require("node:fs/promises");
|
|
5
6
|
const nitropack = require("nitropack");
|
|
6
7
|
const pathe = require("pathe");
|
|
7
8
|
const plugin = require("../plugin.cjs");
|
|
8
9
|
const prerender = require("../prerender.cjs");
|
|
10
|
+
const constants = require("../constants.cjs");
|
|
11
|
+
const buildSitemap = require("../build-sitemap.cjs");
|
|
9
12
|
const devServerPlugin = require("./dev-server-plugin.cjs");
|
|
10
|
-
|
|
13
|
+
function _interopNamespaceDefault(e) {
|
|
14
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
15
|
+
if (e) {
|
|
16
|
+
for (const k in e) {
|
|
17
|
+
if (k !== "default") {
|
|
18
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: () => e[k]
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
n.default = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
const fsp__namespace = /* @__PURE__ */ _interopNamespaceDefault(fsp);
|
|
11
30
|
function nitroPlugin(options, getSsrBundle) {
|
|
12
31
|
const buildPreset = process.env["START_TARGET"] ?? options.target;
|
|
13
32
|
return [
|
|
@@ -15,7 +34,7 @@ function nitroPlugin(options, getSsrBundle) {
|
|
|
15
34
|
{
|
|
16
35
|
name: "tanstack-vite-plugin-nitro",
|
|
17
36
|
configEnvironment(name) {
|
|
18
|
-
if (name ===
|
|
37
|
+
if (name === constants.VITE_ENVIRONMENT_NAMES.server) {
|
|
19
38
|
return {
|
|
20
39
|
build: {
|
|
21
40
|
commonjsOptions: {
|
|
@@ -36,9 +55,8 @@ function nitroPlugin(options, getSsrBundle) {
|
|
|
36
55
|
builder: {
|
|
37
56
|
sharedPlugins: true,
|
|
38
57
|
async buildApp(builder) {
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
const serverEnv = builder.environments["server"];
|
|
58
|
+
const clientEnv = builder.environments[constants.VITE_ENVIRONMENT_NAMES.client];
|
|
59
|
+
const serverEnv = builder.environments[constants.VITE_ENVIRONMENT_NAMES.server];
|
|
42
60
|
if (!clientEnv) {
|
|
43
61
|
throw new Error("Client environment not found");
|
|
44
62
|
}
|
|
@@ -70,14 +88,7 @@ function nitroPlugin(options, getSsrBundle) {
|
|
|
70
88
|
}
|
|
71
89
|
};
|
|
72
90
|
const nitro = await nitropack.createNitro(nitroConfig);
|
|
73
|
-
await
|
|
74
|
-
if ((_a = options.prerender) == null ? void 0 : _a.enabled) {
|
|
75
|
-
await prerender.prerender({
|
|
76
|
-
options,
|
|
77
|
-
nitro,
|
|
78
|
-
builder
|
|
79
|
-
});
|
|
80
|
-
}
|
|
91
|
+
await buildNitroApp(builder, nitro, options);
|
|
81
92
|
}
|
|
82
93
|
}
|
|
83
94
|
};
|
|
@@ -85,6 +96,60 @@ function nitroPlugin(options, getSsrBundle) {
|
|
|
85
96
|
}
|
|
86
97
|
];
|
|
87
98
|
}
|
|
99
|
+
async function buildNitroApp(builder, nitro, options) {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
await nitropack.prepare(nitro);
|
|
102
|
+
await nitropack.copyPublicAssets(nitro);
|
|
103
|
+
if (((_a = options.prerender) == null ? void 0 : _a.enabled) !== false) {
|
|
104
|
+
options.prerender = {
|
|
105
|
+
...options.prerender,
|
|
106
|
+
enabled: options.pages.some(
|
|
107
|
+
(d) => {
|
|
108
|
+
var _a2;
|
|
109
|
+
return typeof d === "string" ? false : !!((_a2 = d.prerender) == null ? void 0 : _a2.enabled);
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if ((_b = options.spa) == null ? void 0 : _b.enabled) {
|
|
115
|
+
options.prerender = {
|
|
116
|
+
...options.prerender,
|
|
117
|
+
enabled: true
|
|
118
|
+
};
|
|
119
|
+
const maskUrl = new URL(options.spa.maskPath, "http://localhost");
|
|
120
|
+
maskUrl.searchParams.set("__TSS_SHELL", "true");
|
|
121
|
+
options.pages.push({
|
|
122
|
+
path: maskUrl.toString().replace("http://localhost", ""),
|
|
123
|
+
prerender: options.spa.prerender,
|
|
124
|
+
sitemap: {
|
|
125
|
+
exclude: true
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (options.prerender.enabled) {
|
|
130
|
+
await prerender.prerender({
|
|
131
|
+
options,
|
|
132
|
+
nitro,
|
|
133
|
+
builder
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
if (options.pages.length) {
|
|
137
|
+
buildSitemap.buildSitemap({
|
|
138
|
+
options,
|
|
139
|
+
publicDir: nitro.options.output.publicDir
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
await nitropack.build(nitro);
|
|
143
|
+
const nitroPublicDir = nitro.options.output.publicDir;
|
|
144
|
+
const viteDir = path.resolve(nitroPublicDir, ".vite");
|
|
145
|
+
if (await fsp__namespace.stat(viteDir).catch(() => false)) {
|
|
146
|
+
await fsp__namespace.rm(viteDir, { recursive: true, force: true });
|
|
147
|
+
}
|
|
148
|
+
await nitro.close();
|
|
149
|
+
nitro.logger.success(
|
|
150
|
+
"Client and Server bundles for TanStack Start have been successfully built."
|
|
151
|
+
);
|
|
152
|
+
}
|
|
88
153
|
function virtualBundlePlugin(ssrBundle) {
|
|
89
154
|
const _modules = /* @__PURE__ */ new Map();
|
|
90
155
|
for (const [fileName, content] of Object.entries(ssrBundle)) {
|
|
@@ -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 { 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 === '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 = builder.environments['client']\n const serverEnv = builder.environments['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.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":["devServerPl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,QAAA;AAAA,MACT;AAEK,aAAA;AAAA,IACT;AAAA,IACA,KAAK,IAAI;AACD,YAAA,IAAI,SAAS,IAAI,EAAE;AACzB,UAAI,CAAC,GAAG;AACC,eAAA;AAAA,MAAA;AAEF,aAAA;AAAA,IAAA;AAAA,EAEX;AACF;;"}
|
|
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 * as fsp from 'node:fs/promises'\nimport { build, copyPublicAssets, createNitro, prepare } from 'nitropack'\nimport { dirname, resolve } from 'pathe'\nimport { clientDistDir, ssrEntryFile } from '../plugin'\nimport { prerender } from '../prerender'\nimport { VITE_ENVIRONMENT_NAMES } from '../constants'\nimport { buildSitemap } from '../build-sitemap'\nimport { devServerPlugin } from './dev-server-plugin'\nimport type {\n EnvironmentOptions,\n PluginOption,\n Rollup,\n ViteBuilder,\n} from 'vite'\nimport type { Nitro, 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 buildNitroApp(builder, nitro, options)\n },\n },\n }\n },\n },\n ]\n}\n\n/**\n * Correctly co-ordinates the nitro app build process to make sure that the\n * app is built, while also correctly handling the prerendering and sitemap\n * generation and including their outputs in the final build.\n */\nasync function buildNitroApp(\n builder: ViteBuilder,\n nitro: Nitro,\n options: TanStackStartOutputConfig,\n) {\n // Cleans the public and server directories for a fresh build\n // i.e the `.output/public` and `.output/server` directories\n await prepare(nitro)\n\n // Creates the `.output/public` directory and copies the public assets\n await copyPublicAssets(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(options.spa.maskPath, 'http://localhost')\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 // Run the prerendering process\n if (options.prerender.enabled) {\n await prerender({\n options,\n nitro,\n builder,\n })\n }\n\n // Run the sitemap build process\n if (options.pages.length) {\n buildSitemap({\n options,\n publicDir: nitro.options.output.publicDir,\n })\n }\n\n // Build the nitro app\n await build(nitro)\n\n // Cleanup the vite public directory\n // As a part of the build process, a `.vite/` directory\n // is copied over from `.tanstack-start/build/client-dist/`\n // to the nitro `publicDir` (e.g. `.output/public/`).\n // This directory (and its contents including the vite client manifest)\n // should not be included in the final build, so we remove it.\n const nitroPublicDir = nitro.options.output.publicDir\n const viteDir = path.resolve(nitroPublicDir, '.vite')\n if (await fsp.stat(viteDir).catch(() => false)) {\n await fsp.rm(viteDir, { recursive: true, force: true })\n }\n\n // Close the nitro instance\n await nitro.close()\n nitro.logger.success(\n 'Client and Server bundles for TanStack Start have been successfully built.',\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","prepare","copyPublicAssets","_a","prerender","buildSitemap","build","fsp","dirname"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBgB,SAAA,YACd,SACA,cACqB;AACrB,QAAM,cACJ,QAAQ,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