diff --git a/.changeset/odd-donuts-impress.md b/.changeset/odd-donuts-impress.md new file mode 100644 index 0000000000..7dd8d6b1b4 --- /dev/null +++ b/.changeset/odd-donuts-impress.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes the path returned by `injectTypes` diff --git a/packages/astro/src/integrations/hooks.ts b/packages/astro/src/integrations/hooks.ts index c0b9604335..aa62572ee8 100644 --- a/packages/astro/src/integrations/hooks.ts +++ b/packages/astro/src/integrations/hooks.ts @@ -351,7 +351,9 @@ export async function runHookConfigDone({ content: injectedType.content, }); - return new URL(normalizedFilename, settings.config.root); + // It must be relative to dotAstroDir here and not inside normalizeInjectedTypeFilename + // because injectedTypes are handled relatively to the dotAstroDir already + return new URL(normalizedFilename, settings.dotAstroDir); }, logger: getLogger(integration, logger), }),