Suggestions
← TIL
~2 min read
#astro#rust#migration#pnpm

Astro 7's Rust compiler caught 2 bugs that spent months in production

pnpm build failed one minute after installing Astro 7.0.0. The error: a <section> opened twice and an unclosed <div> in my design system page. Both had been in production for months; the Go compiler silently auto-corrected them following the HTML spec. The Rust compiler, mandatory in v7, rejects them outright.

The entire migration diff#

src/pages/[lang]/design.astro
diff
                 </section>
-                <section>
     <section>
       <h2 class="section-title">{t("design.sect.media")}</h2>
@@
     </section>
+    </div>
   </main>

That was every line of code the 248-page migration touched. Two lines; the rest was package.json and the lockfile.

The 2 gotchas the changelog won’t shout at you#

I use rehype-slug and rehype-autolink-headings, so the new native Markdown processor (Sätteri) wasn’t enough on its own: I had to install @astrojs/markdown-remark manually and wrap the plugins with unified() in the config. No plugins, nothing to do.

The second one came from pnpm, not Astro. minimumReleaseAge blocks freshly published packages, and a same-day major doesn’t pass the filter:

pnpm-workspace.yaml
minimumReleaseAgeExclude:
  - astro@7.0.0
  - "@astrojs/mdx@7.0.0"
  - "@astrojs/vercel@11.0.0"

What won’t break your site#

Per the official migration guide, there are more breaking changes, but neither the removed astro:transitions constants nor the reserved src/fetch.ts filename affect a typical static site. Optimizations you already had, like instant navigations with Speculation Rules, keep working as before. Check with grep before panicking.

My take: a compiler that rejects your invalid HTML isn’t friction, it’s a free audit. Chesterton’s Fence works in reverse here; the permission nobody remembered granting (silent auto-correction) was hiding real technical debt.

This site brags about its Lighthouse 100/100 and still had invalid HTML in production. No linter saw it; a new compiler did.

Link copied to clipboard