From 8cc7f709cdfd2c7e44660449573eeea957e58905 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 20:46:44 +0000 Subject: [PATCH] fix: enable svelte async runtime flag in build_routes.ts The compiler's `experimental: { async: true }` adds `import 'svelte/internal/flags/async'` to compiled component output, but since esbuild bundles create separate module instances, the `async_mode_flag` checked by `render()` from `svelte/server` was never set. This import enables the flag in the same Deno module context that render() uses. Agent-Logs-Url: https://github.com/mxdvl/mononykus/sessions/e79d6417-2abd-4191-bba6-cacaaed0d976 Co-authored-by: mxdvl <76776+mxdvl@users.noreply.github.com> --- src/esbuild_plugins/build_routes.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/esbuild_plugins/build_routes.ts b/src/esbuild_plugins/build_routes.ts index 6025c9a..ad74665 100644 --- a/src/esbuild_plugins/build_routes.ts +++ b/src/esbuild_plugins/build_routes.ts @@ -4,6 +4,7 @@ import { ensureDir } from "@std/fs/ensure-dir"; import { get_route_html } from "./get_route_html.ts"; import type { Component } from "svelte"; import { render as renderSSR } from "svelte/server"; +import "svelte/internal/flags/async"; const FAILURE_FLAG = ""; @@ -50,7 +51,8 @@ export const build_routes: Plugin = { const routes = result.outputFiles ?? []; - const results = await Promise.all(routes.map(async (route) => { + const failures = new Set(); + for (const route of routes) { const dist_path = route.path.replace(".js", ".html"); await ensureDir(dirname(dist_path)); @@ -61,8 +63,9 @@ export const build_routes: Plugin = { await get_route_html(template), ); - return template.html.startsWith(FAILURE_FLAG) ? dist_path : undefined; - })); + if (!template.html.startsWith(FAILURE_FLAG)) continue; + failures.add(dist_path); + } console.log( `Built ${routes.length} routes in ${ @@ -70,8 +73,7 @@ export const build_routes: Plugin = { }ms`, ); - const failures = results.filter((result) => !!result); - if (failures.length > 0) { + if (failures.size > 0) { console.warn( ["–––", "Failed to build some routes:", ...failures].join("\n"), ); -- 2.51.2