From d78806dfe0301ea7ffe6c7c1f783bd415ac7cda9 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Wed, 4 Oct 2023 15:07:21 -0500 Subject: [PATCH] fix(#8746): improve error message for dynamic component usage (#8747) --- .changeset/fair-otters-worry.md | 5 +++++ packages/astro/src/runtime/server/hydration.ts | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changeset/fair-otters-worry.md diff --git a/.changeset/fair-otters-worry.md b/.changeset/fair-otters-worry.md new file mode 100644 index 0000000000..f62496140b --- /dev/null +++ b/.changeset/fair-otters-worry.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Improve error message when user attempts to render a dynamic component reference diff --git a/packages/astro/src/runtime/server/hydration.ts b/packages/astro/src/runtime/server/hydration.ts index e9d99c81a7..09f42a9b5c 100644 --- a/packages/astro/src/runtime/server/hydration.ts +++ b/packages/astro/src/runtime/server/hydration.ts @@ -122,9 +122,10 @@ export async function generateHydrateScript( const { hydrate, componentUrl, componentExport } = metadata; if (!componentExport.value) { - throw new Error( - `Unable to resolve a valid export for "${metadata.displayName}"! Please open an issue at https://astro.build/issues!` - ); + throw new AstroError({ + ...AstroErrorData.NoMatchingImport, + message: AstroErrorData.NoMatchingImport.message(metadata.displayName), + }); } const island: SSRElement = {