note: no summary for this older release
We summarize recent releases. The original release notes for this version are below.
release-notesgithub.com/withastro/astro · 123 lines
- ### Minor Changes
- - [#15231](https://github.com/withastro/astro/pull/15231) [`3928b87`](https://github.com/withastro/astro/commit/3928b879dd35fa4ec4dcf545f1610a0f0a55fdae) Thanks [@rururux](https://github.com/rururux)! - Adds a new optional `getRemoteSize()` method to the Image Service API.
- Previously, `inferRemoteSize()` had a fixed implementation that fetched the entire image to determine its dimensions.
- With this new helper function that extends `inferRemoteSize()`, you can now override or extend how remote image metadata is retrieved.
- This enables use cases such as:
- - Caching: Storing image dimensions in a database or local cache to avoid redundant network requests.
- - Provider APIs: Using a specific image provider's API (like Cloudinary or Vercel) to get dimensions without downloading the file.
- For example, you can add a simple cache layer to your existing image service:
- ```js
- const cache = new Map();
- const myService = {
- ...baseService,
- async getRemoteSize(url, imageConfig) {
- if (cache.has(url)) return cache.get(url);
- const result = await baseService.getRemoteSize(url, imageConfig);
- cache.set(url, result);
- return result;
- },
- };
- ```
- See the [Image Services API reference documentation](https://v6.docs.astro.build/en/reference/image-service-reference/#getremotesize) for more information.
- - [#15077](https://github.com/withastro/astro/pull/15077) [`a164c77`](https://github.com/withastro/astro/commit/a164c77336059f2dc3e7f7fe992aa754ed145ef3) Thanks [@matthewp](https://github.com/matthewp)! - Updates the Integration API to add `setPrerenderer()` to the `astro:build:start` hook, allowing adapters to provide custom prerendering logic.
- The new API accepts either an `AstroPrerenderer` object directly, or a factory function that receives the default prerenderer:
- ```js
- 'astro:build:start': ({ setPrerenderer }) => {
- setPrerenderer((defaultPrerenderer) => ({
- name: 'my-prerenderer',
- async setup() {
- // Optional: called once before prerendering starts
- },
- async getStaticPaths() {
- // Returns array of { pathname: string, route: RouteData }
- return defaultPrerenderer.getStaticPaths();
- },
- async render(request, { routeData }) {
- // request: Request
- // routeData: RouteData
- // Returns: Response
- },
- async teardown() {
- // Optional: called after all pages are prerendered
- }
- }));
- }
- ```
- Also adds the `astro:static-paths` virtual module, which exports a `StaticPaths` class for adapters to collect all prerenderable paths from within their target runtime. This is useful when implementing a custom prerenderer that runs in a non-Node environment:
- ```js
- // In your adapter's request handler (running in target runtime)
- import { App } from 'astro/app';
- import { StaticPaths } from 'astro:static-paths';
- export function createApp(manifest) {
- const app = new App(manifest);
- return {
- async fetch(request) {
- const { pathname } = new URL(request.url);
- // Expose endpoint for prerenderer to get static paths
- if (pathname === '/__astro_static_paths') {
- const staticPaths = new StaticPaths(app);
- const paths = await staticPaths.getAll();
- return new Response(JSON.stringify({ paths }));
- }
- // Normal request handling
- return app.render(request);
- },
- };
- }
- ```
- See the [adapter reference](https://v6.docs.astro.build/en/reference/adapter-reference/#custom-prerenderer) for more details on implementing a custom prerenderer.
- - [#15345](https://github.com/withastro/astro/pull/15345) [`840fbf9`](https://github.com/withastro/astro/commit/840fbf9e4abc7f847e23da8d67904ffde4d95fff) Thanks [@matthewp](https://github.com/matthewp)! - Adds a new `emitClientAsset` function to `astro/assets/utils` for integration authors. This function allows emitting assets that will be moved to the client directory during SSR builds, useful for assets referenced in server-rendered content that need to be available on the client.
- ```ts
- import { emitClientAsset } from 'astro/assets/utils';
- // Inside a Vite plugin's transform or load hook
- const handle = emitClientAsset(this, {
- type: 'asset',
- name: 'my-image.png',
- source: imageBuffer,
- });
- ```
- ### Patch Changes
- - [#15423](https://github.com/withastro/astro/pull/15423) [`c5ea720`](https://github.com/withastro/astro/commit/c5ea720261a35324988147fbf69d8200e496e1d0) Thanks [@matthewp](https://github.com/matthewp)! - Improves error message when a dynamic redirect destination does not match any existing route.
- Previously, configuring a redirect like `/categories/[category]` → `/categories/[category]/1` in static output mode would fail with a misleading "getStaticPaths required" error. Now, Astro detects this early and provides a clear error explaining that the destination does not match any existing route.
- - [#15444](https://github.com/withastro/astro/pull/15444) [`10b0422`](https://github.com/withastro/astro/commit/10b0422b89d12320da3c026e8a4728ae7265cfb8) Thanks [@AhmadYasser1](https://github.com/AhmadYasser1)! - Fixes `Astro.rewrite` returning 404 when rewriting to a URL with non-ASCII characters
- When rewriting to a path containing non-ASCII characters (e.g., `/redirected/héllo`), the route lookup compared encoded `distURL` hrefs against decoded pathnames, causing the comparison to always fail and resulting in a 404. This fix compares against the encoded pathname instead.
- - [#15419](https://github.com/withastro/astro/pull/15419) [`a18d727`](https://github.com/withastro/astro/commit/a18d727fc717054df85177c8e0c3d38a5252f2da) Thanks [@ematipico](https://github.com/ematipico)! - Fixes an issue where the `add` command could accept any arbitrary value, leading the possible command injections. Now `add` and `--add` accepts
- values that are only acceptable npmjs.org names.
- - [#15345](https://github.com/withastro/astro/pull/15345) [`840fbf9`](https://github.com/withastro/astro/commit/840fbf9e4abc7f847e23da8d67904ffde4d95fff) Thanks [@matthewp](https://github.com/matthewp)! - Fixes an issue where `.sql` files (and other non-asset module types) were incorrectly moved to the client assets folder during SSR builds, causing "no such module" errors at runtime.
- The `ssrMoveAssets` function now reads the Vite manifest to determine which files are actual client assets (CSS and static assets like images) and only moves those, leaving server-side module files in place.
- - [#15422](https://github.com/withastro/astro/pull/15422) [`68770ef`](https://github.com/withastro/astro/commit/68770ef9e981f37a0b1b8febf76958010975add9) Thanks [@matthewp](https://github.com/matthewp)! - Upgrade to @astrojs/compiler@3.0.0-beta
- - Updated dependencies \[[`a164c77`](https://github.com/withastro/astro/commit/a164c77336059f2dc3e7f7fe992aa754ed145ef3), [`a18d727`](https://github.com/withastro/astro/commit/a18d727fc717054df85177c8e0c3d38a5252f2da)]:
- - @astrojs/internal-helpers@0.8.0-beta.1
- - @astrojs/markdown-remark@7.0.0-beta.6