diff --git a/.changeset/wet-chefs-develop.md b/.changeset/wet-chefs-develop.md new file mode 100644 index 000000000000..e2a29702bc02 --- /dev/null +++ b/.changeset/wet-chefs-develop.md @@ -0,0 +1,6 @@ +--- +'@astrojs/vercel': minor +'@astrojs/node': minor +--- + +Adds support for experimental `astro:env` released in Astro 4.10 diff --git a/packages/integrations/node/src/index.ts b/packages/integrations/node/src/index.ts index 2108ec5ca82c..5fec3850c79f 100644 --- a/packages/integrations/node/src/index.ts +++ b/packages/integrations/node/src/index.ts @@ -19,6 +19,7 @@ export function getAdapter(options: Options): AstroAdapter { isSquooshCompatible: true, }, i18nDomains: 'experimental', + envGetSecret: 'experimental', }, }; } diff --git a/packages/integrations/node/src/server.ts b/packages/integrations/node/src/server.ts index 1fb9d93e503d..e5b503292d40 100644 --- a/packages/integrations/node/src/server.ts +++ b/packages/integrations/node/src/server.ts @@ -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); diff --git a/packages/integrations/vercel/src/serverless/adapter.ts b/packages/integrations/vercel/src/serverless/adapter.ts index 1090555cc350..65f5fafd798f 100644 --- a/packages/integrations/vercel/src/serverless/adapter.ts +++ b/packages/integrations/vercel/src/serverless/adapter.ts @@ -98,6 +98,7 @@ function getAdapter({ isSquooshCompatible: true, }, i18nDomains: 'experimental', + envGetSecret: 'experimental', }, }; } diff --git a/packages/integrations/vercel/src/serverless/entrypoint.ts b/packages/integrations/vercel/src/serverless/entrypoint.ts index a8e8ebc41c9f..11d3c3a91e1d 100644 --- a/packages/integrations/vercel/src/serverless/entrypoint.ts +++ b/packages/integrations/vercel/src/serverless/entrypoint.ts @@ -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 = ( diff --git a/packages/integrations/vercel/src/static/adapter.ts b/packages/integrations/vercel/src/static/adapter.ts index d7fd57fd5379..4a66c558ef69 100644 --- a/packages/integrations/vercel/src/static/adapter.ts +++ b/packages/integrations/vercel/src/static/adapter.ts @@ -32,6 +32,7 @@ function getAdapter(): AstroAdapter { staticOutput: 'stable', serverOutput: 'unsupported', hybridOutput: 'unsupported', + envGetSecret: 'unsupported', }, adapterFeatures: { edgeMiddleware: false,