Skip to content

Commit

Permalink
feat: add support for astro:env to node and vercel (#11199)
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-lefebvre authored Jun 10, 2024
1 parent 0a6ab6f commit 2bdca27
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/wet-chefs-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@astrojs/vercel': minor
'@astrojs/node': minor
---

Adds support for experimental `astro:env` released in Astro 4.10
1 change: 1 addition & 0 deletions packages/integrations/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function getAdapter(options: Options): AstroAdapter {
isSquooshCompatible: true,
},
i18nDomains: 'experimental',
envGetSecret: 'experimental',
},
};
}
Expand Down
6 changes: 6 additions & 0 deletions packages/integrations/node/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { createStandaloneHandler } from './standalone.js';
import startServer from './standalone.js';
import type { Options } from './types.js';

// 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]))
.catch(() => {});

applyPolyfills();
export function createExports(manifest: SSRManifest, options: Options) {
const app = new NodeApp(manifest);
Expand Down
1 change: 1 addition & 0 deletions packages/integrations/vercel/src/serverless/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function getAdapter({
isSquooshCompatible: true,
},
i18nDomains: 'experimental',
envGetSecret: 'experimental',
},
};
}
Expand Down
6 changes: 6 additions & 0 deletions packages/integrations/vercel/src/serverless/entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import {
ASTRO_PATH_PARAM,
} from './adapter.js';

// 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]))
.catch(() => {});

applyPolyfills();

export const createExports = (
Expand Down
1 change: 1 addition & 0 deletions packages/integrations/vercel/src/static/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function getAdapter(): AstroAdapter {
staticOutput: 'stable',
serverOutput: 'unsupported',
hybridOutput: 'unsupported',
envGetSecret: 'unsupported',
},
adapterFeatures: {
edgeMiddleware: false,
Expand Down

0 comments on commit 2bdca27

Please sign in to comment.