Astro 5.16

Автор
Matthew Phillips

Astro 5.16 приносит экспериментальную оптимизацию SVG, интерактивные улучшения CLI и набор DX-улучшений.

Что нового в этом релизе:

Чтобы обновить существующий проект, используйте CLI @astrojs/upgrade. Или обновите вручную:

# Рекомендуется:
npx @astrojs/upgrade
# Вручную:
npm install astro@latest
pnpm upgrade astro --latest
yarn upgrade astro --latest

SVG optimization with SVGO

Astro 5.16 добавляет экспериментальную автоматическую оптимизацию SVG через SVGO — уменьшение размера без потери качества.

SVG часто можно сильно оптимизировать — удалить метаданные, упростить пути, убрать лишние атрибуты. SVGO в пайплайне ассетов Astro оптимизирует SVG при сборке.

astro.config.mjs
import { defineConfig } from 'astro/config';
export default defineConfig({
experimental: {
svgo: true,
},
});

По умолчанию рекомендуемые настройки SVGO. Кастомизация:

astro.config.mjs
export default defineConfig({
experimental: {
svgo: {
plugins: [
'preset-default',
{
name: 'removeViewBox',
active: false
}
]
}
}
})

Подробнее — в документации оптимизации SVG.

Interactive shortcuts for astro preview

astro preview теперь поддерживает горячие клавиши — как astro dev:

> Local: http://localhost:4321/
- press o + enter to open in browser
- press q + enter to quit

Не нужно вручную открывать браузер или завершать Ctrl+C — preview согласован с dev workflow.

Better agent support with astro add --yes

Coding agents и AI-инструменты всё популярнее — Astro упрощает работу с ними. astro add показывает подсказку о флаге --yes для пропуска интерактивных промптов.

astro add react --yes

При интерактивном запуске:

astro add react
# Output:
# To run this command without prompts, pass the --yes flag

Агенты (Claude Code, Cursor, Copilot и др.) могут автоматизировать настройку Astro без ожидания подтверждений.

ActionInputSchema utility type for type-safe actions

Astro Actions включают утилитарный тип ActionInputSchema для извлечения input schema из определений actions — удобно для абстракций и переиспользуемых обработчиков.

import { type ActionInputSchema, defineAction } from 'astro:actions';
import { z } from 'astro/zod';
const contactAction = defineAction({
accept: 'form',
input: z.object({
email: z.string().email(),
message: z.string(),
}),
handler: ({ email, message }) => {
// Handle the contact form
return { success: true };
},
});
// Extract the schema type
type ContactSchema = ActionInputSchema<typeof contactAction>;
// Get the actual input type
type ContactInput = z.input<ContactSchema>;
// Result: { email: string; message: string }

Особенно ценно при:

  • обёртках вокруг actions;
  • абстракциях отправки форм;
  • общих типах actions в кодовой базе.

ActionInputSchema даёт правильный type inference без дублирования схем.

Other improvements

  • Сокращение зависимостей Netlify adapter на 82 МБ – обновление @netlify/functions до v5: −310 транзитивных зависимостей, −82 МБ. (#14716)

Bug fixes

Как всегда, с релиза 5.15 мы усердно исправляли проблемы. Все детали — в changelog.

Community

Команда Astro:

Alexander Niebuhr, Armand Philippot, Chris Swithinbank, Emanuele Stoppa, Erika, Florian Lefebvre, Fred Schott, HiDeoo, Luiz Ferraz, Matt Kane, Matthew Phillips, Reuben Tier, Sarah Rainsberger, and Yan Thomas.

Спасибо Alejandro Romano, Andreas Deininger, Arman, Azat S., BuckyBuck135, David Dal Busco, DevVali, Elvis Mao, Eryk Baran, Felix Schneider, Franco Victorio, Fredrik Norlin, Gökhan Kurt, Jacob Lamb, John L. Armstrong IV, Junseong Park, knj, ktym4a, ld-web, Louis Escher, Lumynous, MareStare, Marta Karaś, Mateusz Malinkiewicz, Maurici Abad Gutierrez, Mehdi El Fadil, Michael Stramel, Michał Paśko, Ming-jun Lu, nemu, Néstor, Olusegun Durojaye, paul valladares, Philippe Serhal, pioupia, randomguy-2650, Roman, Roman Hauksson, Sarah Krasnik Bedell, Sebastian Beltran, Sergio, Thomas Bonnet, and vrabe