Vai al contenuto
verdict:

Astro 6.2.0

notable

note: la sintesi e le note di rilascio sono in inglese

note: nessuna sintesi per questa release più vecchia

Sintetizziamo le release recenti. Le note di rilascio originali di questa versione sono qui sotto.

release-notesgithub.com/withastro/astro · 184 righe
  1. ### Minor Changes
  2. - [#16187](https://github.com/withastro/astro/pull/16187) [`fe58071`](https://github.com/withastro/astro/commit/fe58071817f447f832d9ce4341c0b5991d3c0cda) Thanks [@gllmt](https://github.com/gllmt)! - Adds a `waitUntil` option to the `RenderOptions` so that adapters can forward runtime background-task hooks to Astro.
  3. When provided by an adapter, runtime cache providers receive `context.waitUntil` in
  4. `CacheProvider.onRequest()`, which allows background cache work such as stale-while-revalidate
  5. without blocking the response. The Cloudflare adapter now forwards
  6. `ExecutionContext.waitUntil` to this API.
  7. - [#16290](https://github.com/withastro/astro/pull/16290) [`a49637a`](https://github.com/withastro/astro/commit/a49637ab82a6ce8506a7272f331d1101f782b3e0) Thanks [@ViVaLaDaniel](https://github.com/ViVaLaDaniel)! - Ensures that `server.allowedHosts` (and `vite.preview.allowedHosts`) configuration is respected when using `astro preview` with the `@astrojs/cloudflare` adapter. This improves security by preventing DNS rebinding attacks when previewing Cloudflare builds locally.
  8. - [#15725](https://github.com/withastro/astro/pull/15725) [`4108ec1`](https://github.com/withastro/astro/commit/4108ec1e256c5e9d97fb29f1097a5095b73cfb8b) Thanks [@meyer](https://github.com/meyer)! - Adds support for a new `'jsx'` value for the `compressHTML` option. When set, whitespace is stripped using JSX whitespace rules instead of the default HTML compression strategy.
  9. ```js
  10. // astro.config.mjs
  11. import { defineConfig } from 'astro/config';
  12. export default defineConfig({
  13. compressHTML: 'jsx',
  14. });
  15. ```
  16. In JSX, whitespaces never matter, as such, no amount of indentation, or newlines will not affect the rendered output. For instance, the following code:
  17. ```jsx
  18. <div>
  19. <span>foo</span>
  20. <span>bar</span>
  21. </div>
  22. ```
  23. will be rendered as `foobar`, whereas with HTML whitespace rules, a space would be present between the words due to the newline and indentation between the tags.
  24. - [#16477](https://github.com/withastro/astro/pull/16477) [`28fb3e1`](https://github.com/withastro/astro/commit/28fb3e16cdf181d49fbc22fbde41958fe9b9ab9e) Thanks [@ematipico](https://github.com/ematipico)! - Adds experimental support for configurable log handlers.
  25. This experimental feature provides better control over Astro's logging infrastructure by allowing users to replace the default console output with custom logging implementations (e.g., structured JSON). This is particularly useful for users using on-demand rendering and wishing to connect their log aggregation services, such as Kibana, Logstash, CloudWatch, Grafana, or Loki.
  26. By default, Astro provides three built-in log handlers (`json`, `node`, and `console`), but you can also create your own.
  27. #### JSON logging
  28. JSON logging can be enabled via the CLI for the `build`, `dev`, and `sync` commands using the `experimentalJson` flag:
  29. ```js
  30. // astro.config.mjs
  31. import { defineConfig, logHandlers } from 'astro/config';
  32. export default defineConfig({
  33. experimental: {
  34. logger: logHandlers.json({
  35. pretty: true,
  36. level: 'warn',
  37. }),
  38. },
  39. });
  40. ```
  41. #### Custom logger
  42. You can also create your own custom logger by implementing the correct interface:
  43. ```js
  44. // astro.config.mjs
  45. import { defineConfig } from 'astro/config';
  46. export default defineConfig({
  47. experimental: {
  48. logger: {
  49. entrypoint: '@org/custom-logger',
  50. },
  51. },
  52. });
  53. ```
  54. ```ts
  55. // @org/custom-logger.js
  56. import type { AstroLoggerDestination, AstroLoggerMessage } from 'astro';
  57. import { matchesLevel } from 'astor/logger';
  58. function customLogger(level = 'info'): AstroLoggerDestination {
  59. return {
  60. write(message: AstroLoggerMessage) {
  61. if (matchesLevel(message.level, level)) {
  62. // write message somewhere
  63. }
  64. },
  65. };
  66. }
  67. export default customLogger;
  68. ```
  69. For more information on enabling and using this feature in your project, see the [Experimental Logger docs](https://docs.astro.build/en/reference/experimental-flags/logger/).
  70. For a complete overview and to give feedback on this experimental API, see the [Custom logger RFC](https://github.com/withastro/roadmap/blob/logger/proposals/0059-custom-logger.md).
  71. - [#16333](https://github.com/withastro/astro/pull/16333) [`0f7c3c8`](https://github.com/withastro/astro/commit/0f7c3c8e3dfe0fff58bd6e68c40f6f8fb280144e) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Adds an experimental flag `svgOptimizer` that enables automatic optimization of your SVG components using the provided optimizer. This supersedes the `svgo` experimental flag, which is now removed.
  72. When enabled, your imported SVG files used as components will be optimized for smaller file sizes and better performance while maintaining visual quality. This can significantly reduce the size of your SVG assets by removing unnecessary metadata, comments, and redundant code.
  73. Astro ships with a [SVGO](https://svgo.dev/) based optimizer, but any can be used.
  74. To enable this feature, add the experimental flag in your Astro config and remove `svgo` if it was enabled:
  75. ```diff
  76. // astro.config.mjs
  77. -import { defineConfig } from "astro/config";
  78. +import { defineConfig, svgoOptimizer } from "astro/config";
  79. export default defineConfig({
  80. + experimental: {
  81. + svgOptimizer: svgoOptimizer()
  82. - svgo: true
  83. + }
  84. });
  85. ```
  86. For more information on enabling and using this feature in your project, see the [experimental SVG optimization docs](https://docs.astro.build/en/reference/experimental-flags/svg-optimization/).
  87. - [#16302](https://github.com/withastro/astro/pull/16302) [`f6f8e80`](https://github.com/withastro/astro/commit/f6f8e8097e93e29d00f419e5594f2c081bb32478) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Adds a new `experimental_getFontFileURL()` method to resolve font file URLs when using the Fonts API
  88. The `fontData` object exported from `astro:assets` was introduced to provide low-level access to font family data for advanced usage. One of the goals of this API was to be able to resolve buffers using URLs. However, it turned out to be impractical, especially during prerendering.
  89. Astro now exports a new `experimental_getFontFileURL()` helper function from `astro:assets` to resolve font file URLs from `fontData`. For example, when using [satori](https://github.com/vercel/satori) to generate Open Graph images:
  90. ```diff
  91. // src/pages/og.png.ts
  92. import type { APIRoute } from "astro";
  93. -import { fontData } from "astro:assets";
  94. +import { fontData, experimental_getFontFileURL } from "astro:assets";
  95. -import { outDir } from "astro:config/server";
  96. -import { readFile } from "node:fs/promises";
  97. import satori from "satori";
  98. import { html } from "satori-html";
  99. import sharp from "sharp";
  100. export const GET: APIRoute = async (context) => {
  101. const fontPath = fontData["--font-roboto"][0]?.src[0]?.url;
  102. if (fontPath === undefined) {
  103. throw new Error("Cannot find the font path.");
  104. }
  105. - const data = import.meta.env.DEV
  106. - ? await fetch(new URL(fontPath, context.url.origin)).then(async (res) => res.arrayBuffer())
  107. - : await readFile(new URL(`.${fontPath}`, outDir));
  108. + const url = experimental_getFontFileURL(fontPath, context.url);
  109. + const data = await fetch(url).then((res) => res.arrayBuffer());
  110. const svg = await satori(
  111. html`<div style="color: black;">hello, world</div>`,
  112. {
  113. width: 600,
  114. height: 400,
  115. fonts: [
  116. {
  117. name: "Roboto",
  118. data,
  119. weight: 400,
  120. style: "normal",
  121. },
  122. ],
  123. },
  124. );
  125. const pngBuffer = await sharp(Buffer.from(svg))
  126. .resize(600, 400)
  127. .png()
  128. .toBuffer();
  129. return new Response(new Uint8Array(pngBuffer), {
  130. headers: {
  131. "Content-Type": "image/png",
  132. },
  133. });
  134. };
  135. ```
  136. See the [Fonts API documentation](https://docs.astro.build/en/guides/fonts/#accessing-font-data-programmatically) for more information.
  137. ### Patch Changes
  138. - [#15980](https://github.com/withastro/astro/pull/15980) [`8812382`](https://github.com/withastro/astro/commit/88123826690dde1e0019aa801fe7d18085f27271) Thanks [@seroperson](https://github.com/seroperson)! - Prevents script deduplication inside `<template>` elements

vedi su githubimported 2026-09-28 via npm