From 0962b38dc5820f7ff5e2e1ce1fb1826c9e2d7849 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Tue, 13 Aug 2024 14:24:55 +0200 Subject: [PATCH] feat: do not use TLA --- .changeset/selfish-impalas-grin.md | 4 ++-- packages/integrations/node/src/server.ts | 9 +++------ .../integrations/vercel/src/serverless/entrypoint.ts | 8 ++------ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.changeset/selfish-impalas-grin.md b/.changeset/selfish-impalas-grin.md index 2efd92b988..d2319c3d8d 100644 --- a/.changeset/selfish-impalas-grin.md +++ b/.changeset/selfish-impalas-grin.md @@ -1,6 +1,6 @@ --- -'@astrojs/vercel': minor -'@astrojs/node': minor +'@astrojs/vercel': major +'@astrojs/node': major --- Adds stable support for `astro:env` diff --git a/packages/integrations/node/src/server.ts b/packages/integrations/node/src/server.ts index e5b503292d..6bf2e22414 100644 --- a/packages/integrations/node/src/server.ts +++ b/packages/integrations/node/src/server.ts @@ -1,17 +1,14 @@ import type { SSRManifest } from 'astro'; import { NodeApp, applyPolyfills } from 'astro/app/node'; +import { setGetEnv } from 'astro/env/setup'; import createMiddleware from './middleware.js'; 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(() => {}); - +setGetEnv((key) => process.env[key]); applyPolyfills(); + export function createExports(manifest: SSRManifest, options: Options) { const app = new NodeApp(manifest); options.trailingSlash = manifest.trailingSlash; diff --git a/packages/integrations/vercel/src/serverless/entrypoint.ts b/packages/integrations/vercel/src/serverless/entrypoint.ts index 876ab6b07f..b655816e9e 100644 --- a/packages/integrations/vercel/src/serverless/entrypoint.ts +++ b/packages/integrations/vercel/src/serverless/entrypoint.ts @@ -1,6 +1,7 @@ import type { IncomingMessage, ServerResponse } from 'node:http'; import type { SSRManifest } from 'astro'; import { NodeApp, applyPolyfills } from 'astro/app/node'; +import { setGetEnv } from 'astro/env/setup'; import { ASTRO_LOCALS_HEADER, ASTRO_MIDDLEWARE_SECRET_HEADER, @@ -8,12 +9,7 @@ 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(() => {}); - +setGetEnv((key) => process.env[key]); applyPolyfills(); export const createExports = (