astro 2.8.0
Minor Changes
-
#7532
9e5fafa2bThanks @ematipico! - Theastro/middlewaremodule exports a new utility calledtrySerializeLocals.This utility can be used by adapters to validate their
localsbefore sending it to the Astro middleware.This function will throw a runtime error if the value passed is not serializable, so consumers will need to handle that error.
-
#7532
9e5fafa2bThanks @ematipico! - Astro exposes the middleware file path to the integrations in the hookastro:build:ssr// myIntegration.js import type { AstroIntegration } from 'astro'; function integration(): AstroIntegration { return { name: 'fancy-astro-integration', hooks: { 'astro:build:ssr': ({ middlewareEntryPoint }) => { if (middlewareEntryPoint) { // do some operations } }, }, }; }The
middlewareEntryPointis only defined if the user has created an Astro middleware. -
#7432
6e9c29579Thanks @ematipico! - Adds a new commandastro info, useful for sharing debugging information about your current environment when you need help!astro infoOutput
Astro version v2.6.6 Package manager pnpm Platform darwin Architecture arm64 Adapter @astrojs/vercel/serverless Integrations None -
#7532
9e5fafa2bThanks @ematipico! - Theastro/middlewaremodule exports a new API calledcreateContext.This a low-level API that adapters can use to create a context that can be consumed by middleware functions.
-
#7532
9e5fafa2bThanks @ematipico! - Introduced a new build option for SSR, calledbuild.excludeMiddleware.// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ build: { excludeMiddleware: true, }, });When enabled, the code that belongs to be middleware won't be imported by the final pages/entry points. The user is responsible for importing it and calling it manually.
Patch Changes
- #7532
9e5fafa2bThanks @ematipico! - Correctly track the middleware during the SSR build.