0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-20 22:12:38 -05:00

Silently ignore adapters that don't export start() (#9911)

This commit is contained in:
Nate Moore 2024-01-31 13:51:56 -06:00 committed by GitHub
parent 520be8b113
commit aaedb848b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -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

View file

@ -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 {