diff --git a/.changeset/forty-boats-remain.md b/.changeset/forty-boats-remain.md new file mode 100644 index 000000000..1b81d9426 --- /dev/null +++ b/.changeset/forty-boats-remain.md @@ -0,0 +1,6 @@ +--- +'astro': patch +'@astrojs/vercel': patch +--- + +Allows adapters to export default diff --git a/packages/astro/src/core/build/vite-plugin-ssr.ts b/packages/astro/src/core/build/vite-plugin-ssr.ts index 93c53b99b..723703cd1 100644 --- a/packages/astro/src/core/build/vite-plugin-ssr.ts +++ b/packages/astro/src/core/build/vite-plugin-ssr.ts @@ -45,8 +45,14 @@ const _args = ${adapter.args ? JSON.stringify(adapter.args) : 'undefined'}; ${ adapter.exports ? `const _exports = adapter.createExports(_manifest, _args); -${adapter.exports.map((name) => `export const ${name} = _exports['${name}'];`).join('\n')} -${adapter.exports.includes('_default') ? `export default _default` : ''} +${adapter.exports.map((name) => { + if(name === 'default') { + return `const _default = _exports['default']; +export { _default as default };`; + } else { + return `export const ${name} = _exports['${name}'];` + } +}).join('\n')} ` : '' } diff --git a/packages/integrations/vercel/src/index.ts b/packages/integrations/vercel/src/index.ts index b780f6d37..22dbc3eef 100644 --- a/packages/integrations/vercel/src/index.ts +++ b/packages/integrations/vercel/src/index.ts @@ -13,7 +13,7 @@ export function getAdapter(): AstroAdapter { return { name: '@astrojs/vercel', serverEntrypoint: '@astrojs/vercel/server-entrypoint', - exports: ['_default'], + exports: ['default'], }; } diff --git a/packages/integrations/vercel/src/server-entrypoint.ts b/packages/integrations/vercel/src/server-entrypoint.ts index df01fe32a..1061f8eb4 100644 --- a/packages/integrations/vercel/src/server-entrypoint.ts +++ b/packages/integrations/vercel/src/server-entrypoint.ts @@ -12,7 +12,7 @@ polyfill(globalThis, { export const createExports = (manifest: SSRManifest) => { const app = new App(manifest); - const _default = async (req: IncomingMessage, res: ServerResponse) => { + const handler = async (req: IncomingMessage, res: ServerResponse) => { let request: Request; try { @@ -30,5 +30,5 @@ export const createExports = (manifest: SSRManifest) => { await setResponse(res, await app.render(request)); }; - return { _default }; + return { 'default': handler }; };