From 2dc63b8834cdd83761dcb39b1abab59f0be3e38e Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 29 Aug 2024 08:37:44 +0100 Subject: [PATCH] add changesets --- .changeset/brave-elephants-fly.md | 22 +++++++++++++++++++++ .changeset/fuzzy-pugs-live.md | 22 +++++++++++++++++++++ .changeset/ten-walls-tap.md | 21 +++++++++++++++++++- packages/astro/src/types/public/internal.ts | 7 +++++-- 4 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 .changeset/brave-elephants-fly.md create mode 100644 .changeset/fuzzy-pugs-live.md diff --git a/.changeset/brave-elephants-fly.md b/.changeset/brave-elephants-fly.md new file mode 100644 index 0000000000000..aec1c7d8f2b85 --- /dev/null +++ b/.changeset/brave-elephants-fly.md @@ -0,0 +1,22 @@ +--- +'@astrojs/vercel': major +'astro': major +--- + +### [changed]: `entryPoint` type inside the hook `astro:build:ssr` +In Astro v4.x, the `entryPoint` type was `RouteData`. + +Astro v5.0 the `entryPoint` type is `IntegrationRouteData`, which contains a subset of the `RouteData` type. The fields `isIndex` and `fallbackRoutes` were removed. + +#### What should I do? +Update your adapter to change the type of `entryPoint` from `RouteData` to `IntegrationRouteData`. + +```diff +-import type {RouteData} from 'astro'; ++import type {IntegrationRouteData} from "astro" + +-function useRoute(route: RouteData) { ++function useRoute(route: IntegrationRouteData) { + +} +``` diff --git a/.changeset/fuzzy-pugs-live.md b/.changeset/fuzzy-pugs-live.md new file mode 100644 index 0000000000000..1c69b9192f1ad --- /dev/null +++ b/.changeset/fuzzy-pugs-live.md @@ -0,0 +1,22 @@ +--- +'@astrojs/vercel': major +'astro': major +--- + +### [changed]: `routes` type inside the hook `astro:build:done` +In Astro v4.x, the `routes` type was `RouteData`. + +Astro v5.0 the `routes` type is `IntegrationRouteData`, which contains a subset of the `RouteData` type. The fields `isIndex` and `fallbackRoutes` were removed. + +#### What should I do? +Update your adapter to change the type of `routes` from `RouteData` to `IntegrationRouteData`. + +```diff +-import type {RouteData} from 'astro'; ++import type {IntegrationRouteData} from "astro" + +-function useRoute(route: RouteData) { ++function useRoute(route: IntegrationRouteData) { + +} +``` diff --git a/.changeset/ten-walls-tap.md b/.changeset/ten-walls-tap.md index 4cef9456a560b..afc8c07ed8d3e 100644 --- a/.changeset/ten-walls-tap.md +++ b/.changeset/ten-walls-tap.md @@ -2,4 +2,23 @@ 'astro': major --- -ff +### [changed]: `RouteData.distURL` is now an array +In Astro v4.x, `RouteData.distURL` was `undefined` or a `URL` + +Astro v5.0, `RouteData.distURL` is `undefined` or an array of `URL`. This was a bug, because a route can generate multiple files on disk, especially when using dynamic routes such as `[slug]` or `[...slug]`. + +#### What should I do? +Update your code to handle `RouteData.distURL` as an array. + +```diff +if (route.distURL) { +- if (route.distURL.endsWith('index.html')) { +- // do something +- } ++ for (const url of route.distURL) { ++ if (url.endsWith('index.html')) { ++ // do something ++ } ++ } +} +``` diff --git a/packages/astro/src/types/public/internal.ts b/packages/astro/src/types/public/internal.ts index 95fb58f058004..bced5ba2488bc 100644 --- a/packages/astro/src/types/public/internal.ts +++ b/packages/astro/src/types/public/internal.ts @@ -41,7 +41,10 @@ export interface SSRLoadedRendererValue { */ export interface RouteData { /** - * The current **pattern** of the route, + * The current **pattern** of the route. For example: + * - `src/pages/index.astro` has a pattern of `/` + * - `src/pages/blog/[...slug].astro` has a pattern of `/blog/[...slug]` + * - `src/pages/site/[blog]/[...slug].astro` has a pattern of `/site/[blog]/[...slug]` */ route: string; /** @@ -62,7 +65,7 @@ export interface RouteData { */ pathname?: string; /** - * The paths of the physical files emitted by this route. + * The paths of the physical files emitted by this route. When a route **isn't** prerendered, the value is either `undefined` or an empty array. */ distURL?: URL[]; /**