Astro Plugin Peer Dependency Pinning

In the Astro ecosystem, plugin packages (`@astrojs/*`) release independently of the core framework and frequently break peer dependency compatibility. Pin plugin versions explicitly and test upgrades in isolation rather than accepting latest.

Tags

Astro Plugin Peer Dependency Pinning

The Lesson

In the Astro ecosystem, plugin packages (@astrojs/*) release independently of the core framework and frequently break peer dependency compatibility. Pin plugin versions explicitly and test upgrades in isolation rather than accepting latest.

Context

An Astro 5 static site used @astrojs/mdx for rendering MDX content collections across 12 regulatory topic pages. During a routine dependency update, the latest version of @astrojs/mdx was installed, which declared a peer dependency incompatible with the installed Astro 5 version.

What Happened

  1. The project was set up with Astro 5 and @astrojs/mdx at a compatible version.
  2. A dependency update pulled in a newer @astrojs/mdx that required a different Astro version range.
  3. The build broke with peer dependency resolution errors — npm could not reconcile the version constraints.
  4. The fix was downgrading @astrojs/mdx to version 4.3.14, the last release compatible with Astro 5.
  5. The downgrade removed 193 lines of unnecessary lock file entries and restored a clean build.

Key Insights

Applicability

Applies to any project in a framework ecosystem where plugins/integrations version independently (Astro, Next.js plugins, Vite plugins). Less relevant for ecosystems with lockstep versioning (e.g., Angular's synchronized package releases).

Related Lessons