Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tiny-moose-melt.md
Original file line number Diff line number Diff line change
@@ -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
9 changes: 8 additions & 1 deletion packages/astro/src/core/build/plugins/plugin-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading