diff options
Diffstat (limited to 'packages/integrations/node/src')
-rw-r--r-- | packages/integrations/node/src/index.ts | 35 | ||||
-rw-r--r-- | packages/integrations/node/src/middleware.ts | 1 | ||||
-rw-r--r-- | packages/integrations/node/src/polyfill.ts | 3 | ||||
-rw-r--r-- | packages/integrations/node/src/preview.ts | 1 | ||||
-rw-r--r-- | packages/integrations/node/src/server.ts | 14 |
5 files changed, 18 insertions, 36 deletions
diff --git a/packages/integrations/node/src/index.ts b/packages/integrations/node/src/index.ts index eb3c98a9b..e91ed171b 100644 --- a/packages/integrations/node/src/index.ts +++ b/packages/integrations/node/src/index.ts @@ -9,31 +9,21 @@ export function getAdapter(options: Options): AstroAdapter { previewEntrypoint: '@astrojs/node/preview.js', exports: ['handler', 'startServer', 'options'], args: options, + adapterFeatures: { + buildOutput: 'server', + edgeMiddleware: false, + }, supportedAstroFeatures: { hybridOutput: 'stable', staticOutput: 'stable', serverOutput: 'stable', - assets: { - supportKind: 'stable', - isSharpCompatible: true, - isSquooshCompatible: true, - }, + sharpImageService: 'stable', i18nDomains: 'experimental', - envGetSecret: 'experimental', + envGetSecret: 'stable', }, }; } -// TODO: remove once we don't use a TLA anymore -async function shouldExternalizeAstroEnvSetup() { - try { - await import('astro/env/setup'); - return false; - } catch { - return true; - } -} - export default function createIntegration(userOptions: UserOptions): AstroIntegration { if (!userOptions?.mode) { throw new AstroError(`Setting the 'mode' option is required.`); @@ -51,16 +41,11 @@ export default function createIntegration(userOptions: UserOptions): AstroIntegr vite: { ssr: { noExternal: ['@astrojs/node'], - ...((await shouldExternalizeAstroEnvSetup()) - ? { - external: ['astro/env/setup'], - } - : {}), }, }, }); }, - 'astro:config:done': ({ setAdapter, config, logger }) => { + 'astro:config:done': ({ setAdapter, config }) => { _options = { ...userOptions, client: config.build.client?.toString(), @@ -70,12 +55,6 @@ export default function createIntegration(userOptions: UserOptions): AstroIntegr assets: config.build.assets, }; setAdapter(getAdapter(_options)); - - if (config.output === 'static') { - logger.warn( - `\`output: "server"\` or \`output: "hybrid"\` is required to use this adapter.` - ); - } }, }, }; diff --git a/packages/integrations/node/src/middleware.ts b/packages/integrations/node/src/middleware.ts index 5bb104914..aeee6cf2e 100644 --- a/packages/integrations/node/src/middleware.ts +++ b/packages/integrations/node/src/middleware.ts @@ -25,6 +25,7 @@ export default function createMiddleware(app: NodeApp): RequestHandler { return next(error); // biome-ignore lint/style/noUselessElse: <explanation> } else { + // biome-ignore lint/complexity/useArrowFunction: <explanation> throw error; } } diff --git a/packages/integrations/node/src/polyfill.ts b/packages/integrations/node/src/polyfill.ts new file mode 100644 index 000000000..dc00f45d7 --- /dev/null +++ b/packages/integrations/node/src/polyfill.ts @@ -0,0 +1,3 @@ +import { applyPolyfills } from 'astro/app/node'; + +applyPolyfills(); diff --git a/packages/integrations/node/src/preview.ts b/packages/integrations/node/src/preview.ts index 7e9415df8..0517e2c0b 100644 --- a/packages/integrations/node/src/preview.ts +++ b/packages/integrations/node/src/preview.ts @@ -18,6 +18,7 @@ const createPreviewServer: CreatePreviewServer = async (preview) => { ssrHandler = ssrModule.handler; // biome-ignore lint/style/noNonNullAssertion: <explanation> options = ssrModule.options!; + // biome-ignore lint/complexity/useArrowFunction: <explanation> } else { throw new AstroError( `The server entrypoint doesn't have a handler. Are you sure this is the right file?` diff --git a/packages/integrations/node/src/server.ts b/packages/integrations/node/src/server.ts index 1bb27e002..cef262b47 100644 --- a/packages/integrations/node/src/server.ts +++ b/packages/integrations/node/src/server.ts @@ -1,17 +1,15 @@ +// Keep at the top +import './polyfill.js'; + import type { SSRManifest } from 'astro'; -import { NodeApp, applyPolyfills } from 'astro/app/node'; +import { NodeApp } 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'; -// This needs to run first because some internals depend on `crypto` -applyPolyfills(); -// 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]); export function createExports(manifest: SSRManifest, options: Options) { const app = new NodeApp(manifest); |