astro@3.0.0-beta.0
版本发布时间: 2023-08-03 23:20:51
withastro/astro最新发布版本:astro@5.0.0-beta.2(2024-09-24 17:12:05)
Major Changes
-
1eae2e3f7
Thanks @Princesseuh! - Remove support for Node 16. The lowest supported version by Astro and all integrations is now v18.14.1. As a reminder, Node 16 will be deprecated on the 11th September 2023. -
76ddef19c
Thanks @Princesseuh! - Removed automatic flattening ofgetStaticPaths
result..flatMap
and.flat
should now be used to ensure that you're returning a flat array. -
3fdf509b2
Thanks @ematipico! - Thebuild.split
andbuild.excludeMiddleware
configuration options are deprecated and have been replaced by options in the adapter config.If your config includes the
build.excludeMiddleware
option, replace it withedgeMiddleware
in your adapter options:import { defineConfig } from "astro/config"; import netlify from "@astrojs/netlify/functions"; export default defineConfig({ build: { - excludeMiddleware: true }, adapter: netlify({ + edgeMiddleware: true }), });
If your config includes the
build.split
option, replace it withfunctionPerRoute
in your adapter options:import { defineConfig } from "astro/config"; import netlify from "@astrojs/netlify/functions"; export default defineConfig({ build: { - split: true }, adapter: netlify({ + functionPerRoute: true }), });
-
2f951cd40
Thanks @Princesseuh! - Sharp is now the default image service used forastro:assets
. If you would prefer to still use Squoosh, you can update your config with the following:import { defineConfig, squooshImageService } from 'astro/config'; // https://astro.build/config export default defineConfig({ image: { service: squooshImageService(), }, });
However, not only do we recommend using Sharp as it is faster and more reliable, it is also highly likely that the Squoosh service will be removed in a future release.
-
c022a4217
Thanks @Princesseuh! - When using an adapter that supports neither Squoosh or Sharp, Astro will now automatically use an image service that does not support processing, but still provides the other benefits ofastro:assets
such as enforcingalt
, no CLS etc to users -
67becaa58
Thanks @ematipico! - Removed support for old syntax of the API routes. -
dfc2d93e3
Thanks @bluwy! - Remove MDX plugin re-ordering hack -
3dc1ca2fa
Thanks @Princesseuh! - Reduced the amount of polyfills provided by Astro. Astro will no longer provide (no-op) polyfills for several web apis such as HTMLElement, Image or Document. If you need access to those APIs on the server, we recommend using more proper polyfills available on npm. -
1be84dfee
Thanks @Princesseuh! - Updatetsconfig.json
presets withmoduleResolution: 'bundler'
and other new options from TypeScript 5.0. Astro now assumes that you use TypeScript 5.0 (March 2023), or that your editor includes it, ex: VS Code 1.77 -
35f01df79
Thanks @Princesseuh! - Theastro check
command now requires an external package@astrojs/check
and an install oftypescript
in your project. This was done in order to make the mainastro
package smaller and give more flexibility to users in regard to the version of TypeScript they use. -
3fdf509b2
Thanks @ematipico! - Thebuild.split
andbuild.excludeMiddleware
configuration options are deprecated and have been replaced by options in the adapter config.If your config includes the
build.excludeMiddleware
option, replace it withedgeMiddleware
in your adapter options:import { defineConfig } from "astro/config"; import vercel from "@astrojs/vercel/serverless"; export default defineConfig({ build: { - excludeMiddleware: true }, adapter: vercel({ + edgeMiddleware: true }), });
If your config includes the
build.split
option, replace it withfunctionPerRoute
in your adapter options:import { defineConfig } from "astro/config"; import vercel from "@astrojs/vercel/serverless"; export default defineConfig({ build: { - split: true }, adapter: vercel({ + functionPerRoute: true }), });
-
78de801f2
Thanks @ematipico! - Lowercase names for endpoint functions are now deprecated.Rename functions to their uppercase equivalent:
- export function get() { + export function GET() { return new Response(JSON.stringify({ "title": "Bob's blog" })); } - export function post() { + export function POST() { return new Response(JSON.stringify({ "title": "Bob's blog" })); } - export function put() { + export function PUT() { return new Response(JSON.stringify({ "title": "Bob's blog" })); } - export function all() { + export function ALL() { return new Response(JSON.stringify({ "title": "Bob's blog" })); } // you can use the whole word "DELETE" - export function del() { + export function DELETE() { return new Response(JSON.stringify({ "title": "Bob's blog" })); }
-
59d6e569f
Thanks @matthewp! - Astro.cookies.get(key) returns undefined if cookie doesn't existWith this change, Astro.cookies.get(key) no longer always returns a
AstroCookie
object. Instead it now returnsundefined
if the cookie does not exist.You should update your code if you assume that all calls to
get()
return a value. When using withhas()
you still need to assert the value, like so:--- if (Astro.cookies.has(id)) { const id = Astro.cookies.get(id)!; } ---
-
7723c4cc9
Thanks @ematipico! - The propertycompressHTML
is nowtrue
by default. Setting this value totrue
is no longer required.If you do not want to minify your HTML output, you must set this value to
false
inastro.config.mjs
.import {defineConfig} from "astro/config"; export default defineConfig({ + compressHTML: false })
-
fb5cd6b56
Thanks @ematipico! - Astro's default port when running the dev or preview server is now4321
.This will reduce conflicts with ports used by other tools.
-
631b9c410
Thanks @bluwy! - Remove MDX specialcomponents
export handling
Minor Changes
-
9b4f70a62
Thanks @ematipico! - Introduced the concept of feature map. A feature map is a list of features that are built-in in Astro, and an Adapter can tell Astro if it can support it.import { AstroIntegration } from './astro'; function myIntegration(): AstroIntegration { return { name: 'astro-awesome-list', // new feature map supportedAstroFeatures: { hybridOutput: 'experimental', staticOutput: 'stable', serverOutput: 'stable', assets: { supportKind: 'stable', isSharpCompatible: false, isSquooshCompatible: false, }, }, }; }
-
bc37331d8
Thanks @ematipico! - Integrations can now log messages using Astro’s built-in logger.The logger is available to all hooks as an additional parameter:
import { AstroIntegration } from './astro'; // integration.js export function myIntegration(): AstroIntegration { return { name: 'my-integration', hooks: { 'astro:config:done': ({ logger }) => { logger.info('Configure integration...'); }, }, }; }
Patch Changes
- Updated dependencies [
1eae2e3f7
]:- @astrojs/telemetry@3.0.0-beta.0
- @astrojs/internal-helpers@0.2.0-beta.0
- @astrojs/markdown-remark@3.0.0-beta.0