Skip to content

Commit

Permalink
Fix backwards compat with Astro <= 4.9
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed Jun 14, 2024
1 parent 537e971 commit 5b01112
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
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

0 comments on commit 5b01112

Please sign in to comment.