diff --git a/.changeset/fair-otters-worry.md b/.changeset/fair-otters-worry.md new file mode 100644 index 000000000..f62496140 --- /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 e9d99c81a..09f42a9b5 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 = {