From 530fb9ebee77646921ec29d45d9b66484bdfb521 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Fri, 19 May 2023 18:13:46 +0800 Subject: [PATCH] Add route information for getStaticPaths warning (#7126) --- .changeset/swift-lamps-doubt.md | 5 +++++ packages/astro/src/core/routing/validation.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/swift-lamps-doubt.md diff --git a/.changeset/swift-lamps-doubt.md b/.changeset/swift-lamps-doubt.md new file mode 100644 index 000000000000..2ee2f6fb35fe --- /dev/null +++ b/.changeset/swift-lamps-doubt.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Add route information when warning of `getStaticPaths()` ignored diff --git a/packages/astro/src/core/routing/validation.ts b/packages/astro/src/core/routing/validation.ts index 047a5b8923ef..911a97a9e4a9 100644 --- a/packages/astro/src/core/routing/validation.ts +++ b/packages/astro/src/core/routing/validation.ts @@ -1,3 +1,4 @@ +import { bold } from 'kleur/colors'; import type { ComponentInstance, GetStaticPathsResult, RouteData } from '../../@types/astro'; import { AstroError, AstroErrorData } from '../errors/index.js'; import type { LogOptions } from '../logger/core'; @@ -32,7 +33,11 @@ export function validateDynamicRouteModule( } ) { if (ssr && mod.getStaticPaths && !mod.prerender) { - warn(logging, 'getStaticPaths', 'getStaticPaths() is ignored when "output: server" is set.'); + warn( + logging, + 'getStaticPaths', + `getStaticPaths() in ${bold(route.component)} is ignored when "output: server" is set.` + ); } if ((!ssr || mod.prerender) && !mod.getStaticPaths) { throw new AstroError({