diff --git a/.changeset/tiny-moose-melt.md b/.changeset/tiny-moose-melt.md new file mode 100644 index 000000000000..aba946fe7021 --- /dev/null +++ b/.changeset/tiny-moose-melt.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fixes an issue where some adapters that do not include a `start()` export would error rather than silently proceed diff --git a/packages/astro/src/core/build/plugins/plugin-ssr.ts b/packages/astro/src/core/build/plugins/plugin-ssr.ts index 79bfd1ece42b..df48374fdb01 100644 --- a/packages/astro/src/core/build/plugins/plugin-ssr.ts +++ b/packages/astro/src/core/build/plugins/plugin-ssr.ts @@ -263,7 +263,14 @@ function generateSSRCode(adapter: AstroAdapter, middlewareId: string) { return `export const ${name} = _exports['${name}'];`; } }) ?? []), - `serverEntrypointModule.start?.(_manifest, _args);`, + // NOTE: This is intentionally obfuscated! + // Do NOT simplify this to something like `serverEntrypointModule.start?.(_manifest, _args)` + // They are NOT equivalent! Some bundlers will throw if `start` is not exported, but we + // only want to silently ignore it... hence the dynamic, obfuscated weirdness. + `const _start = 'start'; +if (_start in serverEntrypointModule) { + serverEntrypointModule[_start](_manifest, _args); +}`, ]; return {