@analogjs/vite-plugin-nitro 3.0.0-beta.34 → 3.0.0-beta.36

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/vite-plugin-nitro",
3
- "version": "3.0.0-beta.34",
3
+ "version": "3.0.0-beta.36",
4
4
  "description": "A Vite plugin for adding a nitro API server",
5
5
  "type": "module",
6
6
  "author": "Brandon Roberts <robertsbt@gmail.com>",
@@ -402,8 +402,9 @@ function getAnalogOptions(userConfig) {
402
402
  return (userConfig.plugins ?? []).flat(Infinity).find((plugin) => plugin?.api?.analogOptions)?.api?.analogOptions;
403
403
  }
404
404
  /**
405
- * Stamps `ssr: false` and `streaming: false` route rules as response headers,
406
- * which the renderers read to skip SSR or streaming for matching routes.
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.
407
408
  */
408
409
  function withAnalogRouteRuleHeaders(nitroOptions) {
409
410
  if (!nitroOptions.routeRules) return nitroOptions;
@@ -411,8 +412,8 @@ function withAnalogRouteRuleHeaders(nitroOptions) {
411
412
  ...rule,
412
413
  headers: {
413
414
  ...rule.headers,
414
- ...rule.ssr === false ? { "x-analog-no-ssr": "true" } : {},
415
- ...rule.streaming === false ? { "x-analog-no-streaming": "true" } : {}
415
+ ...typeof rule.ssr === "boolean" ? { "x-analog-no-ssr": String(!rule.ssr) } : {},
416
+ ...typeof rule.streaming === "boolean" ? { "x-analog-no-streaming": String(!rule.streaming) } : {}
416
417
  }
417
418
  }]));
418
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 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 );\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,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,aAA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C7D,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 );\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;C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