@tanstack/start-plugin-core 1.166.12 → 1.166.13

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 (87) hide show
  1. package/dist/esm/build-sitemap.js +94 -123
  2. package/dist/esm/build-sitemap.js.map +1 -1
  3. package/dist/esm/constants.js +15 -20
  4. package/dist/esm/constants.js.map +1 -1
  5. package/dist/esm/dev-server-plugin/dev-styles.js +137 -150
  6. package/dist/esm/dev-server-plugin/dev-styles.js.map +1 -1
  7. package/dist/esm/dev-server-plugin/extract-html-scripts.js +16 -15
  8. package/dist/esm/dev-server-plugin/extract-html-scripts.js.map +1 -1
  9. package/dist/esm/dev-server-plugin/plugin.js +125 -195
  10. package/dist/esm/dev-server-plugin/plugin.js.map +1 -1
  11. package/dist/esm/import-protection-plugin/ast.js +6 -5
  12. package/dist/esm/import-protection-plugin/ast.js.map +1 -1
  13. package/dist/esm/import-protection-plugin/constants.js +20 -22
  14. package/dist/esm/import-protection-plugin/constants.js.map +1 -1
  15. package/dist/esm/import-protection-plugin/defaults.js +35 -25
  16. package/dist/esm/import-protection-plugin/defaults.js.map +1 -1
  17. package/dist/esm/import-protection-plugin/extensionlessAbsoluteIdResolver.js +93 -92
  18. package/dist/esm/import-protection-plugin/extensionlessAbsoluteIdResolver.js.map +1 -1
  19. package/dist/esm/import-protection-plugin/matchers.js +23 -24
  20. package/dist/esm/import-protection-plugin/matchers.js.map +1 -1
  21. package/dist/esm/import-protection-plugin/plugin.js +1045 -1361
  22. package/dist/esm/import-protection-plugin/plugin.js.map +1 -1
  23. package/dist/esm/import-protection-plugin/postCompileUsage.js +58 -55
  24. package/dist/esm/import-protection-plugin/postCompileUsage.js.map +1 -1
  25. package/dist/esm/import-protection-plugin/rewriteDeniedImports.js +187 -259
  26. package/dist/esm/import-protection-plugin/rewriteDeniedImports.js.map +1 -1
  27. package/dist/esm/import-protection-plugin/sourceLocation.js +238 -248
  28. package/dist/esm/import-protection-plugin/sourceLocation.js.map +1 -1
  29. package/dist/esm/import-protection-plugin/trace.js +173 -184
  30. package/dist/esm/import-protection-plugin/trace.js.map +1 -1
  31. package/dist/esm/import-protection-plugin/utils.js +132 -111
  32. package/dist/esm/import-protection-plugin/utils.js.map +1 -1
  33. package/dist/esm/import-protection-plugin/virtualModules.js +216 -196
  34. package/dist/esm/import-protection-plugin/virtualModules.js.map +1 -1
  35. package/dist/esm/index.js +2 -7
  36. package/dist/esm/load-env-plugin/plugin.js +12 -11
  37. package/dist/esm/load-env-plugin/plugin.js.map +1 -1
  38. package/dist/esm/output-directory.js +10 -10
  39. package/dist/esm/output-directory.js.map +1 -1
  40. package/dist/esm/plugin.js +275 -355
  41. package/dist/esm/plugin.js.map +1 -1
  42. package/dist/esm/post-server-build.js +39 -53
  43. package/dist/esm/post-server-build.js.map +1 -1
  44. package/dist/esm/prerender.js +177 -239
  45. package/dist/esm/prerender.js.map +1 -1
  46. package/dist/esm/preview-server-plugin/plugin.js +41 -44
  47. package/dist/esm/preview-server-plugin/plugin.js.map +1 -1
  48. package/dist/esm/queue.js +115 -126
  49. package/dist/esm/queue.js.map +1 -1
  50. package/dist/esm/resolve-entries.js +31 -32
  51. package/dist/esm/resolve-entries.js.map +1 -1
  52. package/dist/esm/schema.js +156 -179
  53. package/dist/esm/schema.js.map +1 -1
  54. package/dist/esm/start-compiler-plugin/compiler.js +655 -812
  55. package/dist/esm/start-compiler-plugin/compiler.js.map +1 -1
  56. package/dist/esm/start-compiler-plugin/handleClientOnlyJSX.js +25 -8
  57. package/dist/esm/start-compiler-plugin/handleClientOnlyJSX.js.map +1 -1
  58. package/dist/esm/start-compiler-plugin/handleCreateIsomorphicFn.js +22 -19
  59. package/dist/esm/start-compiler-plugin/handleCreateIsomorphicFn.js.map +1 -1
  60. package/dist/esm/start-compiler-plugin/handleCreateMiddleware.js +20 -22
  61. package/dist/esm/start-compiler-plugin/handleCreateMiddleware.js.map +1 -1
  62. package/dist/esm/start-compiler-plugin/handleCreateServerFn.js +187 -255
  63. package/dist/esm/start-compiler-plugin/handleCreateServerFn.js.map +1 -1
  64. package/dist/esm/start-compiler-plugin/handleEnvOnly.js +23 -33
  65. package/dist/esm/start-compiler-plugin/handleEnvOnly.js.map +1 -1
  66. package/dist/esm/start-compiler-plugin/plugin.js +247 -291
  67. package/dist/esm/start-compiler-plugin/plugin.js.map +1 -1
  68. package/dist/esm/start-compiler-plugin/utils.js +27 -27
  69. package/dist/esm/start-compiler-plugin/utils.js.map +1 -1
  70. package/dist/esm/start-manifest-plugin/manifestBuilder.js +272 -378
  71. package/dist/esm/start-manifest-plugin/manifestBuilder.js.map +1 -1
  72. package/dist/esm/start-manifest-plugin/plugin.js +35 -44
  73. package/dist/esm/start-manifest-plugin/plugin.js.map +1 -1
  74. package/dist/esm/start-router-plugin/constants.js +6 -5
  75. package/dist/esm/start-router-plugin/constants.js.map +1 -1
  76. package/dist/esm/start-router-plugin/generator-plugins/prerender-routes-plugin.js +24 -19
  77. package/dist/esm/start-router-plugin/generator-plugins/prerender-routes-plugin.js.map +1 -1
  78. package/dist/esm/start-router-plugin/generator-plugins/routes-manifest-plugin.js +28 -29
  79. package/dist/esm/start-router-plugin/generator-plugins/routes-manifest-plugin.js.map +1 -1
  80. package/dist/esm/start-router-plugin/plugin.js +146 -199
  81. package/dist/esm/start-router-plugin/plugin.js.map +1 -1
  82. package/dist/esm/start-router-plugin/pruneServerOnlySubtrees.js +32 -31
  83. package/dist/esm/start-router-plugin/pruneServerOnlySubtrees.js.map +1 -1
  84. package/dist/esm/utils.js +14 -14
  85. package/dist/esm/utils.js.map +1 -1
  86. package/package.json +7 -7
  87. package/dist/esm/index.js.map +0 -1
@@ -1,134 +1,105 @@
1
- import { writeFileSync } from "node:fs";
1
+ import { createLogger } from "./utils.js";
2
2
  import path from "node:path";
3
+ import { writeFileSync } from "node:fs";
3
4
  import { create } from "xmlbuilder2";
4
- import { createLogger } from "./utils.js";
5
+ //#region src/build-sitemap.ts
5
6
  function buildSitemapJson(pages, host) {
6
- const slash = checkSlash(host);
7
- const urls = pages.filter((page) => {
8
- return page.sitemap?.exclude !== true;
9
- }).map((page) => ({
10
- loc: `${host}${slash}${page.path.replace(/^\/+/g, "")}`,
11
- lastmod: page.sitemap?.lastmod ? new Date(page.sitemap.lastmod).toISOString().split("T")[0] : (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
12
- priority: page.sitemap?.priority,
13
- changefreq: page.sitemap?.changefreq,
14
- alternateRefs: page.sitemap?.alternateRefs,
15
- images: page.sitemap?.images,
16
- news: page.sitemap?.news
17
- }));
18
- return { urls };
7
+ const slash = checkSlash(host);
8
+ return { urls: pages.filter((page) => {
9
+ return page.sitemap?.exclude !== true;
10
+ }).map((page) => ({
11
+ loc: `${host}${slash}${page.path.replace(/^\/+/g, "")}`,
12
+ lastmod: page.sitemap?.lastmod ? new Date(page.sitemap.lastmod).toISOString().split("T")[0] : (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
13
+ priority: page.sitemap?.priority,
14
+ changefreq: page.sitemap?.changefreq,
15
+ alternateRefs: page.sitemap?.alternateRefs,
16
+ images: page.sitemap?.images,
17
+ news: page.sitemap?.news
18
+ })) };
19
19
  }
20
20
  function jsonToXml(sitemapData) {
21
- const sitemap = createXml("urlset");
22
- for (const item of sitemapData.urls) {
23
- const page = sitemap.ele("url");
24
- page.ele("loc").txt(item.loc);
25
- page.ele("lastmod").txt(item.lastmod);
26
- if (item.priority !== void 0) {
27
- page.ele("priority").txt(item.priority.toString());
28
- }
29
- if (item.changefreq) {
30
- page.ele("changefreq").txt(item.changefreq);
31
- }
32
- if (item.alternateRefs?.length) {
33
- for (const ref of item.alternateRefs) {
34
- const alternateRef = page.ele("xhtml:link");
35
- alternateRef.att("rel", "alternate");
36
- alternateRef.att("href", ref.href);
37
- if (ref.hreflang) {
38
- alternateRef.att("hreflang", ref.hreflang);
39
- }
40
- }
41
- }
42
- if (item.images?.length) {
43
- for (const image of item.images) {
44
- const imageElement = page.ele("image:image");
45
- imageElement.ele("image:loc").txt(image.loc);
46
- if (image.title) {
47
- imageElement.ele("image:title").txt(image.title);
48
- }
49
- if (image.caption) {
50
- imageElement.ele("image:caption").txt(image.caption);
51
- }
52
- }
53
- }
54
- if (item.news) {
55
- const newsElement = page.ele("news:news");
56
- const publication = newsElement.ele("news:publication");
57
- publication.ele("news:name").txt(item.news.publication.name);
58
- publication.ele("news:language").txt(item.news.publication.language);
59
- newsElement.ele("news:publication_date").txt(new Date(item.news.publicationDate).toISOString().split("T")[0]);
60
- newsElement.ele("news:title").txt(item.news.title);
61
- }
62
- }
63
- return sitemap.end({ prettyPrint: true });
21
+ const sitemap = createXml("urlset");
22
+ for (const item of sitemapData.urls) {
23
+ const page = sitemap.ele("url");
24
+ page.ele("loc").txt(item.loc);
25
+ page.ele("lastmod").txt(item.lastmod);
26
+ if (item.priority !== void 0) page.ele("priority").txt(item.priority.toString());
27
+ if (item.changefreq) page.ele("changefreq").txt(item.changefreq);
28
+ if (item.alternateRefs?.length) for (const ref of item.alternateRefs) {
29
+ const alternateRef = page.ele("xhtml:link");
30
+ alternateRef.att("rel", "alternate");
31
+ alternateRef.att("href", ref.href);
32
+ if (ref.hreflang) alternateRef.att("hreflang", ref.hreflang);
33
+ }
34
+ if (item.images?.length) for (const image of item.images) {
35
+ const imageElement = page.ele("image:image");
36
+ imageElement.ele("image:loc").txt(image.loc);
37
+ if (image.title) imageElement.ele("image:title").txt(image.title);
38
+ if (image.caption) imageElement.ele("image:caption").txt(image.caption);
39
+ }
40
+ if (item.news) {
41
+ const newsElement = page.ele("news:news");
42
+ const publication = newsElement.ele("news:publication");
43
+ publication.ele("news:name").txt(item.news.publication.name);
44
+ publication.ele("news:language").txt(item.news.publication.language);
45
+ newsElement.ele("news:publication_date").txt(new Date(item.news.publicationDate).toISOString().split("T")[0]);
46
+ newsElement.ele("news:title").txt(item.news.title);
47
+ }
48
+ }
49
+ return sitemap.end({ prettyPrint: true });
64
50
  }
65
- function buildSitemap({
66
- startConfig,
67
- publicDir
68
- }) {
69
- const logger = createLogger("sitemap");
70
- let sitemapOptions = startConfig.sitemap;
71
- if (!sitemapOptions && startConfig.pages.length) {
72
- sitemapOptions = { enabled: true, outputPath: "sitemap.xml" };
73
- }
74
- if (!sitemapOptions?.enabled) {
75
- throw new Error("Sitemap is not enabled");
76
- }
77
- const { host, outputPath } = sitemapOptions;
78
- if (!host) {
79
- if (!startConfig.sitemap) {
80
- logger.info(
81
- "Hint: Pages found, but no sitemap host has been set. To enable sitemap generation, set the `sitemap.host` option."
82
- );
83
- return;
84
- }
85
- throw new Error(
86
- "Sitemap host is not set and required to build the sitemap."
87
- );
88
- }
89
- if (!outputPath) {
90
- throw new Error("Sitemap output path is not set");
91
- }
92
- const { pages } = startConfig;
93
- if (!pages.length) {
94
- logger.info("No pages were found to build the sitemap. Skipping...");
95
- return;
96
- }
97
- logger.info("Building Sitemap...");
98
- const sitemapData = buildSitemapJson(pages, host);
99
- const xmlOutputPath = path.join(publicDir, outputPath);
100
- const pagesOutputPath = path.join(publicDir, "pages.json");
101
- try {
102
- logger.info(`Writing sitemap XML at ${xmlOutputPath}`);
103
- writeFileSync(xmlOutputPath, jsonToXml(sitemapData));
104
- logger.info(`Writing pages data at ${pagesOutputPath}`);
105
- writeFileSync(
106
- pagesOutputPath,
107
- JSON.stringify(
108
- {
109
- pages,
110
- host,
111
- lastBuilt: (/* @__PURE__ */ new Date()).toISOString()
112
- },
113
- null,
114
- 2
115
- )
116
- );
117
- } catch (e) {
118
- logger.error(`Unable to write sitemap files`, e);
119
- }
51
+ function buildSitemap({ startConfig, publicDir }) {
52
+ const logger = createLogger("sitemap");
53
+ let sitemapOptions = startConfig.sitemap;
54
+ if (!sitemapOptions && startConfig.pages.length) sitemapOptions = {
55
+ enabled: true,
56
+ outputPath: "sitemap.xml"
57
+ };
58
+ if (!sitemapOptions?.enabled) throw new Error("Sitemap is not enabled");
59
+ const { host, outputPath } = sitemapOptions;
60
+ if (!host) {
61
+ if (!startConfig.sitemap) {
62
+ logger.info("Hint: Pages found, but no sitemap host has been set. To enable sitemap generation, set the `sitemap.host` option.");
63
+ return;
64
+ }
65
+ throw new Error("Sitemap host is not set and required to build the sitemap.");
66
+ }
67
+ if (!outputPath) throw new Error("Sitemap output path is not set");
68
+ const { pages } = startConfig;
69
+ if (!pages.length) {
70
+ logger.info("No pages were found to build the sitemap. Skipping...");
71
+ return;
72
+ }
73
+ logger.info("Building Sitemap...");
74
+ const sitemapData = buildSitemapJson(pages, host);
75
+ const xmlOutputPath = path.join(publicDir, outputPath);
76
+ const pagesOutputPath = path.join(publicDir, "pages.json");
77
+ try {
78
+ logger.info(`Writing sitemap XML at ${xmlOutputPath}`);
79
+ writeFileSync(xmlOutputPath, jsonToXml(sitemapData));
80
+ logger.info(`Writing pages data at ${pagesOutputPath}`);
81
+ writeFileSync(pagesOutputPath, JSON.stringify({
82
+ pages,
83
+ host,
84
+ lastBuilt: (/* @__PURE__ */ new Date()).toISOString()
85
+ }, null, 2));
86
+ } catch (e) {
87
+ logger.error(`Unable to write sitemap files`, e);
88
+ }
120
89
  }
121
90
  function createXml(elementName) {
122
- return create({ version: "1.0", encoding: "UTF-8" }).ele(elementName, {
123
- xmlns: "https://www.sitemaps.org/schemas/sitemap/0.9",
124
- "xmlns:xhtml": "http://www.w3.org/1999/xhtml"
125
- }).com(`This file was automatically generated by TanStack Start.`);
91
+ return create({
92
+ version: "1.0",
93
+ encoding: "UTF-8"
94
+ }).ele(elementName, {
95
+ xmlns: "https://www.sitemaps.org/schemas/sitemap/0.9",
96
+ "xmlns:xhtml": "http://www.w3.org/1999/xhtml"
97
+ }).com(`This file was automatically generated by TanStack Start.`);
126
98
  }
127
99
  function checkSlash(host) {
128
- const finalChar = host.slice(-1);
129
- return finalChar === "/" ? "" : "/";
100
+ return host.slice(-1) === "/" ? "" : "/";
130
101
  }
131
- export {
132
- buildSitemap
133
- };
134
- //# sourceMappingURL=build-sitemap.js.map
102
+ //#endregion
103
+ export { buildSitemap };
104
+
105
+ //# sourceMappingURL=build-sitemap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-sitemap.js","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 './schema'\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 startConfig,\n publicDir,\n}: {\n startConfig: TanStackStartOutputConfig\n publicDir: string\n}) {\n const logger = createLogger('sitemap')\n\n let sitemapOptions = startConfig.sitemap\n\n if (!sitemapOptions && startConfig.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 (!startConfig.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 } = startConfig\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 'xmlns:xhtml': 'http://www.w3.org/1999/xhtml',\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":[],"mappings":";;;;AA0CA,SAAS,iBACP,OACA,MACa;AACb,QAAM,QAAQ,WAAW,IAAI;AAE7B,QAAM,OAA0B,MAC7B,OAAO,CAAC,SAAS;AAChB,WAAO,KAAK,SAAS,YAAY;AAAA,EACnC,CAAC,EACA,IAAI,CAAC,UAAU;AAAA,IACd,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,KAAK,QAAQ,SAAS,EAAE,CAAC;AAAA,IACrD,SAAS,KAAK,SAAS,UACnB,IAAI,KAAK,KAAK,QAAQ,OAAO,EAAE,YAAA,EAAc,MAAM,GAAG,EAAE,CAAC,KACzD,oBAAI,KAAA,GAAO,YAAA,EAAc,MAAM,GAAG,EAAE,CAAC;AAAA,IACzC,UAAU,KAAK,SAAS;AAAA,IACxB,YAAY,KAAK,SAAS;AAAA,IAC1B,eAAe,KAAK,SAAS;AAAA,IAC7B,QAAQ,KAAK,SAAS;AAAA,IACtB,MAAM,KAAK,SAAS;AAAA,EAAA,EACpB;AAEJ,SAAO,EAAE,KA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AAA,QACH;AAAA,UACE;AAAA,UACA;AAAA,UACA,YAAW,oBAAI,KAAA,GAAO,YAAA;AAAA,QAAY;AAAA,QAEpC;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,EAEJ,SAAS,GAAG;AACV,WAAO,MAAM,iCAAiC,CAAC;AAAA,EACjD;AACF;AAEA,SAAS,UAAU,aAAoD;AACrE,SAAO,OAAO,EAAE,SAAS,OAAO,UAAU,QAAA,CAAS,EAChD,IAAI,aAAa;AAAA,IAChB,OAAO;AAAA,IACP,eAAe;AAAA,EAAA,CAChB,EACA,IAAI,0DAA0D;AACnE;AAEA,SAAS,WAAW,MAAsB;AACxC,QAAM,YAAY,KAAK,MAAM,EAAE;AAC/B,SAAO,cAAc,MAAM,KAAK;AAClC;"}
1
+ {"version":3,"file":"build-sitemap.js","names":[],"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 './schema'\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 startConfig,\n publicDir,\n}: {\n startConfig: TanStackStartOutputConfig\n publicDir: string\n}) {\n const logger = createLogger('sitemap')\n\n let sitemapOptions = startConfig.sitemap\n\n if (!sitemapOptions && startConfig.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 (!startConfig.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 } = startConfig\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 'xmlns:xhtml': 'http://www.w3.org/1999/xhtml',\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"],"mappings":";;;;;AA0CA,SAAS,iBACP,OACA,MACa;CACb,MAAM,QAAQ,WAAW,KAAK;AAkB9B,QAAO,EAAE,MAhBuB,MAC7B,QAAQ,SAAS;AAChB,SAAO,KAAK,SAAS,YAAY;GACjC,CACD,KAAK,UAAU;EACd,KAAK,GAAG,OAAO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AAyB,kBAAkB;AACvD,gBACE,iBACA,KAAK,UACH;GACE;GACA;GACA,4BAAW,IAAI,MAAM,EAAC,aAAa;GACpC,EACD,MACA,EACD,CACF;UACM,GAAG;AACV,SAAO,MAAM,iCAAiC,EAAE;;;AAIpD,SAAS,UAAU,aAAoD;AACrE,QAAO,OAAO;EAAE,SAAS;EAAO,UAAU;EAAS,CAAC,CACjD,IAAI,aAAa;EAChB,OAAO;EACP,eAAe;EAChB,CAAC,CACD,IAAI,2DAA2D;;AAGpE,SAAS,WAAW,MAAsB;AAExC,QADkB,KAAK,MAAM,GAAG,KACX,MAAM,KAAK"}
@@ -1,22 +1,17 @@
1
- const VITE_ENVIRONMENT_NAMES = {
2
- // 'ssr' is chosen as the name for the server environment to ensure backwards compatibility
3
- // with vite plugins that are not compatible with the new vite environment API (e.g. tailwindcss)
4
- server: "ssr",
5
- client: "client"
1
+ //#region src/constants.ts
2
+ var VITE_ENVIRONMENT_NAMES = {
3
+ server: "ssr",
4
+ client: "client"
6
5
  };
7
- const ENTRY_POINTS = {
8
- client: "virtual:tanstack-start-client-entry",
9
- server: "virtual:tanstack-start-server-entry",
10
- // the start entry point must always be provided by the user
11
- start: "#tanstack-start-entry",
12
- router: "#tanstack-router-entry"
6
+ var ENTRY_POINTS = {
7
+ client: "virtual:tanstack-start-client-entry",
8
+ server: "virtual:tanstack-start-server-entry",
9
+ start: "#tanstack-start-entry",
10
+ router: "#tanstack-router-entry"
13
11
  };
14
- const SERVER_FN_LOOKUP = "server-fn-module-lookup";
15
- const TRANSFORM_ID_REGEX = [/\.[cm]?[tj]sx?($|\?)/];
16
- export {
17
- ENTRY_POINTS,
18
- SERVER_FN_LOOKUP,
19
- TRANSFORM_ID_REGEX,
20
- VITE_ENVIRONMENT_NAMES
21
- };
22
- //# sourceMappingURL=constants.js.map
12
+ var SERVER_FN_LOOKUP = "server-fn-module-lookup";
13
+ var TRANSFORM_ID_REGEX = [/\.[cm]?[tj]sx?($|\?)/];
14
+ //#endregion
15
+ export { ENTRY_POINTS, SERVER_FN_LOOKUP, TRANSFORM_ID_REGEX, VITE_ENVIRONMENT_NAMES };
16
+
17
+ //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","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\nexport type ViteEnvironmentNames =\n (typeof VITE_ENVIRONMENT_NAMES)[keyof typeof VITE_ENVIRONMENT_NAMES]\n\n// for client and router:\n// if a user has a custom server/client entry point file, resolve.alias will point to this\n// otherwise it will be aliased to the default entry point in the respective framework plugin\nexport const ENTRY_POINTS = {\n client: 'virtual:tanstack-start-client-entry',\n server: 'virtual:tanstack-start-server-entry',\n // the start entry point must always be provided by the user\n start: '#tanstack-start-entry',\n router: '#tanstack-router-entry',\n} as const\n\nexport const SERVER_FN_LOOKUP = 'server-fn-module-lookup'\n\n// matches\n// .ts, .tsx, .cts, .mts, .js, .jsx, .cjs, .mjs\n// with optional query params after\n// but not .json\nexport const TRANSFORM_ID_REGEX = [/\\.[cm]?[tj]sx?($|\\?)/]\n"],"names":[],"mappings":"AAAO,MAAM,yBAAyB;AAAA;AAAA;AAAA,EAGpC,QAAQ;AAAA,EACR,QAAQ;AACV;AAQO,MAAM,eAAe;AAAA,EAC1B,QAAQ;AAAA,EACR,QAAQ;AAAA;AAAA,EAER,OAAO;AAAA,EACP,QAAQ;AACV;AAEO,MAAM,mBAAmB;AAMzB,MAAM,qBAAqB,CAAC,sBAAsB;"}
1
+ {"version":3,"file":"constants.js","names":[],"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\nexport type ViteEnvironmentNames =\n (typeof VITE_ENVIRONMENT_NAMES)[keyof typeof VITE_ENVIRONMENT_NAMES]\n\n// for client and router:\n// if a user has a custom server/client entry point file, resolve.alias will point to this\n// otherwise it will be aliased to the default entry point in the respective framework plugin\nexport const ENTRY_POINTS = {\n client: 'virtual:tanstack-start-client-entry',\n server: 'virtual:tanstack-start-server-entry',\n // the start entry point must always be provided by the user\n start: '#tanstack-start-entry',\n router: '#tanstack-router-entry',\n} as const\n\nexport const SERVER_FN_LOOKUP = 'server-fn-module-lookup'\n\n// matches\n// .ts, .tsx, .cts, .mts, .js, .jsx, .cjs, .mjs\n// with optional query params after\n// but not .json\nexport const TRANSFORM_ID_REGEX = [/\\.[cm]?[tj]sx?($|\\?)/]\n"],"mappings":";AAAA,IAAa,yBAAyB;CAGpC,QAAQ;CACR,QAAQ;CACT;AAQD,IAAa,eAAe;CAC1B,QAAQ;CACR,QAAQ;CAER,OAAO;CACP,QAAQ;CACT;AAED,IAAa,mBAAmB;AAMhC,IAAa,qBAAqB,CAAC,uBAAuB"}