#Build fails due to @astrojs/react import after Astro 6.0 upgrade

4 messages · Page 1 of 1 (latest)

eternal rampart
#

I tried to update my blog to Astro 6.0 and also update my RSS to encode content. I previously held off on this as I use MDX files and didn't think I could reasonably render this content. I learned about the experimental_AstroContainer and saw that it might now be possible. I upgraded to Astro 6.0 and implemented a new RSS endpoint to support MDX with astro containers and both MDX and React renderers.

The Problem

The RSS feed generation works when I run astro dev, but astro build fails when building server entrypoints.

After some debugging, I have found that this import is the cause of the error:

import { getContainerRenderer as getReactContainerRenderer } from "@astrojs/react";
  • If I remove the react container renderer and include the import statement, the build fails.
  • If I remove the react container renderer and import statement, the build succeeds.
  • When I investigate the @astrojs/react and @astrojs/mdx packages I don't see any major difference in how the getContainerRenderer function is exported.

The error

[commonjs--resolver] Missing "./internal" specifier in "vite" package
gentle daggerBOT
#

Hi @eternal rampart. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The knowledge sources don't contain enough information to directly explain or resolve the specific build error you're encountering ([commonjs--resolver] Missing "./internal" specifier in "vite" package) related to importing getContainerRenderer from @astrojs/react after upgrading to Astro 6.0.

However, there are a couple of things worth noting from the documentation that may be relevant:

On the Container API and renderers:

The docs describe two approaches for adding renderers. For build/testing contexts (where Vite is available), you use loadRenderers() from the astro:container virtual module:

import { getContainerRenderer as reactContainerRenderer } from "@astrojs/react";
import { getContainerRenderer as mdxContainerRenderer } from "@astrojs/mdx";
import { loadRenderers } from "astro:container";

const renderers = await loadRenderers([reactContainerRenderer(), mdxContainerRenderer()]);
const container = await experimental_AstroContainer.create({ renderers });

For on-demand/runtime usage (outside of Vite), you must import server renderers manually instead: [Container API]

import reactRenderer from "@astrojs/react/server.js";
import mdxRenderer from "@astrojs/mdx/server.js";

const container = await experimental_AstroContainer.create();
container.addServerRenderer({ renderer: reactRenderer });
container.addServerRenderer({ renderer: mdxRenderer });
container.addClientRenderer({ name: "@astrojs/react", entrypoint: "@astrojs/react/client.js" });

On Astro 6.0 and Vite 7:

#

Astro 6.0 upgrades to Vite 7.0, which may introduce breaking changes. The error mentioning a missing "./internal" specifier in the "vite" package suggests a Vite compatibility issue. [Upgrade to v6]

My suggestion: Since your RSS endpoint runs at build time (server-side, outside a Vite dev context), try switching from the getContainerRenderer + loadRenderers() approach to the manual renderer import approach shown above. The astro:container virtual module and loadRenderers() are intended for Vite contexts (like Vitest), and may not work correctly during astro build server entrypoint compilation.

If the issue persists, I'd recommend checking Astro's GitHub issues as this appears to be a specific compatibility bug that isn't covered in the available documentation. [Known Issues]

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: