diff options
author | 2024-01-31 13:51:56 -0600 | |
---|---|---|
committer | 2024-01-31 13:51:56 -0600 | |
commit | aaedb848b1d6f683840035865528506a346ea659 (patch) | |
tree | dc181dcf8e78538823d96d66d2e75274c26d6477 | |
parent | 520be8b113bbb3189033e2952b28a6cda2a676a1 (diff) | |
download | astro-aaedb848b1d6f683840035865528506a346ea659.tar.gz astro-aaedb848b1d6f683840035865528506a346ea659.tar.zst astro-aaedb848b1d6f683840035865528506a346ea659.zip |
Silently ignore adapters that don't export `start()` (#9911)
-rw-r--r-- | .changeset/tiny-moose-melt.md | 5 | ||||
-rw-r--r-- | packages/astro/src/core/build/plugins/plugin-ssr.ts | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/.changeset/tiny-moose-melt.md b/.changeset/tiny-moose-melt.md new file mode 100644 index 000000000..aba946fe7 --- /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 79bfd1ece..df48374fd 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 { |