Change8

astro@7.2.0

📦 astroView on GitHub →
6 features🐛 1 fixes🔧 14 symbols

Summary

This release introduces background preview servers, relative paths for logger entrypoints, and experimental support for incremental static builds. It also enhances prerendering capabilities and allows opting out of session support.

Migration Steps

  1. When using custom log handlers, update `logger.entrypoint` to use relative paths (e.g., `'./src/logger.js'`) instead of absolute `URL` objects.
  2. To enable incremental static builds, set `experimental.incrementalBuild: true` in `astro.config.mjs` and return a `cacheKey` from `getStaticPaths()`.
  3. To opt out of session support, set `session: false` in `astro.config.mjs`.
  4. To opt out of automatic background mode for preview servers, set `ASTRO_PREVIEW_BACKGROUND=0` before running `astro preview`.

✨ New Features

  • Adds the `astro preview --background` flag to start preview servers as background processes, making them easier to manage from scripts and AI coding agents. New subcommands `astro preview status`, `astro preview logs`, `astro preview logs --follow`, and `astro preview stop` are available. Background mode is enabled automatically for AI coding agents. Opt out with `ASTRO_PREVIEW_BACKGROUND=0`.
  • Adds support for paths relative to your project root in `logger.entrypoint`. Paths starting with `./` or `../` are resolved against your project root.
  • Widens the `AstroPrerenderer` `render()` return type to include `PrerenderResult` which pairs the response with metadata like content entries and optimized-image transforms. This supports incremental static builds.
  • Adds `session: false` in `astro.config` to opt out of session support, tree-shaking the session runtime and dependencies (`unstorage`) from the SSR bundle for projects that don't use sessions.
  • Adds experimental support for incremental static builds with `experimental.incrementalBuild`. When enabled, Astro can skip regenerating static pages from dynamic routes if their module dependencies and data cache key are unchanged. Requires preserving Astro's cache directory (`node_modules/.astro/`) between builds.
  • Adds the optional `digest` property to content collection entries, allowing loaders to provide a value that changes when an entry changes. This can be used as a `cacheKey` for incremental static builds.

🐛 Bug Fixes

  • Fixes `astro dev` crashing with `Invalid URL` when `--host` is set to a specific non-loopback address.

Affected Symbols