@analogjs/vite-plugin-nitro 3.0.0-beta.5 → 3.0.0-beta.51
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/package.json +1 -1
- package/src/lib/build-server.js +1 -1
- package/src/lib/build-server.js.map +1 -1
- package/src/lib/utils/i18n-prerender.d.ts +2 -1
- package/src/lib/utils/i18n-prerender.js +4 -2
- package/src/lib/utils/i18n-prerender.js.map +1 -1
- package/src/lib/utils/server-fn-endpoints.d.ts +3 -1
- package/src/lib/utils/server-fn-endpoints.js +16 -5
- package/src/lib/utils/server-fn-endpoints.js.map +1 -1
- package/src/lib/vite-plugin-nitro.js +8 -6
- package/src/lib/vite-plugin-nitro.js.map +1 -1
package/package.json
CHANGED
package/src/lib/build-server.js
CHANGED
|
@@ -47,7 +47,7 @@ async function buildServer(options, nitroConfig = {}, routeSourceFiles, i18nWork
|
|
|
47
47
|
if (options?.prerender?.postRenderingHooks) addPostRenderingHooks(nitro, options.prerender.postRenderingHooks);
|
|
48
48
|
await prepare(nitro);
|
|
49
49
|
await copyPublicAssets(nitro);
|
|
50
|
-
if (options?.ssr &&
|
|
50
|
+
if (options?.ssr && (!(options.static || nitro.options.static) || nitroConfig.prerender?.routes?.includes("/"))) [
|
|
51
51
|
"",
|
|
52
52
|
".br",
|
|
53
53
|
".gz"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-server.js","names":[],"sources":["../../../src/lib/build-server.ts"],"sourcesContent":["import { Nitro, NitroConfig, copyPublicAssets, prerender } from 'nitropack';\nimport { createNitro, build, prepare } from 'nitropack';\nimport { existsSync, mkdirSync, unlinkSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\n\nimport { Options } from './options.js';\nimport { addPostRenderingHooks } from './hooks/post-rendering-hook.js';\nimport { validateI18nWorkers } from './utils/i18n-workers.js';\nimport { createSsrStreamRenderer } from './utils/renderers.js';\n\nexport async function buildServer(\n options?: Options,\n nitroConfig: NitroConfig = {},\n routeSourceFiles?: Record<string, string>,\n i18nWorkers = false,\n): Promise<void> {\n if (i18nWorkers && options?.i18n) {\n validateI18nWorkers(options, nitroConfig);\n nitroConfig = {\n ...nitroConfig,\n entry: join(\n dirname(fileURLToPath(import.meta.url)),\n 'runtime/locale-worker-entry.mjs',\n ),\n externals: {\n ...nitroConfig.externals,\n inline: [...(nitroConfig.externals?.inline ?? []), '@analogjs/router'],\n },\n replace: {\n ...nitroConfig.replace,\n ANALOG_I18N_FIXED_LOCALE: \"process.env['ANALOG_I18N_LOCALE']\",\n ANALOG_I18N_DEFAULT_LOCALE: JSON.stringify(options.i18n.defaultLocale),\n ANALOG_I18N_LOCALES: JSON.stringify(options.i18n.locales),\n },\n virtual: {\n ...nitroConfig.virtual,\n '#analog/i18n-workers': `export default ${JSON.stringify({\n locales: options.i18n.locales,\n defaultLocale: options.i18n.defaultLocale,\n baseURL: nitroConfig.baseURL || '/',\n })}`,\n },\n };\n }\n const nitro = await createNitro({\n dev: false,\n preset: process.env['BUILD_PRESET'],\n ...nitroConfig,\n });\n\n try {\n if (options?.experimental?.streaming) {\n nitro.hooks.hook('prerender:init', (renderer) => {\n renderer.options.virtual = {\n ...renderer.options.virtual,\n '#ANALOG_SSR_RENDERER': createSsrStreamRenderer(true),\n };\n });\n }\n if (options?.prerender?.postRenderingHooks) {\n addPostRenderingHooks(nitro, options.prerender.postRenderingHooks);\n }\n\n await prepare(nitro);\n await copyPublicAssets(nitro);\n\n if (\n options?.ssr &&\n
|
|
1
|
+
{"version":3,"file":"build-server.js","names":[],"sources":["../../../src/lib/build-server.ts"],"sourcesContent":["import { Nitro, NitroConfig, copyPublicAssets, prerender } from 'nitropack';\nimport { createNitro, build, prepare } from 'nitropack';\nimport { existsSync, mkdirSync, unlinkSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\n\nimport { Options } from './options.js';\nimport { addPostRenderingHooks } from './hooks/post-rendering-hook.js';\nimport { validateI18nWorkers } from './utils/i18n-workers.js';\nimport { createSsrStreamRenderer } from './utils/renderers.js';\n\nexport async function buildServer(\n options?: Options,\n nitroConfig: NitroConfig = {},\n routeSourceFiles?: Record<string, string>,\n i18nWorkers = false,\n): Promise<void> {\n if (i18nWorkers && options?.i18n) {\n validateI18nWorkers(options, nitroConfig);\n nitroConfig = {\n ...nitroConfig,\n entry: join(\n dirname(fileURLToPath(import.meta.url)),\n 'runtime/locale-worker-entry.mjs',\n ),\n externals: {\n ...nitroConfig.externals,\n inline: [...(nitroConfig.externals?.inline ?? []), '@analogjs/router'],\n },\n replace: {\n ...nitroConfig.replace,\n ANALOG_I18N_FIXED_LOCALE: \"process.env['ANALOG_I18N_LOCALE']\",\n ANALOG_I18N_DEFAULT_LOCALE: JSON.stringify(options.i18n.defaultLocale),\n ANALOG_I18N_LOCALES: JSON.stringify(options.i18n.locales),\n },\n virtual: {\n ...nitroConfig.virtual,\n '#analog/i18n-workers': `export default ${JSON.stringify({\n locales: options.i18n.locales,\n defaultLocale: options.i18n.defaultLocale,\n baseURL: nitroConfig.baseURL || '/',\n })}`,\n },\n };\n }\n const nitro = await createNitro({\n dev: false,\n preset: process.env['BUILD_PRESET'],\n ...nitroConfig,\n });\n\n try {\n if (options?.experimental?.streaming) {\n nitro.hooks.hook('prerender:init', (renderer) => {\n renderer.options.virtual = {\n ...renderer.options.virtual,\n '#ANALOG_SSR_RENDERER': createSsrStreamRenderer(true),\n };\n });\n }\n if (options?.prerender?.postRenderingHooks) {\n addPostRenderingHooks(nitro, options.prerender.postRenderingHooks);\n }\n\n await prepare(nitro);\n await copyPublicAssets(nitro);\n\n if (\n options?.ssr &&\n (!(options.static || nitro.options.static) ||\n nitroConfig.prerender?.routes?.includes('/'))\n ) {\n const indexFileExts = ['', '.br', '.gz'];\n\n indexFileExts.forEach((fileExt) => {\n // Remove the root index.html(.br|.gz) files\n const indexFilePath = `${nitroConfig?.output?.publicDir}/index.html${fileExt ? `${fileExt}` : ''}`;\n\n if (existsSync(indexFilePath)) {\n unlinkSync(indexFilePath);\n }\n });\n }\n\n if (\n nitroConfig?.prerender?.routes &&\n nitroConfig?.prerender?.routes?.length > 0\n ) {\n console.log(`Prerendering static pages...`);\n let closePrerenderer: (() => Promise<void>) | undefined;\n let prerenderer: Nitro | undefined;\n const unhook = i18nWorkers\n ? nitro.hooks.hook('prerender:init', (renderer) => {\n prerenderer = renderer;\n renderer.hooks.hook('compiled', async () => {\n const fileName =\n renderer.options.rollupConfig?.output?.entryFileNames;\n const entry = join(\n renderer.options.output.serverDir,\n typeof fileName === 'string' ? fileName : 'index.mjs',\n );\n // Capture cleanup only after a successful build, before Nitro starts rendering.\n const runtime = await import(pathToFileURL(entry).href);\n closePrerenderer = runtime.closePrerenderer;\n });\n })\n : undefined;\n try {\n await prerender(nitro);\n } finally {\n unhook?.();\n try {\n await closePrerenderer?.();\n } finally {\n await prerenderer?.close();\n }\n }\n }\n\n if (routeSourceFiles && Object.keys(routeSourceFiles).length > 0) {\n const publicDir = nitroConfig?.output?.publicDir;\n if (!publicDir) {\n throw new Error(\n 'Nitro public output directory is required to write route source files.',\n );\n }\n\n for (const [route, content] of Object.entries(routeSourceFiles)) {\n const outputPath = join(publicDir, `${route}.md`);\n const outputDir = dirname(outputPath);\n\n if (!existsSync(outputDir)) {\n mkdirSync(outputDir, { recursive: true });\n }\n\n writeFileSync(outputPath, content, 'utf8');\n }\n }\n\n if (!options?.static) {\n console.log('Building Server...');\n await build(nitro);\n }\n } finally {\n await nitro.close();\n }\n}\n"],"mappings":";;;;;;;;AAWA,eAAsB,YACpB,SACA,cAA2B,CAAC,GAC5B,kBACA,cAAc,OACC;CACf,IAAI,eAAe,SAAS,MAAM;EAChC,oBAAoB,SAAS,WAAW;EACxC,cAAc;GACZ,GAAG;GACH,OAAO,KACL,QAAQ,cAAc,YAAY,GAAG,CAAC,GACtC,iCACF;GACA,WAAW;I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,SAAS,MAAM,KAAK,YAAY,YAAY;KAC1C,MAAM,WACJ,SAAS,QAAQ,cAAc,QAAQ;KACzC,MAAM,QAAQ,KACZ,SAAS,QAAQ,OAAO,WACxB,OAAO,aAAa,WAAW,WAAW,WAC5C;KAGA,oBAAmB,MADG,OAAO,cAAc,KAAK,CAAC,CAAC,MAAA,CACvB;IAC7B,CAAC;GACH,CAAC,IACD,KAAA;GACJ,IAAI;IACF,MAAM,UAAU,KAAK;GACvB,UAAU;IACR,SAAS;IACT,IAAI;KACF,MAAM,mBAAmB;IAC3B,UAAU;KACR,MAAM,aAAa,MAAM;IAC3B;GACF;EACF;EAEA,IAAI,oBAAoB,OAAO,KAAK,gBAAgB,CAAC,CAAC,SAAS,GAAG;GAChE,MAAM,YAAY,aAAa,QAAQ;GACvC,IAAI,CAAC,WACH,MAAM,IAAI,MACR,wEACF;GAGF,KAAK,MAAM,CAAC,OAAO,YAAY,OAAO,QAAQ,gBAAgB,GAAG;IAC/D,MAAM,aAAa,KAAK,WAAW,GAAG,MAAM,IAAI;IAChD,MAAM,YAAY,QAAQ,UAAU;IAEpC,IAAI,CAAC,WAAW,SAAS,GACvB,UAAU,WAAW,EAAE,WAAW,KAAK,CAAC;IAG1C,cAAc,YAAY,SAAS,MAAM;GAC3C;EACF;EAEA,IAAI,CAAC,SAAS,QAAQ;GACpB,QAAQ,IAAI,oBAAoB;GAChC,MAAM,MAAM,KAAK;EACnB;CACF,UAAU;EACR,MAAM,MAAM,MAAM;CACpB;AACF"}
|
|
@@ -12,9 +12,10 @@ import { I18nPrerenderOptions } from "../options.js";
|
|
|
12
12
|
*
|
|
13
13
|
* @param routes - The original routes to expand
|
|
14
14
|
* @param i18n - The i18n prerender configuration
|
|
15
|
+
* @param apiPrefix - The API route prefix (default `api`); API routes are not localized
|
|
15
16
|
* @returns Expanded routes with locale prefixes
|
|
16
17
|
*/
|
|
17
|
-
export declare function expandRoutesWithLocales(routes: string[], i18n: I18nPrerenderOptions): string[];
|
|
18
|
+
export declare function expandRoutesWithLocales(routes: string[], i18n: I18nPrerenderOptions, apiPrefix?: string): string[];
|
|
18
19
|
/**
|
|
19
20
|
* Creates a post-rendering hook that injects the `lang` attribute
|
|
20
21
|
* into the `<html>` tag of prerendered pages based on the route's
|
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @param routes - The original routes to expand
|
|
13
13
|
* @param i18n - The i18n prerender configuration
|
|
14
|
+
* @param apiPrefix - The API route prefix (default `api`); API routes are not localized
|
|
14
15
|
* @returns Expanded routes with locale prefixes
|
|
15
16
|
*/
|
|
16
|
-
function expandRoutesWithLocales(routes, i18n) {
|
|
17
|
+
function expandRoutesWithLocales(routes, i18n, apiPrefix = "api") {
|
|
17
18
|
const expanded = /* @__PURE__ */ new Set();
|
|
19
|
+
const apiRoute = `/${apiPrefix.replace(/^\/+|\/+$/g, "")}`;
|
|
18
20
|
for (const route of routes) {
|
|
19
21
|
const firstSegment = route.split("/").filter(Boolean)[0];
|
|
20
|
-
if (route.includes("/_analog/") || route.startsWith(
|
|
22
|
+
if (route.includes("/_analog/") || route === apiRoute || route.startsWith(`${apiRoute}/`) || i18n.locales.includes(firstSegment)) {
|
|
21
23
|
expanded.add(route);
|
|
22
24
|
continue;
|
|
23
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-prerender.js","names":[],"sources":["../../../../src/lib/utils/i18n-prerender.ts"],"sourcesContent":["import { PrerenderRoute } from 'nitropack';\nimport { I18nPrerenderOptions } from '../options.js';\n\n/**\n * Expands a list of routes to include locale-prefixed variants.\n *\n * For each route and each locale, generates a prefixed route:\n * '/' + locale + route\n *\n * The default locale's routes are included both with and without the prefix\n * so that `/about` and `/en/about` both render.\n * Routes that already have a configured locale prefix are kept as-is.\n *\n * @param routes - The original routes to expand\n * @param i18n - The i18n prerender configuration\n * @returns Expanded routes with locale prefixes\n */\nexport function expandRoutesWithLocales(\n routes: string[],\n i18n: I18nPrerenderOptions,\n): string[] {\n const expanded = new Set<string>();\n\n for (const route of routes) {\n // API routes and explicitly localized routes don't need locale prefixes.\n const firstSegment = route.split('/').filter(Boolean)[0];\n if (\n route.includes('/_analog/') ||\n route.startsWith(
|
|
1
|
+
{"version":3,"file":"i18n-prerender.js","names":[],"sources":["../../../../src/lib/utils/i18n-prerender.ts"],"sourcesContent":["import { PrerenderRoute } from 'nitropack';\nimport { I18nPrerenderOptions } from '../options.js';\n\n/**\n * Expands a list of routes to include locale-prefixed variants.\n *\n * For each route and each locale, generates a prefixed route:\n * '/' + locale + route\n *\n * The default locale's routes are included both with and without the prefix\n * so that `/about` and `/en/about` both render.\n * Routes that already have a configured locale prefix are kept as-is.\n *\n * @param routes - The original routes to expand\n * @param i18n - The i18n prerender configuration\n * @param apiPrefix - The API route prefix (default `api`); API routes are not localized\n * @returns Expanded routes with locale prefixes\n */\nexport function expandRoutesWithLocales(\n routes: string[],\n i18n: I18nPrerenderOptions,\n apiPrefix = 'api',\n): string[] {\n const expanded = new Set<string>();\n const apiRoute = `/${apiPrefix.replace(/^\\/+|\\/+$/g, '')}`;\n\n for (const route of routes) {\n // API routes and explicitly localized routes don't need locale prefixes.\n const firstSegment = route.split('/').filter(Boolean)[0];\n if (\n route.includes('/_analog/') ||\n route === apiRoute ||\n route.startsWith(`${apiRoute}/`) ||\n i18n.locales.includes(firstSegment)\n ) {\n expanded.add(route);\n continue;\n }\n\n for (const locale of i18n.locales) {\n const prefix = `/${locale}`;\n const localizedRoute = route === '/' ? prefix : `${prefix}${route}`;\n expanded.add(localizedRoute);\n }\n\n // Keep the unprefixed route for the default locale\n expanded.add(route);\n }\n\n return [...expanded];\n}\n\n/**\n * Creates a post-rendering hook that injects the `lang` attribute\n * into the `<html>` tag of prerendered pages based on the route's\n * locale prefix.\n *\n * @param i18n - The i18n prerender configuration\n * @returns A post-rendering hook function\n */\nexport function createI18nPostRenderingHook(\n i18n: I18nPrerenderOptions,\n): (route: PrerenderRoute) => Promise<void> {\n return async (route: PrerenderRoute) => {\n if (!route.contents || typeof route.contents !== 'string') {\n return;\n }\n\n const locale = detectLocaleFromRoute(route.route, i18n);\n if (!locale) {\n return;\n }\n\n // Inject or replace the lang attribute on <html>\n route.contents = setHtmlLang(route.contents, locale);\n };\n}\n\n/**\n * Detects the locale from a prerendered route path by checking\n * the first path segment against the configured locales.\n */\nexport function detectLocaleFromRoute(\n route: string,\n i18n: I18nPrerenderOptions,\n): string {\n const segments = route.split('/').filter(Boolean);\n const firstSegment = segments[0];\n\n if (firstSegment && i18n.locales.includes(firstSegment)) {\n return firstSegment;\n }\n\n return i18n.defaultLocale;\n}\n\n/**\n * Sets the `lang` attribute on the `<html>` tag in an HTML string.\n * If a `lang` attribute already exists, it is replaced.\n * If no `lang` attribute exists, it is added.\n */\nexport function setHtmlLang(html: string, locale: string): string {\n // Replace existing lang attribute\n if (/<html[^>]*\\slang\\s*=\\s*[\"'][^\"']*[\"']/i.test(html)) {\n return html.replace(\n /(<html[^>]*\\s)lang\\s*=\\s*[\"'][^\"']*[\"']/i,\n `$1lang=\"${locale}\"`,\n );\n }\n\n // Add lang attribute to <html> tag\n return html.replace(/<html/i, `<html lang=\"${locale}\"`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,SAAgB,wBACd,QACA,MACA,YAAY,OACF;CACV,MAAM,2BAAW,IAAI,IAAY;CACjC,MAAM,WAAW,IAAI,UAAU,QAAQ,cAAc,EAAE;CAEvD,KAAK,MAAM,SAAS,QAAQ;EAE1B,MAAM,eAAe,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC;EACtD,IACE,MAAM,SAAS,WAAW,KAC1B,UAAU,YACV,MAAM,WAAW,GAAG,SAAS,EAAE,KAC/B,KAAK,QAAQ,SAAS,YAAY,GAClC;GACA,SAAS,IAAI,KAAK;GAClB;EACF;EAEA,KAAK,MAAM,UAAU,KAAK,SAAS;GACjC,MAAM,SAAS,IAAI;GACnB,MAAM,iBAAiB,UAAU,MAAM,SAAS,GAAG,SAAS;GAC5D,SAAS,IAAI,cAAc;EAC7B;EAGA,SAAS,IAAI,KAAK;CACpB;CAEA,OAAO,CAAC,GAAG,QAAQ;AACrB;;;;;;;;;AAUA,SAAgB,4BACd,MAC0C;CAC1C,OAAO,OAAO,UAA0B;EACtC,IAAI,CAAC,MAAM,YAAY,OAAO,MAAM,aAAa,UAC/C;EAGF,MAAM,SAAS,sBAAsB,MAAM,OAAO,IAAI;EACtD,IAAI,CAAC,QACH;EAIF,MAAM,WAAW,YAAY,MAAM,UAAU,MAAM;CACrD;AACF;;;;;AAMA,SAAgB,sBACd,OACA,MACQ;CAER,MAAM,eADW,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,OACpB,CAAA,CAAS;CAE9B,IAAI,gBAAgB,KAAK,QAAQ,SAAS,YAAY,GACpD,OAAO;CAGT,OAAO,KAAK;AACd;;;;;;AAOA,SAAgB,YAAY,MAAc,QAAwB;CAEhE,IAAI,yCAAyC,KAAK,IAAI,GACpD,OAAO,KAAK,QACV,4CACA,WAAW,OAAO,EACpB;CAIF,OAAO,KAAK,QAAQ,UAAU,eAAe,OAAO,EAAE;AACxD"}
|
|
@@ -29,6 +29,8 @@ export type BuildServerFnDispatchModuleArgs = {
|
|
|
29
29
|
* app configured. When absent, handlers run with only `providedIn: 'root'`.
|
|
30
30
|
*/
|
|
31
31
|
appConfigModule?: string;
|
|
32
|
+
/** The app's root directory, where `zone.js` is resolved from. */
|
|
33
|
+
root: string;
|
|
32
34
|
};
|
|
33
35
|
/**
|
|
34
36
|
* Generates the source of the Nitro dispatch handler.
|
|
@@ -38,4 +40,4 @@ export type BuildServerFnDispatchModuleArgs = {
|
|
|
38
40
|
* each request looks up the function by id and runs it via `dispatchServerFn` —
|
|
39
41
|
* the same call path the validation harnesses exercise.
|
|
40
42
|
*/
|
|
41
|
-
export declare function buildServerFnDispatchModule({ modules, appConfigModule }: BuildServerFnDispatchModuleArgs): string;
|
|
43
|
+
export declare function buildServerFnDispatchModule({ modules, appConfigModule, root }: BuildServerFnDispatchModuleArgs): string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { normalizePath } from "vite";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
2
4
|
//#region packages/vite-plugin-nitro/src/lib/utils/server-fn-endpoints.ts
|
|
3
5
|
/**
|
|
4
6
|
* Nitro virtual-module id for the generated server-function dispatch handler.
|
|
@@ -33,16 +35,17 @@ function getServerFnDispatchHandler() {
|
|
|
33
35
|
* each request looks up the function by id and runs it via `dispatchServerFn` —
|
|
34
36
|
* the same call path the validation harnesses exercise.
|
|
35
37
|
*/
|
|
36
|
-
function buildServerFnDispatchModule({ modules, appConfigModule }) {
|
|
38
|
+
function buildServerFnDispatchModule({ modules, appConfigModule, root }) {
|
|
39
|
+
const registrationImports = modules.map((m) => `import ${JSON.stringify(normalizePath(m.file))};`).join("\n");
|
|
40
|
+
const appConfig = appConfigModule ? `import { config as serverFnAppConfig } from ${JSON.stringify(normalizePath(appConfigModule))};` : `const serverFnAppConfig = { providers: [] };`;
|
|
37
41
|
return `import '@angular/compiler';
|
|
38
|
-
import 'zone.js/node';
|
|
39
|
-
import '@angular/platform-server/init';
|
|
42
|
+
${hasZoneJs(root) ? `import 'zone.js/node';\n` : ""}import '@angular/platform-server/init';
|
|
40
43
|
import { createServerFnAppInjector, createServerFnEventHandler } from '@analogjs/router/server';
|
|
41
44
|
|
|
42
45
|
// Discovered server-function modules (registration side-effects).
|
|
43
|
-
${
|
|
46
|
+
${registrationImports}
|
|
44
47
|
|
|
45
|
-
${
|
|
48
|
+
${appConfig}
|
|
46
49
|
|
|
47
50
|
// Bootstrapped once from the app's own server config, so a handler resolves the
|
|
48
51
|
// same DI as an SSR render (\`providedIn: 'root'\` and listed providers alike).
|
|
@@ -53,6 +56,14 @@ export default createServerFnEventHandler(
|
|
|
53
56
|
);
|
|
54
57
|
`;
|
|
55
58
|
}
|
|
59
|
+
function hasZoneJs(root) {
|
|
60
|
+
try {
|
|
61
|
+
createRequire(join(root, "noop.js")).resolve("zone.js/node");
|
|
62
|
+
return true;
|
|
63
|
+
} catch {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
56
67
|
//#endregion
|
|
57
68
|
export { SERVER_FN_DISPATCH_PREFIX, SERVER_FN_DISPATCH_ROUTE, SERVER_FN_DISPATCH_VIRTUAL, buildServerFnDispatchModule, getServerFnDispatchHandler };
|
|
58
69
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-fn-endpoints.js","names":[],"sources":["../../../../src/lib/utils/server-fn-endpoints.ts"],"sourcesContent":["import type { NitroEventHandler } from 'nitropack';\nimport { normalizePath } from 'vite';\n\nimport type { ServerFnHandlerModule } from './get-server-fn-handlers';\n\n/**\n * Nitro virtual-module id for the generated server-function dispatch handler.\n * Referenced from `nitroConfig.handlers` and provided via `nitroConfig.virtual`.\n */\nexport const SERVER_FN_DISPATCH_VIRTUAL = '#ANALOG_SERVER_FN_DISPATCH';\n\n/** The single transport route all server functions dispatch through. */\nexport const SERVER_FN_DISPATCH_ROUTE = '/_analog/fn/:id';\n\n/** URL prefix of that route, for matching requests before the id is known. */\nexport const SERVER_FN_DISPATCH_PREFIX = '/_analog/fn/';\n\n/**\n * The Nitro handler registration for the server-function dispatch route.\n * Unlike page endpoints (one handler per file), every server function shares\n * this one `/_analog/fn/:id` route; the id selects the function at runtime.\n *\n * The route is fixed and NOT `/api`-prefixed: client proxies always call the\n * absolute `/_analog/fn/:id` URL, so an `/api` prefix (as page endpoints use)\n * would leave the handler unreachable in apps that have an API directory.\n */\nexport function getServerFnDispatchHandler(): NitroEventHandler {\n return {\n route: SERVER_FN_DISPATCH_ROUTE,\n handler: SERVER_FN_DISPATCH_VIRTUAL,\n lazy: true,\n };\n}\n\nexport type BuildServerFnDispatchModuleArgs = {\n /** Discovered `*.server.ts` modules, imported for registration side-effects. */\n modules: ServerFnHandlerModule[];\n /**\n * Absolute path to the app's server config module (`app.config.server.ts`),\n * which exports the `ApplicationConfig` (as `config`) that `main.server.ts`\n * renders with. Handlers bootstrap against it, so they see the same DI the\n * app configured. When absent, handlers run with only `providedIn: 'root'`.\n */\n appConfigModule?: string;\n};\n\n/**\n * Generates the source of the Nitro dispatch handler.\n *\n * The handler imports every discovered `*.server.ts` module so each\n * `serverFn(...)` registers itself, imports the app's server config, then on\n * each request looks up the function by id and runs it via `dispatchServerFn` —\n * the same call path the validation harnesses exercise.\n */\nexport function buildServerFnDispatchModule({\n modules,\n appConfigModule,\n}: BuildServerFnDispatchModuleArgs): string {\n const registrationImports = modules\n .map((m) => `import ${JSON.stringify(normalizePath(m.file))};`)\n .join('\\n');\n\n // Bootstrap against the app's own server config so a handler resolves exactly\n // the services, tokens, and interceptors the app configured — one config, no\n // second provider list. Fall back to an empty config when the app has none.\n const appConfig = appConfigModule\n ? `import { config as serverFnAppConfig } from ${JSON.stringify(\n normalizePath(appConfigModule),\n )};`\n : `const serverFnAppConfig = { providers: [] };`;\n\n // `@analogjs/router/server` is a partially-compiled Angular library, and this\n // module is bundled by Nitro rather than by the app's Angular pipeline, so the\n // linker never runs over it. Loading the compiler gives it the JIT fallback.\n // `zone.js` and the server platform init match the SSR entry, so bootstrapping
|
|
1
|
+
{"version":3,"file":"server-fn-endpoints.js","names":[],"sources":["../../../../src/lib/utils/server-fn-endpoints.ts"],"sourcesContent":["import type { NitroEventHandler } from 'nitropack';\nimport { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { normalizePath } from 'vite';\n\nimport type { ServerFnHandlerModule } from './get-server-fn-handlers';\n\n/**\n * Nitro virtual-module id for the generated server-function dispatch handler.\n * Referenced from `nitroConfig.handlers` and provided via `nitroConfig.virtual`.\n */\nexport const SERVER_FN_DISPATCH_VIRTUAL = '#ANALOG_SERVER_FN_DISPATCH';\n\n/** The single transport route all server functions dispatch through. */\nexport const SERVER_FN_DISPATCH_ROUTE = '/_analog/fn/:id';\n\n/** URL prefix of that route, for matching requests before the id is known. */\nexport const SERVER_FN_DISPATCH_PREFIX = '/_analog/fn/';\n\n/**\n * The Nitro handler registration for the server-function dispatch route.\n * Unlike page endpoints (one handler per file), every server function shares\n * this one `/_analog/fn/:id` route; the id selects the function at runtime.\n *\n * The route is fixed and NOT `/api`-prefixed: client proxies always call the\n * absolute `/_analog/fn/:id` URL, so an `/api` prefix (as page endpoints use)\n * would leave the handler unreachable in apps that have an API directory.\n */\nexport function getServerFnDispatchHandler(): NitroEventHandler {\n return {\n route: SERVER_FN_DISPATCH_ROUTE,\n handler: SERVER_FN_DISPATCH_VIRTUAL,\n lazy: true,\n };\n}\n\nexport type BuildServerFnDispatchModuleArgs = {\n /** Discovered `*.server.ts` modules, imported for registration side-effects. */\n modules: ServerFnHandlerModule[];\n /**\n * Absolute path to the app's server config module (`app.config.server.ts`),\n * which exports the `ApplicationConfig` (as `config`) that `main.server.ts`\n * renders with. Handlers bootstrap against it, so they see the same DI the\n * app configured. When absent, handlers run with only `providedIn: 'root'`.\n */\n appConfigModule?: string;\n /** The app's root directory, where `zone.js` is resolved from. */\n root: string;\n};\n\n/**\n * Generates the source of the Nitro dispatch handler.\n *\n * The handler imports every discovered `*.server.ts` module so each\n * `serverFn(...)` registers itself, imports the app's server config, then on\n * each request looks up the function by id and runs it via `dispatchServerFn` —\n * the same call path the validation harnesses exercise.\n */\nexport function buildServerFnDispatchModule({\n modules,\n appConfigModule,\n root,\n}: BuildServerFnDispatchModuleArgs): string {\n const registrationImports = modules\n .map((m) => `import ${JSON.stringify(normalizePath(m.file))};`)\n .join('\\n');\n\n // Bootstrap against the app's own server config so a handler resolves exactly\n // the services, tokens, and interceptors the app configured — one config, no\n // second provider list. Fall back to an empty config when the app has none.\n const appConfig = appConfigModule\n ? `import { config as serverFnAppConfig } from ${JSON.stringify(\n normalizePath(appConfigModule),\n )};`\n : `const serverFnAppConfig = { providers: [] };`;\n\n // `@analogjs/router/server` is a partially-compiled Angular library, and this\n // module is bundled by Nitro rather than by the app's Angular pipeline, so the\n // linker never runs over it. Loading the compiler gives it the JIT fallback.\n // `zone.js` (when installed; zoneless apps may omit it) and the server\n // platform init match the SSR entry, so bootstrapping the app injector below\n // runs in the same environment a render would.\n //\n // The transport itself — id decoding, the malformed-body contract, dispatch,\n // and response writing — lives in `createServerFnEventHandler`, so this module\n // is only wiring: bootstrap the app injector from the app's server config, and\n // hand it to that handler.\n const zoneImport = hasZoneJs(root) ? `import 'zone.js/node';\\n` : '';\n\n return `import '@angular/compiler';\n${zoneImport}import '@angular/platform-server/init';\nimport { createServerFnAppInjector, createServerFnEventHandler } from '@analogjs/router/server';\n\n// Discovered server-function modules (registration side-effects).\n${registrationImports}\n\n${appConfig}\n\n// Bootstrapped once from the app's own server config, so a handler resolves the\n// same DI as an SSR render (\\`providedIn: 'root'\\` and listed providers alike).\n// No component is bootstrapped, so nothing renders and the router never\n// navigates. Only REQUEST/RESPONSE are rebuilt per call.\nexport default createServerFnEventHandler(\n createServerFnAppInjector(serverFnAppConfig),\n);\n`;\n}\n\nfunction hasZoneJs(root: string): boolean {\n try {\n createRequire(join(root, 'noop.js')).resolve('zone.js/node');\n return true;\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;AAWA,IAAa,6BAA6B;;AAG1C,IAAa,2BAA2B;;AAGxC,IAAa,4BAA4B;;;;;;;;;;AAWzC,SAAgB,6BAAgD;CAC9D,OAAO;EACL,OAAO;EACP,SAAS;EACT,MAAM;CACR;AACF;;;;;;;;;AAwBA,SAAgB,4BAA4B,EAC1C,SACA,iBACA,QAC0C;CAC1C,MAAM,sBAAsB,QACzB,KAAK,MAAM,UAAU,KAAK,UAAU,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAC9D,KAAK,IAAI;CAKZ,MAAM,YAAY,kBACd,+CAA+C,KAAK,UAClD,cAAc,eAAe,CAC/B,EAAE,KACF;CAeJ,OAAO;EAFY,UAAU,IAAI,IAAI,6BAA6B,GAGvD;;;;EAIX,oBAAoB;;EAEpB,UAAU;;;;;;;;;;AAUZ;AAEA,SAAS,UAAU,MAAuB;CACxC,IAAI;EACF,cAAc,KAAK,MAAM,SAAS,CAAC,CAAC,CAAC,QAAQ,cAAc;EAC3D,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
@@ -85,7 +85,8 @@ function nitro(pluginOptions = {}) {
|
|
|
85
85
|
const serverFnHandlers = hasServerFns ? [getServerFnDispatchHandler()] : [];
|
|
86
86
|
const serverFnVirtual = serverFnModules.length > 0 ? { [SERVER_FN_DISPATCH_VIRTUAL]: buildServerFnDispatchModule({
|
|
87
87
|
modules: serverFnModules,
|
|
88
|
-
appConfigModule: serverFnAppConfigModule
|
|
88
|
+
appConfigModule: serverFnAppConfigModule,
|
|
89
|
+
root: resolve(workspaceRoot, rootDir)
|
|
89
90
|
}) } : {};
|
|
90
91
|
nitroConfig = {
|
|
91
92
|
rootDir,
|
|
@@ -170,7 +171,7 @@ function nitro(pluginOptions = {}) {
|
|
|
170
171
|
});
|
|
171
172
|
return prev;
|
|
172
173
|
}, []);
|
|
173
|
-
if (options?.i18n && nitroConfig.prerender?.routes) nitroConfig.prerender.routes = expandRoutesWithLocales(nitroConfig.prerender.routes.filter(Boolean), options.i18n);
|
|
174
|
+
if (options?.i18n && nitroConfig.prerender?.routes) nitroConfig.prerender.routes = expandRoutesWithLocales(nitroConfig.prerender.routes.filter(Boolean), options.i18n, apiPrefix);
|
|
174
175
|
}
|
|
175
176
|
if (options?.i18n) {
|
|
176
177
|
options.prerender = options.prerender ?? {};
|
|
@@ -401,8 +402,9 @@ function getAnalogOptions(userConfig) {
|
|
|
401
402
|
return (userConfig.plugins ?? []).flat(Infinity).find((plugin) => plugin?.api?.analogOptions)?.api?.analogOptions;
|
|
402
403
|
}
|
|
403
404
|
/**
|
|
404
|
-
* Stamps `ssr
|
|
405
|
-
*
|
|
405
|
+
* Stamps `ssr` and `streaming` route rules as response headers, which the
|
|
406
|
+
* renderers read to skip SSR or streaming for matching routes. `true` rules
|
|
407
|
+
* stamp `'false'` so they override a broader `false` rule.
|
|
406
408
|
*/
|
|
407
409
|
function withAnalogRouteRuleHeaders(nitroOptions) {
|
|
408
410
|
if (!nitroOptions.routeRules) return nitroOptions;
|
|
@@ -410,8 +412,8 @@ function withAnalogRouteRuleHeaders(nitroOptions) {
|
|
|
410
412
|
...rule,
|
|
411
413
|
headers: {
|
|
412
414
|
...rule.headers,
|
|
413
|
-
...rule.ssr ===
|
|
414
|
-
...rule.streaming ===
|
|
415
|
+
...typeof rule.ssr === "boolean" ? { "x-analog-no-ssr": String(!rule.ssr) } : {},
|
|
416
|
+
...typeof rule.streaming === "boolean" ? { "x-analog-no-streaming": String(!rule.streaming) } : {}
|
|
415
417
|
}
|
|
416
418
|
}]));
|
|
417
419
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-nitro.js","names":[],"sources":["../../../src/lib/vite-plugin-nitro.ts"],"sourcesContent":["import {\n NitroConfig,\n build,\n createDevServer,\n createNitro,\n loadOptions,\n} from 'nitropack';\nimport { App, toNodeListener } from 'h3';\nimport type { Plugin, UserConfig, ViteDevServer } from 'vite';\nimport { mergeConfig, normalizePath } from 'vite';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { platform } from 'node:os';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { existsSync, readFileSync } from 'node:fs';\n\nimport { buildServer } from './build-server.js';\nimport { buildSSRApp } from './build-ssr.js';\nimport {\n I18N_WORKER_SSR_ENTRY,\n i18nWorkerSsrEntry,\n resolveI18nWorkers,\n} from './utils/i18n-workers.js';\nimport {\n Options,\n PrerenderContentDir,\n PrerenderContentFile,\n PrerenderRouteConfig,\n PrerenderSitemapConfig,\n} from './options.js';\nimport { pageEndpointsPlugin } from './plugins/page-endpoints.js';\nimport { serverFnIdPlugin } from './plugins/server-fn-id-plugin.js';\nimport { getPageHandlers } from './utils/get-page-handlers.js';\nimport { getServerFnHandlers } from './utils/get-server-fn-handlers.js';\nimport {\n buildServerFnDispatchModule,\n getServerFnDispatchHandler,\n SERVER_FN_DISPATCH_PREFIX,\n SERVER_FN_DISPATCH_VIRTUAL,\n} from './utils/server-fn-endpoints.js';\nimport { buildSitemap } from './build-sitemap.js';\nimport { devServerPlugin } from './plugins/dev-server-plugin.js';\nimport { getMatchingContentFilesWithFrontMatter } from './utils/get-content-files.js';\nimport { IncomingMessage, ServerResponse } from 'node:http';\nimport {\n ssrRenderer,\n ssrStreamRenderer,\n clientRenderer,\n} from './utils/renderers.js';\nimport {\n expandRoutesWithLocales,\n createI18nPostRenderingHook,\n} from './utils/i18n-prerender.js';\n\nconst isWindows = platform() === 'win32';\nconst filePrefix = isWindows ? 'file:///' : '';\nlet clientOutputPath = '';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nexport interface NitroPluginOptions extends NitroConfig {\n /**\n * Analog options for apps that don't use `analog()` from\n * `@analogjs/platform`. They override the options passed to `analog()`.\n */\n analog?: Options;\n}\n\nexport function nitro(pluginOptions: NitroPluginOptions = {}): Plugin[] {\n // Nitro's `static` means the same as Analog's: prerender without a server.\n const { analog, static: isStatic, ...pluginNitroOptions } = pluginOptions;\n const nitroOptions = withAnalogRouteRuleHeaders(pluginNitroOptions);\n let options: Options | undefined;\n let workspaceRoot = process.cwd();\n let sourceRoot = 'src';\n let isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const baseURL = process.env['NITRO_APP_BASE_URL'] || '';\n const prefix = baseURL ? baseURL.substring(0, baseURL.length - 1) : '';\n let apiPrefix = '/api';\n\n let i18nWorkers = false;\n let isBuild = false;\n let isServe = false;\n let ssrBuild = false;\n let config: UserConfig;\n let nitroConfig: NitroConfig;\n let environmentBuild = false;\n let hasServerFns = false;\n const routeSitemaps: Record<\n string,\n PrerenderSitemapConfig | (() => PrerenderSitemapConfig)\n > = {};\n const routeSourceFiles: Record<string, string> = {};\n let rootDir = workspaceRoot;\n\n // Options passed to `analog()` are the defaults, so an Analog app configures\n // SSR, prerendering and API routes in one place.\n function resolveOptions(userConfig: UserConfig) {\n options = {\n ...getAnalogOptions(userConfig),\n ...(isStatic === undefined ? {} : { static: isStatic }),\n ...analog,\n };\n workspaceRoot = options.workspaceRoot ?? process.cwd();\n sourceRoot = options.sourceRoot ?? 'src';\n apiPrefix = `/${options.apiPrefix || 'api'}`;\n }\n\n return [\n {\n name: '@analogjs/vite-plugin-nitro',\n async config(userConfig, { mode, command }) {\n resolveOptions(userConfig);\n isServe = command === 'serve';\n isBuild = command === 'build';\n ssrBuild = userConfig.build?.ssr === true;\n config = userConfig;\n isTest = isTest ? isTest : mode === 'test';\n\n rootDir = relative(workspaceRoot, config.root || '.') || '.';\n const buildPreset =\n process.env['BUILD_PRESET'] ??\n (nitroOptions?.preset as string | undefined);\n\n const pageHandlers = getPageHandlers({\n workspaceRoot,\n sourceRoot,\n rootDir,\n additionalPagesDirs: options?.additionalPagesDirs,\n apiPrefix,\n });\n\n // Server functions: discover every `*.server.ts` module, then register a\n // single `/_analog/fn/:id` dispatch handler backed by a generated Nitro\n // virtual module that imports those modules (registration side-effects)\n // and the app provider set. Only wired when server functions exist.\n const serverFnModules = getServerFnHandlers({\n workspaceRoot,\n sourceRoot,\n rootDir,\n additionalServerFnDirs: options?.additionalServerFnDirs,\n });\n const serverFnAppConfigModule = resolveServerFnAppConfigModule(\n workspaceRoot,\n rootDir,\n sourceRoot,\n );\n hasServerFns = serverFnModules.length > 0;\n const serverFnHandlers = hasServerFns\n ? [getServerFnDispatchHandler()]\n : [];\n const serverFnVirtual =\n serverFnModules.length > 0\n ? {\n [SERVER_FN_DISPATCH_VIRTUAL]: buildServerFnDispatchModule({\n modules: serverFnModules,\n appConfigModule: serverFnAppConfigModule,\n }),\n }\n : {};\n\n nitroConfig = {\n rootDir,\n preset: buildPreset,\n compatibilityDate: '2024-11-19',\n logLevel: nitroOptions?.logLevel || 0,\n srcDir: normalizePath(`${sourceRoot}/server`),\n scanDirs: [\n normalizePath(`${rootDir}/${sourceRoot}/server`),\n ...(options?.additionalAPIDirs || []).map((dir) =>\n normalizePath(`${workspaceRoot}${dir}`),\n ),\n ],\n output: {\n dir: normalizePath(\n resolve(workspaceRoot, 'dist', rootDir, 'analog'),\n ),\n publicDir: normalizePath(\n resolve(workspaceRoot, 'dist', rootDir, 'analog/public'),\n ),\n },\n buildDir: normalizePath(\n resolve(workspaceRoot, 'dist', rootDir, '.nitro'),\n ),\n typescript: {\n generateTsConfig: false,\n },\n runtimeConfig: {\n apiPrefix: apiPrefix.substring(1),\n prefix,\n },\n // Fixes support for Rolldown\n imports: {\n autoImport: false,\n },\n // The dispatch module's imports are all bare side-effect imports —\n // the JIT compiler it needs, and each `*.server.ts` whose import is\n // what registers its functions. Nitro treeshakes those away unless\n // the modules are declared side-effectful, which would leave every\n // call 404ing against an empty registry.\n ...(hasServerFns\n ? {\n moduleSideEffects: [\n '@angular/compiler',\n ...serverFnModules.map((m) => normalizePath(m.file)),\n ],\n }\n : {}),\n rollupConfig: {\n onwarn(warning) {\n if (\n warning.message.includes('empty chunk') &&\n warning.message.endsWith('.server')\n ) {\n return;\n }\n },\n plugins: [\n pageEndpointsPlugin(),\n serverFnIdPlugin(normalizePath(resolve(workspaceRoot, rootDir))),\n ],\n },\n handlers: [...pageHandlers, ...serverFnHandlers],\n virtual: {\n '#ANALOG_SSR_RENDERER': options?.experimental?.streaming\n ? ssrStreamRenderer\n : ssrRenderer,\n '#ANALOG_CLIENT_RENDERER': clientRenderer,\n ...serverFnVirtual,\n },\n };\n\n if (isVercelPreset(buildPreset)) {\n nitroConfig = withVercelOutputAPI(nitroConfig, workspaceRoot);\n }\n\n if (isCloudflarePreset(buildPreset)) {\n nitroConfig = withCloudflareOutput(nitroConfig);\n }\n\n if (\n isNetlifyPreset(buildPreset) &&\n rootDir === '.' &&\n !existsSync(resolve(workspaceRoot, 'netlify.toml'))\n ) {\n nitroConfig = withNetlifyOutputAPI(nitroConfig, workspaceRoot);\n }\n\n if (isFirebaseAppHosting()) {\n nitroConfig = withAppHostingOutput(nitroConfig);\n }\n\n if (!ssrBuild && !isTest) {\n // store the client output path for the SSR build config\n clientOutputPath = resolve(\n workspaceRoot,\n rootDir,\n config.build?.outDir || 'dist/client',\n );\n }\n\n const indexEntry = normalizePath(\n resolve(clientOutputPath, 'index.html'),\n );\n nitroConfig.alias = {\n '#analog/index': indexEntry,\n };\n\n if (isBuild) {\n nitroConfig.publicAssets = [{ dir: clientOutputPath }];\n nitroConfig.renderer = options?.ssr\n ? '#ANALOG_SSR_RENDERER'\n : '#ANALOG_CLIENT_RENDERER';\n\n if (isEmptyPrerenderRoutes(options)) {\n nitroConfig.prerender = {};\n nitroConfig.prerender.routes = ['/'];\n }\n\n if (options?.prerender) {\n nitroConfig.prerender = nitroConfig.prerender ?? {};\n nitroConfig.prerender.crawlLinks = options?.prerender?.discover;\n\n let routes: (\n | string\n | PrerenderContentDir\n | PrerenderRouteConfig\n | undefined\n )[] = [];\n\n const prerenderRoutes = options?.prerender?.routes;\n if (\n isArrayWithElements<string | PrerenderContentDir>(prerenderRoutes)\n ) {\n routes = prerenderRoutes;\n } else if (typeof prerenderRoutes === 'function') {\n routes = await prerenderRoutes();\n }\n\n nitroConfig.prerender.routes = routes.reduce<string[]>(\n (prev, current) => {\n if (!current) {\n return prev;\n }\n if (typeof current === 'string') {\n prev.push(current);\n return prev;\n }\n\n if ('route' in current) {\n if (current.sitemap) {\n routeSitemaps[current.route] = current.sitemap;\n }\n\n if (current.outputSourceFile) {\n const sourcePath = resolve(\n workspaceRoot,\n rootDir,\n current.outputSourceFile,\n );\n routeSourceFiles[current.route] = readFileSync(\n sourcePath,\n 'utf8',\n );\n }\n\n prev.push(current.route);\n\n // Add the server-side data fetching endpoint URL\n if ('staticData' in current) {\n prev.push(`${apiPrefix}/_analog/pages/${current.route}`);\n }\n\n return prev;\n }\n\n const affectedFiles: PrerenderContentFile[] =\n getMatchingContentFilesWithFrontMatter(\n workspaceRoot,\n rootDir,\n current.contentDir,\n current.recursive,\n );\n\n affectedFiles.forEach((f) => {\n const result = current.transform(f);\n\n if (result) {\n if (current.sitemap) {\n routeSitemaps[result] =\n current.sitemap && typeof current.sitemap === 'function'\n ? current.sitemap?.(f)\n : current.sitemap;\n }\n\n if (current.outputSourceFile) {\n const sourceContent = current.outputSourceFile(f);\n if (sourceContent) {\n routeSourceFiles[result] = sourceContent;\n }\n }\n\n prev.push(result);\n\n // Add the server-side data fetching endpoint URL\n if ('staticData' in current) {\n prev.push(`${apiPrefix}/_analog/pages/${result}`);\n }\n }\n });\n\n return prev;\n },\n [],\n );\n\n // Expand routes with locale prefixes when i18n is configured\n if (options?.i18n && nitroConfig.prerender?.routes) {\n nitroConfig.prerender.routes = expandRoutesWithLocales(\n nitroConfig.prerender.routes.filter(Boolean) as string[],\n options.i18n,\n );\n }\n }\n\n // Register i18n post-rendering hook for lang attribute injection\n if (options?.i18n) {\n options.prerender = options.prerender ?? {};\n options.prerender.postRenderingHooks =\n options.prerender.postRenderingHooks ?? [];\n options.prerender.postRenderingHooks.push(\n createI18nPostRenderingHook(options.i18n),\n );\n }\n\n if (ssrBuild) {\n if (isWindows) {\n nitroConfig.externals = {\n inline: ['std-env'],\n };\n }\n\n nitroConfig = {\n ...nitroConfig,\n externals: {\n ...nitroConfig.externals,\n external: ['rxjs', 'node-fetch-native/dist/polyfill'],\n },\n moduleSideEffects: [\n 'zone.js/node',\n 'zone.js/fesm2015/zone-node',\n ...(nitroConfig.moduleSideEffects ?? []),\n ],\n handlers: [...pageHandlers, ...serverFnHandlers],\n };\n }\n }\n\n nitroConfig = mergeConfig(\n nitroConfig,\n nitroOptions as Record<string, any>,\n );\n\n i18nWorkers = false;\n if (\n isBuild &&\n options?.i18n &&\n options.i18n.workers !== false &&\n (options.i18n.loader || options.i18n.workers === true)\n ) {\n const resolvedNitro = await loadOptions({\n dev: false,\n preset: process.env['BUILD_PRESET'],\n ...nitroConfig,\n });\n i18nWorkers = resolveI18nWorkers(options, resolvedNitro);\n nitroConfig.preset = resolvedNitro.preset;\n }\n\n return {\n define: {\n ANALOG_I18N_FIXED_LOCALE: i18nWorkers\n ? 'globalThis.process.env.ANALOG_I18N_LOCALE'\n : 'undefined',\n },\n environments: {\n client: {\n build: {\n outDir:\n config?.build?.outDir ||\n resolve(workspaceRoot, 'dist', rootDir, 'client'),\n },\n },\n ssr: {\n consumer: 'server',\n build: {\n ssr: true,\n rollupOptions: {\n input: i18nWorkers\n ? { 'main.server': I18N_WORKER_SSR_ENTRY }\n : options?.entryServer ||\n resolve(\n workspaceRoot,\n rootDir,\n `${sourceRoot}/main.server.ts`,\n ),\n },\n outDir:\n options?.ssrBuildDir ||\n resolve(workspaceRoot, 'dist', rootDir, 'ssr'),\n },\n },\n },\n builder: {\n sharedPlugins: true,\n buildApp: async (builder) => {\n environmentBuild = true;\n const builds = [builder.build(builder.environments['client'])];\n\n if (options?.ssr || nitroConfig.prerender?.routes?.length) {\n builds.push(builder.build(builder.environments['ssr']));\n }\n\n await Promise.all(builds);\n\n let ssrEntryPath = resolve(\n options?.ssrBuildDir ||\n resolve(workspaceRoot, 'dist', rootDir, `ssr`),\n `main.server${filePrefix ? '.js' : ''}`,\n );\n\n // add check for main.server.mjs fallback on Windows\n if (isWindows && !existsSync(ssrEntryPath)) {\n ssrEntryPath = ssrEntryPath.replace('.js', '.mjs');\n }\n\n const ssrEntry = normalizePath(filePrefix + ssrEntryPath);\n\n nitroConfig.alias = {\n ...nitroConfig.alias,\n '#analog/ssr': ssrEntry,\n };\n\n await buildServer(\n options,\n nitroConfig,\n routeSourceFiles,\n i18nWorkers,\n );\n\n if (\n nitroConfig.prerender?.routes?.length &&\n options?.prerender?.sitemap\n ) {\n const publicDir = nitroConfig.output?.publicDir;\n if (!publicDir) {\n throw new Error(\n 'Nitro public output directory is required to build the sitemap.',\n );\n }\n\n console.log('Building Sitemap...');\n // sitemap needs to be built after all directories are built\n await buildSitemap(\n config,\n options.prerender.sitemap,\n nitroConfig.prerender.routes,\n publicDir,\n routeSitemaps,\n options.i18n,\n );\n }\n\n console.log(\n `\\n\\nThe '@analogjs/platform' server has been successfully built.`,\n );\n },\n },\n };\n },\n async configureServer(viteServer: ViteDevServer) {\n if (isServe && !isTest) {\n const nitro = await createNitro({\n dev: true,\n ...nitroConfig,\n });\n const server = createDevServer(nitro);\n await build(nitro);\n const apiHandler = toNodeListener(server.app as unknown as App);\n\n // Server functions dispatch through `/_analog/fn/:id`, outside the\n // API prefix the Nitro dev server is mounted under, so route them\n // explicitly — otherwise a call falls through to the SSR catch-all\n // and the client gets HTML back instead of its result.\n if (hasServerFns) {\n viteServer.middlewares.use(\n (\n req: IncomingMessage,\n res: ServerResponse,\n next: (error?: unknown) => void,\n ) => {\n if (req.url?.startsWith(SERVER_FN_DISPATCH_PREFIX)) {\n apiHandler(req, res);\n return;\n }\n\n next();\n },\n );\n }\n\n viteServer.middlewares.use(\n (\n req: IncomingMessage,\n res: ServerResponse,\n next: (error?: unknown) => void,\n ) => {\n if (req.url?.startsWith(`${prefix}${apiPrefix}`)) {\n apiHandler(req, res);\n return;\n }\n\n next();\n },\n );\n\n // handle upgrades if websockets are enabled\n if (nitroOptions?.experimental?.websocket) {\n viteServer.httpServer?.on('upgrade', server.upgrade);\n }\n\n console.log(\n `\\n\\nThe server endpoints are accessible under the \"${prefix}${apiPrefix}\" path.`,\n );\n }\n },\n\n async closeBundle() {\n // Skip when build is triggered by the Environment API\n if (environmentBuild) {\n return;\n }\n\n if (ssrBuild) {\n return;\n }\n\n if (isBuild) {\n if (options?.ssr) {\n console.log('Building SSR application...');\n await buildSSRApp(config, options, i18nWorkers);\n }\n\n if (\n nitroConfig.prerender?.routes?.length &&\n options?.prerender?.sitemap\n ) {\n console.log('Building Sitemap...');\n // sitemap needs to be built after all directories are built\n await buildSitemap(\n config,\n options.prerender.sitemap,\n nitroConfig.prerender.routes,\n clientOutputPath,\n routeSitemaps,\n options.i18n,\n );\n }\n\n let ssrEntryPath = resolve(\n options?.ssrBuildDir ||\n resolve(workspaceRoot, 'dist', rootDir, `ssr`),\n `main.server${filePrefix ? '.js' : ''}`,\n );\n\n // add check for main.server.mjs fallback on Windows\n if (isWindows && !existsSync(ssrEntryPath)) {\n ssrEntryPath = ssrEntryPath.replace('.js', '.mjs');\n }\n\n const ssrEntry = normalizePath(filePrefix + ssrEntryPath);\n\n nitroConfig.alias = {\n ...nitroConfig.alias,\n '#analog/ssr': ssrEntry,\n };\n\n await buildServer(\n options,\n nitroConfig,\n routeSourceFiles,\n i18nWorkers,\n );\n\n console.log(\n `\\n\\nThe '@analogjs/platform' server has been successfully built.`,\n );\n }\n },\n },\n {\n name: 'analog-i18n-worker-entry',\n apply: 'build' as const,\n resolveId(id: string) {\n return id === I18N_WORKER_SSR_ENTRY && options?.i18n?.loader\n ? '\\0' + id\n : undefined;\n },\n load(id: string) {\n if (id !== '\\0' + I18N_WORKER_SSR_ENTRY || !options?.i18n?.loader)\n return;\n return i18nWorkerSsrEntry(\n normalizePath(\n resolve(\n workspaceRoot,\n rootDir,\n options.entryServer || `${sourceRoot}/main.server.ts`,\n ),\n ),\n normalizePath(resolve(workspaceRoot, rootDir, options.i18n.loader)),\n options.i18n,\n );\n },\n },\n devServerPlugin(() => ({\n ...options,\n routeRules: nitroOptions?.routeRules,\n })),\n {\n name: '@analogjs/vite-plugin-nitro-api-prefix',\n config() {\n return {\n define: {\n ANALOG_API_PREFIX: `\"${baseURL.substring(1)}${apiPrefix.substring(1)}\"`,\n ...(options?.i18n\n ? {\n ANALOG_I18N_DEFAULT_LOCALE: JSON.stringify(\n options.i18n.defaultLocale,\n ),\n ANALOG_I18N_LOCALES: JSON.stringify(options.i18n.locales),\n }\n : {}),\n },\n };\n },\n },\n ];\n}\n\nfunction isEmptyPrerenderRoutes(options?: Options): boolean {\n if (!options || isArrayWithElements(options?.prerender?.routes)) {\n return false;\n }\n return !options.prerender?.routes;\n}\n\nfunction isArrayWithElements<T>(arr: unknown): arr is [T, ...T[]] {\n return !!(Array.isArray(arr) && arr.length);\n}\n\nconst isVercelPreset = (buildPreset: string | undefined) =>\n process.env['VERCEL'] ||\n (buildPreset && buildPreset.toLowerCase().includes('vercel'));\n\nconst withVercelOutputAPI = (\n nitroConfig: NitroConfig | undefined,\n workspaceRoot: string,\n) => ({\n ...nitroConfig,\n output: {\n ...nitroConfig?.output,\n dir: normalizePath(resolve(workspaceRoot, '.vercel', 'output')),\n publicDir: normalizePath(\n resolve(workspaceRoot, '.vercel', 'output/static'),\n ),\n },\n});\n\nconst isCloudflarePreset = (buildPreset: string | undefined) =>\n process.env['CF_PAGES'] ||\n (buildPreset && buildPreset.toLowerCase().includes('cloudflare-pages'));\n\nconst withCloudflareOutput = (nitroConfig: NitroConfig | undefined) => ({\n ...nitroConfig,\n output: {\n ...nitroConfig?.output,\n serverDir: '{{ output.publicDir }}/_worker.js',\n },\n});\n\nconst isFirebaseAppHosting = () => !!process.env['NG_BUILD_LOGS_JSON'];\nconst withAppHostingOutput = (nitroConfig: NitroConfig) => {\n let hasOutput = false;\n\n return <NitroConfig>{\n ...nitroConfig,\n serveStatic: true,\n rollupConfig: {\n ...nitroConfig.rollupConfig,\n output: {\n ...nitroConfig.rollupConfig?.output,\n entryFileNames: 'server.mjs',\n },\n },\n hooks: {\n ...nitroConfig.hooks,\n compiled: () => {\n if (!hasOutput) {\n const buildOutput = {\n errors: [],\n warnings: [],\n outputPaths: {\n root: pathToFileURL(`${nitroConfig.output?.dir}`),\n browser: pathToFileURL(`${nitroConfig.output?.publicDir}`),\n server: pathToFileURL(`${nitroConfig.output?.dir}/server`),\n },\n };\n\n // Log the build output for Firebase App Hosting to pick up\n console.log(JSON.stringify(buildOutput, null, 2));\n hasOutput = true;\n }\n },\n },\n };\n};\n\nfunction resolveServerFnAppConfigModule(\n workspaceRoot: string,\n rootDir: string,\n sourceRoot: string,\n): string | undefined {\n // The app's server config (the one `main.server.ts` renders with), exporting\n // `config`. Server-function handlers bootstrap against it, so they resolve the\n // same DI as SSR with no separate provider list to maintain.\n const root = normalizePath(resolve(workspaceRoot, rootDir));\n const candidates = [\n `${root}/${sourceRoot}/app/app.config.server.ts`,\n `${root}/${sourceRoot}/app.config.server.ts`,\n ];\n return candidates.find((candidate) => existsSync(candidate));\n}\n\nconst isNetlifyPreset = (buildPreset: string | undefined) =>\n process.env['NETLIFY'] ||\n (buildPreset && buildPreset.toLowerCase().includes('netlify'));\n\nconst withNetlifyOutputAPI = (\n nitroConfig: NitroConfig | undefined,\n workspaceRoot: string,\n) => ({\n ...nitroConfig,\n output: {\n ...nitroConfig?.output,\n dir: normalizePath(resolve(workspaceRoot, 'netlify/functions')),\n },\n});\n\n/**\n * Reads the options passed to `analog()` from `@analogjs/platform`, which\n * exposes them on its plugin `api`.\n */\nfunction getAnalogOptions(userConfig: UserConfig): Options | undefined {\n const plugins = ((userConfig.plugins ?? []) as unknown[]).flat(Infinity) as (\n | { api?: { analogOptions?: Options } }\n | null\n | undefined\n )[];\n return plugins.find((plugin) => plugin?.api?.analogOptions)?.api\n ?.analogOptions;\n}\n\n/**\n * Stamps `ssr: false` and `streaming: false` route rules as response headers,\n * which the renderers read to skip SSR or streaming for matching routes.\n */\nfunction withAnalogRouteRuleHeaders(nitroOptions: NitroConfig): NitroConfig {\n if (!nitroOptions.routeRules) {\n return nitroOptions;\n }\n\n const routeRules = Object.fromEntries(\n Object.entries(nitroOptions.routeRules).map(([route, rule]) => [\n route,\n {\n ...rule,\n headers: {\n ...rule.headers,\n ...(rule.ssr === false ? { 'x-analog-no-ssr': 'true' } : {}),\n ...(rule.streaming === false\n ? { 'x-analog-no-streaming': 'true' }\n : {}),\n },\n },\n ]),\n );\n\n return { ...nitroOptions, routeRules };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqDA,IAAM,YAAY,SAAS,MAAM;AACjC,IAAM,aAAa,YAAY,aAAa;AAC5C,IAAI,mBAAmB;AAEvB,IAAM,aAAa,cAAc,YAAY,GAAG;AAC9B,QAAQ,UAAU;AAUpC,SAAg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4BACtB,GAAG,KAAK,GAAG,WAAW,sBAEjB,CAAA,CAAW,MAAM,cAAc,WAAW,SAAS,CAAC;AAC7D;AAEA,IAAM,mBAAmB,gBACvB,QAAQ,IAAI,cACX,eAAe,YAAY,YAAY,CAAC,CAAC,SAAS,SAAS;AAE9D,IAAM,wBACJ,aACA,mBACI;CACJ,GAAG;CACH,QAAQ;EACN,GAAG,aAAa;EAChB,KAAK,cAAc,QAAQ,eAAe,mBAAmB,CAAC;CAChE;AACF;;;;;AAMA,SAAS,iBAAiB,YAA6C;CAMrE,QALkB,WAAW,WAAW,CAAC,EAAA,CAAiB,KAAK,QAKxD,CAAA,CAAQ,MAAM,WAAW,QAAQ,KAAK,aAAa,CAAC,EAAE,KACzD;AACN;;;;;AAMA,SAAS,2BAA2B,cAAwC;CAC1E,IAAI,CAAC,aAAa,YAChB,OAAO;CAGT,MAAM,aAAa,OAAO,YACxB,OAAO,QAAQ,aAAa,UAAU,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAC7D,OACA;EACE,GAAG;EACH,SAAS;GACP,GAAG,KAAK;GACR,GAAI,KAAK,QAAQ,QAAQ,EAAE,mBAAmB,OAAO,IAAI,CAAC;GAC1D,GAAI,KAAK,cAAc,QACnB,EAAE,yBAAyB,OAAO,IAClC,CAAC;EACP;CACF,CACF,CAAC,CACH;CAEA,OAAO;EAAE,GAAG;EAAc;CAAW;AACvC"}
|
|
1
|
+
{"version":3,"file":"vite-plugin-nitro.js","names":[],"sources":["../../../src/lib/vite-plugin-nitro.ts"],"sourcesContent":["import {\n NitroConfig,\n build,\n createDevServer,\n createNitro,\n loadOptions,\n} from 'nitropack';\nimport { App, toNodeListener } from 'h3';\nimport type { Plugin, UserConfig, ViteDevServer } from 'vite';\nimport { mergeConfig, normalizePath } from 'vite';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { platform } from 'node:os';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { existsSync, readFileSync } from 'node:fs';\n\nimport { buildServer } from './build-server.js';\nimport { buildSSRApp } from './build-ssr.js';\nimport {\n I18N_WORKER_SSR_ENTRY,\n i18nWorkerSsrEntry,\n resolveI18nWorkers,\n} from './utils/i18n-workers.js';\nimport {\n Options,\n PrerenderContentDir,\n PrerenderContentFile,\n PrerenderRouteConfig,\n PrerenderSitemapConfig,\n} from './options.js';\nimport { pageEndpointsPlugin } from './plugins/page-endpoints.js';\nimport { serverFnIdPlugin } from './plugins/server-fn-id-plugin.js';\nimport { getPageHandlers } from './utils/get-page-handlers.js';\nimport { getServerFnHandlers } from './utils/get-server-fn-handlers.js';\nimport {\n buildServerFnDispatchModule,\n getServerFnDispatchHandler,\n SERVER_FN_DISPATCH_PREFIX,\n SERVER_FN_DISPATCH_VIRTUAL,\n} from './utils/server-fn-endpoints.js';\nimport { buildSitemap } from './build-sitemap.js';\nimport { devServerPlugin } from './plugins/dev-server-plugin.js';\nimport { getMatchingContentFilesWithFrontMatter } from './utils/get-content-files.js';\nimport { IncomingMessage, ServerResponse } from 'node:http';\nimport {\n ssrRenderer,\n ssrStreamRenderer,\n clientRenderer,\n} from './utils/renderers.js';\nimport {\n expandRoutesWithLocales,\n createI18nPostRenderingHook,\n} from './utils/i18n-prerender.js';\n\nconst isWindows = platform() === 'win32';\nconst filePrefix = isWindows ? 'file:///' : '';\nlet clientOutputPath = '';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nexport interface NitroPluginOptions extends NitroConfig {\n /**\n * Analog options for apps that don't use `analog()` from\n * `@analogjs/platform`. They override the options passed to `analog()`.\n */\n analog?: Options;\n}\n\nexport function nitro(pluginOptions: NitroPluginOptions = {}): Plugin[] {\n // Nitro's `static` means the same as Analog's: prerender without a server.\n const { analog, static: isStatic, ...pluginNitroOptions } = pluginOptions;\n const nitroOptions = withAnalogRouteRuleHeaders(pluginNitroOptions);\n let options: Options | undefined;\n let workspaceRoot = process.cwd();\n let sourceRoot = 'src';\n let isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const baseURL = process.env['NITRO_APP_BASE_URL'] || '';\n const prefix = baseURL ? baseURL.substring(0, baseURL.length - 1) : '';\n let apiPrefix = '/api';\n\n let i18nWorkers = false;\n let isBuild = false;\n let isServe = false;\n let ssrBuild = false;\n let config: UserConfig;\n let nitroConfig: NitroConfig;\n let environmentBuild = false;\n let hasServerFns = false;\n const routeSitemaps: Record<\n string,\n PrerenderSitemapConfig | (() => PrerenderSitemapConfig)\n > = {};\n const routeSourceFiles: Record<string, string> = {};\n let rootDir = workspaceRoot;\n\n // Options passed to `analog()` are the defaults, so an Analog app configures\n // SSR, prerendering and API routes in one place.\n function resolveOptions(userConfig: UserConfig) {\n options = {\n ...getAnalogOptions(userConfig),\n ...(isStatic === undefined ? {} : { static: isStatic }),\n ...analog,\n };\n workspaceRoot = options.workspaceRoot ?? process.cwd();\n sourceRoot = options.sourceRoot ?? 'src';\n apiPrefix = `/${options.apiPrefix || 'api'}`;\n }\n\n return [\n {\n name: '@analogjs/vite-plugin-nitro',\n async config(userConfig, { mode, command }) {\n resolveOptions(userConfig);\n isServe = command === 'serve';\n isBuild = command === 'build';\n ssrBuild = userConfig.build?.ssr === true;\n config = userConfig;\n isTest = isTest ? isTest : mode === 'test';\n\n rootDir = relative(workspaceRoot, config.root || '.') || '.';\n const buildPreset =\n process.env['BUILD_PRESET'] ??\n (nitroOptions?.preset as string | undefined);\n\n const pageHandlers = getPageHandlers({\n workspaceRoot,\n sourceRoot,\n rootDir,\n additionalPagesDirs: options?.additionalPagesDirs,\n apiPrefix,\n });\n\n // Server functions: discover every `*.server.ts` module, then register a\n // single `/_analog/fn/:id` dispatch handler backed by a generated Nitro\n // virtual module that imports those modules (registration side-effects)\n // and the app provider set. Only wired when server functions exist.\n const serverFnModules = getServerFnHandlers({\n workspaceRoot,\n sourceRoot,\n rootDir,\n additionalServerFnDirs: options?.additionalServerFnDirs,\n });\n const serverFnAppConfigModule = resolveServerFnAppConfigModule(\n workspaceRoot,\n rootDir,\n sourceRoot,\n );\n hasServerFns = serverFnModules.length > 0;\n const serverFnHandlers = hasServerFns\n ? [getServerFnDispatchHandler()]\n : [];\n const serverFnVirtual =\n serverFnModules.length > 0\n ? {\n [SERVER_FN_DISPATCH_VIRTUAL]: buildServerFnDispatchModule({\n modules: serverFnModules,\n appConfigModule: serverFnAppConfigModule,\n root: resolve(workspaceRoot, rootDir),\n }),\n }\n : {};\n\n nitroConfig = {\n rootDir,\n preset: buildPreset,\n compatibilityDate: '2024-11-19',\n logLevel: nitroOptions?.logLevel || 0,\n srcDir: normalizePath(`${sourceRoot}/server`),\n scanDirs: [\n normalizePath(`${rootDir}/${sourceRoot}/server`),\n ...(options?.additionalAPIDirs || []).map((dir) =>\n normalizePath(`${workspaceRoot}${dir}`),\n ),\n ],\n output: {\n dir: normalizePath(\n resolve(workspaceRoot, 'dist', rootDir, 'analog'),\n ),\n publicDir: normalizePath(\n resolve(workspaceRoot, 'dist', rootDir, 'analog/public'),\n ),\n },\n buildDir: normalizePath(\n resolve(workspaceRoot, 'dist', rootDir, '.nitro'),\n ),\n typescript: {\n generateTsConfig: false,\n },\n runtimeConfig: {\n apiPrefix: apiPrefix.substring(1),\n prefix,\n },\n // Fixes support for Rolldown\n imports: {\n autoImport: false,\n },\n // The dispatch module's imports are all bare side-effect imports —\n // the JIT compiler it needs, and each `*.server.ts` whose import is\n // what registers its functions. Nitro treeshakes those away unless\n // the modules are declared side-effectful, which would leave every\n // call 404ing against an empty registry.\n ...(hasServerFns\n ? {\n moduleSideEffects: [\n '@angular/compiler',\n ...serverFnModules.map((m) => normalizePath(m.file)),\n ],\n }\n : {}),\n rollupConfig: {\n onwarn(warning) {\n if (\n warning.message.includes('empty chunk') &&\n warning.message.endsWith('.server')\n ) {\n return;\n }\n },\n plugins: [\n pageEndpointsPlugin(),\n serverFnIdPlugin(normalizePath(resolve(workspaceRoot, rootDir))),\n ],\n },\n handlers: [...pageHandlers, ...serverFnHandlers],\n virtual: {\n '#ANALOG_SSR_RENDERER': options?.experimental?.streaming\n ? ssrStreamRenderer\n : ssrRenderer,\n '#ANALOG_CLIENT_RENDERER': clientRenderer,\n ...serverFnVirtual,\n },\n };\n\n if (isVercelPreset(buildPreset)) {\n nitroConfig = withVercelOutputAPI(nitroConfig, workspaceRoot);\n }\n\n if (isCloudflarePreset(buildPreset)) {\n nitroConfig = withCloudflareOutput(nitroConfig);\n }\n\n if (\n isNetlifyPreset(buildPreset) &&\n rootDir === '.' &&\n !existsSync(resolve(workspaceRoot, 'netlify.toml'))\n ) {\n nitroConfig = withNetlifyOutputAPI(nitroConfig, workspaceRoot);\n }\n\n if (isFirebaseAppHosting()) {\n nitroConfig = withAppHostingOutput(nitroConfig);\n }\n\n if (!ssrBuild && !isTest) {\n // store the client output path for the SSR build config\n clientOutputPath = resolve(\n workspaceRoot,\n rootDir,\n config.build?.outDir || 'dist/client',\n );\n }\n\n const indexEntry = normalizePath(\n resolve(clientOutputPath, 'index.html'),\n );\n nitroConfig.alias = {\n '#analog/index': indexEntry,\n };\n\n if (isBuild) {\n nitroConfig.publicAssets = [{ dir: clientOutputPath }];\n nitroConfig.renderer = options?.ssr\n ? '#ANALOG_SSR_RENDERER'\n : '#ANALOG_CLIENT_RENDERER';\n\n if (isEmptyPrerenderRoutes(options)) {\n nitroConfig.prerender = {};\n nitroConfig.prerender.routes = ['/'];\n }\n\n if (options?.prerender) {\n nitroConfig.prerender = nitroConfig.prerender ?? {};\n nitroConfig.prerender.crawlLinks = options?.prerender?.discover;\n\n let routes: (\n | string\n | PrerenderContentDir\n | PrerenderRouteConfig\n | undefined\n )[] = [];\n\n const prerenderRoutes = options?.prerender?.routes;\n if (\n isArrayWithElements<string | PrerenderContentDir>(prerenderRoutes)\n ) {\n routes = prerenderRoutes;\n } else if (typeof prerenderRoutes === 'function') {\n routes = await prerenderRoutes();\n }\n\n nitroConfig.prerender.routes = routes.reduce<string[]>(\n (prev, current) => {\n if (!current) {\n return prev;\n }\n if (typeof current === 'string') {\n prev.push(current);\n return prev;\n }\n\n if ('route' in current) {\n if (current.sitemap) {\n routeSitemaps[current.route] = current.sitemap;\n }\n\n if (current.outputSourceFile) {\n const sourcePath = resolve(\n workspaceRoot,\n rootDir,\n current.outputSourceFile,\n );\n routeSourceFiles[current.route] = readFileSync(\n sourcePath,\n 'utf8',\n );\n }\n\n prev.push(current.route);\n\n // Add the server-side data fetching endpoint URL\n if ('staticData' in current) {\n prev.push(`${apiPrefix}/_analog/pages/${current.route}`);\n }\n\n return prev;\n }\n\n const affectedFiles: PrerenderContentFile[] =\n getMatchingContentFilesWithFrontMatter(\n workspaceRoot,\n rootDir,\n current.contentDir,\n current.recursive,\n );\n\n affectedFiles.forEach((f) => {\n const result = current.transform(f);\n\n if (result) {\n if (current.sitemap) {\n routeSitemaps[result] =\n current.sitemap && typeof current.sitemap === 'function'\n ? current.sitemap?.(f)\n : current.sitemap;\n }\n\n if (current.outputSourceFile) {\n const sourceContent = current.outputSourceFile(f);\n if (sourceContent) {\n routeSourceFiles[result] = sourceContent;\n }\n }\n\n prev.push(result);\n\n // Add the server-side data fetching endpoint URL\n if ('staticData' in current) {\n prev.push(`${apiPrefix}/_analog/pages/${result}`);\n }\n }\n });\n\n return prev;\n },\n [],\n );\n\n // Expand routes with locale prefixes when i18n is configured\n if (options?.i18n && nitroConfig.prerender?.routes) {\n nitroConfig.prerender.routes = expandRoutesWithLocales(\n nitroConfig.prerender.routes.filter(Boolean) as string[],\n options.i18n,\n apiPrefix,\n );\n }\n }\n\n // Register i18n post-rendering hook for lang attribute injection\n if (options?.i18n) {\n options.prerender = options.prerender ?? {};\n options.prerender.postRenderingHooks =\n options.prerender.postRenderingHooks ?? [];\n options.prerender.postRenderingHooks.push(\n createI18nPostRenderingHook(options.i18n),\n );\n }\n\n if (ssrBuild) {\n if (isWindows) {\n nitroConfig.externals = {\n inline: ['std-env'],\n };\n }\n\n nitroConfig = {\n ...nitroConfig,\n externals: {\n ...nitroConfig.externals,\n external: ['rxjs', 'node-fetch-native/dist/polyfill'],\n },\n moduleSideEffects: [\n 'zone.js/node',\n 'zone.js/fesm2015/zone-node',\n ...(nitroConfig.moduleSideEffects ?? []),\n ],\n handlers: [...pageHandlers, ...serverFnHandlers],\n };\n }\n }\n\n nitroConfig = mergeConfig(\n nitroConfig,\n nitroOptions as Record<string, any>,\n );\n\n i18nWorkers = false;\n if (\n isBuild &&\n options?.i18n &&\n options.i18n.workers !== false &&\n (options.i18n.loader || options.i18n.workers === true)\n ) {\n const resolvedNitro = await loadOptions({\n dev: false,\n preset: process.env['BUILD_PRESET'],\n ...nitroConfig,\n });\n i18nWorkers = resolveI18nWorkers(options, resolvedNitro);\n nitroConfig.preset = resolvedNitro.preset;\n }\n\n return {\n define: {\n ANALOG_I18N_FIXED_LOCALE: i18nWorkers\n ? 'globalThis.process.env.ANALOG_I18N_LOCALE'\n : 'undefined',\n },\n environments: {\n client: {\n build: {\n outDir:\n config?.build?.outDir ||\n resolve(workspaceRoot, 'dist', rootDir, 'client'),\n },\n },\n ssr: {\n consumer: 'server',\n build: {\n ssr: true,\n rollupOptions: {\n input: i18nWorkers\n ? { 'main.server': I18N_WORKER_SSR_ENTRY }\n : options?.entryServer ||\n resolve(\n workspaceRoot,\n rootDir,\n `${sourceRoot}/main.server.ts`,\n ),\n },\n outDir:\n options?.ssrBuildDir ||\n resolve(workspaceRoot, 'dist', rootDir, 'ssr'),\n },\n },\n },\n builder: {\n sharedPlugins: true,\n buildApp: async (builder) => {\n environmentBuild = true;\n const builds = [builder.build(builder.environments['client'])];\n\n if (options?.ssr || nitroConfig.prerender?.routes?.length) {\n builds.push(builder.build(builder.environments['ssr']));\n }\n\n await Promise.all(builds);\n\n let ssrEntryPath = resolve(\n options?.ssrBuildDir ||\n resolve(workspaceRoot, 'dist', rootDir, `ssr`),\n `main.server${filePrefix ? '.js' : ''}`,\n );\n\n // add check for main.server.mjs fallback on Windows\n if (isWindows && !existsSync(ssrEntryPath)) {\n ssrEntryPath = ssrEntryPath.replace('.js', '.mjs');\n }\n\n const ssrEntry = normalizePath(filePrefix + ssrEntryPath);\n\n nitroConfig.alias = {\n ...nitroConfig.alias,\n '#analog/ssr': ssrEntry,\n };\n\n await buildServer(\n options,\n nitroConfig,\n routeSourceFiles,\n i18nWorkers,\n );\n\n if (\n nitroConfig.prerender?.routes?.length &&\n options?.prerender?.sitemap\n ) {\n const publicDir = nitroConfig.output?.publicDir;\n if (!publicDir) {\n throw new Error(\n 'Nitro public output directory is required to build the sitemap.',\n );\n }\n\n console.log('Building Sitemap...');\n // sitemap needs to be built after all directories are built\n await buildSitemap(\n config,\n options.prerender.sitemap,\n nitroConfig.prerender.routes,\n publicDir,\n routeSitemaps,\n options.i18n,\n );\n }\n\n console.log(\n `\\n\\nThe '@analogjs/platform' server has been successfully built.`,\n );\n },\n },\n };\n },\n async configureServer(viteServer: ViteDevServer) {\n if (isServe && !isTest) {\n const nitro = await createNitro({\n dev: true,\n ...nitroConfig,\n });\n const server = createDevServer(nitro);\n await build(nitro);\n const apiHandler = toNodeListener(server.app as unknown as App);\n\n // Server functions dispatch through `/_analog/fn/:id`, outside the\n // API prefix the Nitro dev server is mounted under, so route them\n // explicitly — otherwise a call falls through to the SSR catch-all\n // and the client gets HTML back instead of its result.\n if (hasServerFns) {\n viteServer.middlewares.use(\n (\n req: IncomingMessage,\n res: ServerResponse,\n next: (error?: unknown) => void,\n ) => {\n if (req.url?.startsWith(SERVER_FN_DISPATCH_PREFIX)) {\n apiHandler(req, res);\n return;\n }\n\n next();\n },\n );\n }\n\n viteServer.middlewares.use(\n (\n req: IncomingMessage,\n res: ServerResponse,\n next: (error?: unknown) => void,\n ) => {\n if (req.url?.startsWith(`${prefix}${apiPrefix}`)) {\n apiHandler(req, res);\n return;\n }\n\n next();\n },\n );\n\n // handle upgrades if websockets are enabled\n if (nitroOptions?.experimental?.websocket) {\n viteServer.httpServer?.on('upgrade', server.upgrade);\n }\n\n console.log(\n `\\n\\nThe server endpoints are accessible under the \"${prefix}${apiPrefix}\" path.`,\n );\n }\n },\n\n async closeBundle() {\n // Skip when build is triggered by the Environment API\n if (environmentBuild) {\n return;\n }\n\n if (ssrBuild) {\n return;\n }\n\n if (isBuild) {\n if (options?.ssr) {\n console.log('Building SSR application...');\n await buildSSRApp(config, options, i18nWorkers);\n }\n\n if (\n nitroConfig.prerender?.routes?.length &&\n options?.prerender?.sitemap\n ) {\n console.log('Building Sitemap...');\n // sitemap needs to be built after all directories are built\n await buildSitemap(\n config,\n options.prerender.sitemap,\n nitroConfig.prerender.routes,\n clientOutputPath,\n routeSitemaps,\n options.i18n,\n );\n }\n\n let ssrEntryPath = resolve(\n options?.ssrBuildDir ||\n resolve(workspaceRoot, 'dist', rootDir, `ssr`),\n `main.server${filePrefix ? '.js' : ''}`,\n );\n\n // add check for main.server.mjs fallback on Windows\n if (isWindows && !existsSync(ssrEntryPath)) {\n ssrEntryPath = ssrEntryPath.replace('.js', '.mjs');\n }\n\n const ssrEntry = normalizePath(filePrefix + ssrEntryPath);\n\n nitroConfig.alias = {\n ...nitroConfig.alias,\n '#analog/ssr': ssrEntry,\n };\n\n await buildServer(\n options,\n nitroConfig,\n routeSourceFiles,\n i18nWorkers,\n );\n\n console.log(\n `\\n\\nThe '@analogjs/platform' server has been successfully built.`,\n );\n }\n },\n },\n {\n name: 'analog-i18n-worker-entry',\n apply: 'build' as const,\n resolveId(id: string) {\n return id === I18N_WORKER_SSR_ENTRY && options?.i18n?.loader\n ? '\\0' + id\n : undefined;\n },\n load(id: string) {\n if (id !== '\\0' + I18N_WORKER_SSR_ENTRY || !options?.i18n?.loader)\n return;\n return i18nWorkerSsrEntry(\n normalizePath(\n resolve(\n workspaceRoot,\n rootDir,\n options.entryServer || `${sourceRoot}/main.server.ts`,\n ),\n ),\n normalizePath(resolve(workspaceRoot, rootDir, options.i18n.loader)),\n options.i18n,\n );\n },\n },\n devServerPlugin(() => ({\n ...options,\n routeRules: nitroOptions?.routeRules,\n })),\n {\n name: '@analogjs/vite-plugin-nitro-api-prefix',\n config() {\n return {\n define: {\n ANALOG_API_PREFIX: `\"${baseURL.substring(1)}${apiPrefix.substring(1)}\"`,\n ...(options?.i18n\n ? {\n ANALOG_I18N_DEFAULT_LOCALE: JSON.stringify(\n options.i18n.defaultLocale,\n ),\n ANALOG_I18N_LOCALES: JSON.stringify(options.i18n.locales),\n }\n : {}),\n },\n };\n },\n },\n ];\n}\n\nfunction isEmptyPrerenderRoutes(options?: Options): boolean {\n if (!options || isArrayWithElements(options?.prerender?.routes)) {\n return false;\n }\n return !options.prerender?.routes;\n}\n\nfunction isArrayWithElements<T>(arr: unknown): arr is [T, ...T[]] {\n return !!(Array.isArray(arr) && arr.length);\n}\n\nconst isVercelPreset = (buildPreset: string | undefined) =>\n process.env['VERCEL'] ||\n (buildPreset && buildPreset.toLowerCase().includes('vercel'));\n\nconst withVercelOutputAPI = (\n nitroConfig: NitroConfig | undefined,\n workspaceRoot: string,\n) => ({\n ...nitroConfig,\n output: {\n ...nitroConfig?.output,\n dir: normalizePath(resolve(workspaceRoot, '.vercel', 'output')),\n publicDir: normalizePath(\n resolve(workspaceRoot, '.vercel', 'output/static'),\n ),\n },\n});\n\nconst isCloudflarePreset = (buildPreset: string | undefined) =>\n process.env['CF_PAGES'] ||\n (buildPreset && buildPreset.toLowerCase().includes('cloudflare-pages'));\n\nconst withCloudflareOutput = (nitroConfig: NitroConfig | undefined) => ({\n ...nitroConfig,\n output: {\n ...nitroConfig?.output,\n serverDir: '{{ output.publicDir }}/_worker.js',\n },\n});\n\nconst isFirebaseAppHosting = () => !!process.env['NG_BUILD_LOGS_JSON'];\nconst withAppHostingOutput = (nitroConfig: NitroConfig) => {\n let hasOutput = false;\n\n return <NitroConfig>{\n ...nitroConfig,\n serveStatic: true,\n rollupConfig: {\n ...nitroConfig.rollupConfig,\n output: {\n ...nitroConfig.rollupConfig?.output,\n entryFileNames: 'server.mjs',\n },\n },\n hooks: {\n ...nitroConfig.hooks,\n compiled: () => {\n if (!hasOutput) {\n const buildOutput = {\n errors: [],\n warnings: [],\n outputPaths: {\n root: pathToFileURL(`${nitroConfig.output?.dir}`),\n browser: pathToFileURL(`${nitroConfig.output?.publicDir}`),\n server: pathToFileURL(`${nitroConfig.output?.dir}/server`),\n },\n };\n\n // Log the build output for Firebase App Hosting to pick up\n console.log(JSON.stringify(buildOutput, null, 2));\n hasOutput = true;\n }\n },\n },\n };\n};\n\nfunction resolveServerFnAppConfigModule(\n workspaceRoot: string,\n rootDir: string,\n sourceRoot: string,\n): string | undefined {\n // The app's server config (the one `main.server.ts` renders with), exporting\n // `config`. Server-function handlers bootstrap against it, so they resolve the\n // same DI as SSR with no separate provider list to maintain.\n const root = normalizePath(resolve(workspaceRoot, rootDir));\n const candidates = [\n `${root}/${sourceRoot}/app/app.config.server.ts`,\n `${root}/${sourceRoot}/app.config.server.ts`,\n ];\n return candidates.find((candidate) => existsSync(candidate));\n}\n\nconst isNetlifyPreset = (buildPreset: string | undefined) =>\n process.env['NETLIFY'] ||\n (buildPreset && buildPreset.toLowerCase().includes('netlify'));\n\nconst withNetlifyOutputAPI = (\n nitroConfig: NitroConfig | undefined,\n workspaceRoot: string,\n) => ({\n ...nitroConfig,\n output: {\n ...nitroConfig?.output,\n dir: normalizePath(resolve(workspaceRoot, 'netlify/functions')),\n },\n});\n\n/**\n * Reads the options passed to `analog()` from `@analogjs/platform`, which\n * exposes them on its plugin `api`.\n */\nfunction getAnalogOptions(userConfig: UserConfig): Options | undefined {\n const plugins = ((userConfig.plugins ?? []) as unknown[]).flat(Infinity) as (\n | { api?: { analogOptions?: Options } }\n | null\n | undefined\n )[];\n return plugins.find((plugin) => plugin?.api?.analogOptions)?.api\n ?.analogOptions;\n}\n\n/**\n * Stamps `ssr` and `streaming` route rules as response headers, which the\n * renderers read to skip SSR or streaming for matching routes. `true` rules\n * stamp `'false'` so they override a broader `false` rule.\n */\nfunction withAnalogRouteRuleHeaders(nitroOptions: NitroConfig): NitroConfig {\n if (!nitroOptions.routeRules) {\n return nitroOptions;\n }\n\n const routeRules = Object.fromEntries(\n Object.entries(nitroOptions.routeRules).map(([route, rule]) => [\n route,\n {\n ...rule,\n headers: {\n ...rule.headers,\n ...(typeof rule.ssr === 'boolean'\n ? { 'x-analog-no-ssr': String(!rule.ssr) }\n : {}),\n ...(typeof rule.streaming === 'boolean'\n ? { 'x-analog-no-streaming': String(!rule.streaming) }\n : {}),\n },\n },\n ]),\n );\n\n return { ...nitroOptions, routeRules };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqDA,IAAM,YAAY,SAAS,MAAM;AACjC,IAAM,aAAa,YAAY,aAAa;AAC5C,IAAI,mBAAmB;AAEvB,IAAM,aAAa,cAAc,YAAY,GAAG;AAC9B,QAAQ,UAAU;AAUpC,SAAgB,MAAM,gBAAoC,CAAC,GAAa;CAEtE,MAAM,EAAE,QAAQ,QAAQ,UAAU,GAAG,uBAAuB;CAC5D,MAAM,eAAe,2BAA2B,kBAAkB;CAClE,IAAI;CACJ,IAAI,gBAAgB,QAAQ,IAAI;CAChC,IAAI,aAAa;CACjB,IAAI,SAAA,QAAA,IAAA,aAAqC,UAAU,CAAC,CAAC,QAAQ,IAAI;CACjE,MAAM,UAAU,QAAQ,IAAI,yBAAyB;CACrD,MAAM,SAAS,UAAU,QAAQ,UAAU,GAAG,QAAQ,SAAS,CAAC,IAAI;CACpE,IAAI,YAAY;CAEhB,IAAI,cAAc;CAClB,IAAI,UAAU;CACd,IAAI,UAAU;CACd,IAAI,WAAW;CACf,IAAI;CACJ,IAAI;CACJ,IAAI,mBAAmB;CACvB,IAAI,eAAe;CACnB,MAAM,gBAGF,CAAC;CACL,MAAM,mBAA2C,CAAC;CAClD,IAAI,UAAU;CAId,SAAS,eAAe,YAAwB;EAC9C,UAAU;GACR,GAAG,iBAAiB,UAAU;GAC9B,GAAI,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,SAAS;GACrD,GAAG;EACL;EACA,gBAAgB,QAAQ,iBAAiB,QAAQ,IAAI;EACrD,aA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