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

Fix backwards compat with Astro <= 4.9 in Node and Vercel adapters #11261

Merged
merged 1 commit into from
Jun 14, 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
6 changes: 6 additions & 0 deletions .changeset/serious-humans-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@astrojs/vercel': patch
'@astrojs/node': patch
---

Fix backwards compat with Astro <= 4.9
7 changes: 5 additions & 2 deletions packages/integrations/node/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import { createStandaloneHandler } from './standalone.js';
import startServer from './standalone.js';
import type { Options } from './types.js';

type EnvSetupModule = typeof import('astro/env/setup');

// Won't throw if the virtual module is not available because it's not supported in
// the users's astro version or if astro:env is not enabled in the project
await import('astro/env/setup')
.then((mod) => mod.setGetEnv((key) => process.env[key]))
const setupModule = 'astro/env/setup';
await import(/* @vite-ignore */setupModule)
.then((mod: EnvSetupModule) => mod.setGetEnv((key) => process.env[key]))
.catch(() => {});

applyPolyfills();
Expand Down
7 changes: 5 additions & 2 deletions packages/integrations/vercel/src/serverless/entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import {
ASTRO_PATH_PARAM,
} from './adapter.js';

type EnvSetupModule = typeof import('astro/env/setup');

// Won't throw if the virtual module is not available because it's not supported in
// the users's astro version or if astro:env is not enabled in the project
await import('astro/env/setup')
.then((mod) => mod.setGetEnv((key) => process.env[key]))
const setupModule = 'astro/env/setup';
await import(/* @vite-ignore */setupModule)
.then((mod: EnvSetupModule) => mod.setGetEnv((key) => process.env[key]))
.catch(() => {});

applyPolyfills();
Expand Down
Loading