Skip to content

build: bump Astro from 6 to 7#685

Open
stasadev wants to merge 2 commits into
mainfrom
20260723_stasadev_astro_7
Open

build: bump Astro from 6 to 7#685
stasadev wants to merge 2 commits into
mainfrom
20260723_stasadev_astro_7

Conversation

@stasadev

@stasadev stasadev commented Jul 23, 2026

Copy link
Copy Markdown
Member

The Issue

See https://docs.astro.build/en/guides/upgrade-to/v7/

How This PR Solves The Issue

Astro 7 changes that needed code fixes:

  • New Rust compiler is stricter about HTML. Every non-void element now needs a closing tag; the old Go compiler used to fix this by itself. Added the missing </Layout> tags in survey.astro and newsletter.astro.

  • Markdown now runs through a processor. Moved remarkPlugins and rehypePlugins into unified({...}) from @astrojs/markdown-remark so the deprecation warning is gone.

  • Astro 7 also moves to Vite 8 (handled by the dependency bumps).

  • src/lib/search-index.js used an undefined fs (the import was named fs2). The bug was there before but stayed hidden; Astro 7 fails the build:done hook on it. Renamed the import to fs.

  • package.json override:

    "overrides": {
      "astro-rehype-relative-markdown-links": {
        "astro": "$astro"
      }
    }

    astro-rehype-relative-markdown-links does not yet list Astro 7 as a supported peer, but it works fine. The override makes it use our Astro version and avoids a peer-dependency install error. See Support Astro v7 (update peer dependency range) vernak2539/astro-rehype-relative-markdown-links#84

Manual Testing Instructions

Compare https://20260723-stasadev-astro-7.ddev-com-front-end.pages.dev/ vs https://ddev.com/

Click different links and confirm that everything works as expected in both desktop and mobile views.

Automated Testing Overview

Release/Deployment Notes

See https://docs.astro.build/en/guides/upgrade-to/v7/

Astro 7 changes that needed code fixes:

- New Rust compiler is stricter about HTML. Every non-void element
  now needs a closing tag; the old Go compiler used to fix this by
  itself. Added the missing `</Layout>` tags in `survey.astro` and
  `newsletter.astro`.

- Markdown now runs through a `processor`. Moved `remarkPlugins` and
  `rehypePlugins` into `unified({...})` from `@astrojs/markdown-remark` so
  the deprecation warning is gone.

- Astro 7 also moves to Vite 8 (handled by the dependency bumps).

- `src/lib/search-index.js` used an undefined `fs` (the import was
  named `fs2`). The bug was there before but stayed hidden; Astro 7
  fails the `build:done` hook on it. Renamed the import to `fs`.

- `package.json` override:

  ```js
  "overrides": {
    "astro-rehype-relative-markdown-links": {
      "astro": "$astro"
    }
  }
  ```

  `astro-rehype-relative-markdown-links` does not yet list Astro 7 as a
  supported peer, but it works fine. The override makes it use our
  Astro version and avoids a peer-dependency install error.
  See vernak2539/astro-rehype-relative-markdown-links#84
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploying ddev-com-front-end with  Cloudflare Pages  Cloudflare Pages

Latest commit: 924884f
Status: ✅  Deploy successful!
Preview URL: https://c5b224db.ddev-com-front-end.pages.dev
Branch Preview URL: https://20260723-stasadev-astro-7.ddev-com-front-end.pages.dev

View logs

@stasadev
stasadev requested a review from bmartinez287 July 23, 2026 21:12
@rfay

rfay commented Jul 23, 2026

Copy link
Copy Markdown
Member

Claude Review: differential crawl of both deployed sites

Instead of eyeballing the three listed pages, I compared all 216 sitemap pages on prod (ddev.com, confirmed Astro v6.3.5) vs the preview deploy (confirmed Astro v7.1.3). The script fetches each path from both hosts and diffs three things per page — HTTP status, visible text (tags stripped), and all link/asset targets — after normalizing out build-specific noise (content hashes, generator version, scoped-style CIDs). A second pass scrubs live dynamic data to separate real differences from time-based churn.

Results — no regressions

Check Result
HTTP status, all 216 pages 200/200 on both — no broken pages
Text identical after scrubbing dynamic data 205 / 216
Remaining 11 diffs all explained as non-regressions (below)
Generated outputs search.json 10 entries both · blog/rss.xml 50 items both · /404 renders both

The 11 residual differences:

  • Cloudflare email obfuscation (8 pages: contact, privacy, and several blog posts) — the production zone rewrites emails into [email protected] + a cdn-cgi decode script; the pages.dev preview shows the true email. Edge feature of the prod zone, not this PR. Same cause as the /cdn-cgi/l/email-protection link diffs.
  • Live dynamic data — homepage GitHub star count (127→128), usage-stats Amplitude numbers. Time-based, expected.
  • /get-started/ — a newline vs space inside a download-button label (↓\n(Intel/AMD)); inline whitespace browsers collapse identically. Cosmetic only.

Link/asset diffs reduced to build-hash changes plus giscus emitting giscus.app/client.js as a runtime setAttribute (Astro 7) vs a static src (Astro 6) — giscus is present and configured on both. Expected Vite/Astro-bump artifacts.

Highest-risk change verified clean: the markdown processor migration (remarkPlugins/rehypePluginsprocessor: unified({...})). On markdown-features-demo every structural feature matches exactly — callouts (76), figures/figcaptions (4/4), autolinked headings (10), shiki blocks (28), copy buttons (16), table wrappers (16), emoji labels (21).

Code review

All 8 files look correct and minimal:

  • astro.config.mjs — plugin lists moved verbatim into unified(); order preserved.
  • search-index.js — the fs2fs fix is a real latent bug fix (the old name was undefined).
  • newsletter.astro / survey.astro — added the missing </Layout> the old Go compiler had been auto-closing.
  • package.json deps/override/allowScripts, plus the two whitespace-only content/doc edits — all benign.

Recommendation: approve. The preview deploy building and serving all 216 pages is itself proof the Astro 7 build succeeds. The only PR-attributable rendering difference is the cosmetic /get-started/ whitespace, which is visually identical in-browser.

Comparison script used (compare.sh)
#!/usr/bin/env bash
# Compare prod (Astro 6) vs preview (Astro 7) for every sitemap path.
set -u
WD=~/tmp/astro7-diff
cd "$WD"
PROD="https://ddev.com"
PREV="https://20260723-stasadev-astro-7.ddev-com-front-end.pages.dev"
mkdir -p prod prev norm diffs
: > status.tsv
: > report.txt

# Normalizer: remove build-specific noise so only real diffs remain.
normalize() {
  perl -0777 -pe '
    s{/_astro/([A-Za-z0-9_\-]+?)\.[A-Za-z0-9_\-]{6,}(\.[a-z0-9]+)}{/_astro/$1$2}g; # asset content hashes
    s{Astro v[0-9]+\.[0-9]+\.[0-9]+}{Astro vX}g;                                    # generator version
    s{data-astro-cid-[a-z0-9]+}{data-astro-cid-X}g;                                 # scoped style ids
    s{astro-[a-z0-9]{8,}}{astro-X}g;                                                # scoped class names
    s{\?v=[a-z0-9]+}{?v=X}gi;                                                        # cache-busting query
  '
}
# Visible text: strip script/style, then all tags, collapse whitespace.
textof() {
  perl -0777 -pe 's{<script\b.*?</script>}{}gis; s{<style\b.*?</style>}{}gis; s{<!--.*?-->}{}gis; s{<[^>]+>}{ }gs;' \
   | perl -0777 -pe 's{&nbsp;}{ }g; s{&amp;}{&}g; s{&#39;}{'"'"'}g; s{&quot;}{"}g;' \
   | tr -s ' \t\r\n' ' ' | sed 's/^ //; s/ $//'
}
# Link/asset targets, normalized and sorted.
linksof() {
  grep -oiE '(href|src)="[^"]*"' | sed -E 's/^(href|src)=//I' | tr -d '"' | sort -u
}

n=0
while IFS= read -r url; do
  path="${url#https://ddev.com}"
  [ -z "$path" ] && path="/"
  slug=$(echo "$path" | sed 's#/#_#g; s/^_//; s/_$//'); [ -z "$slug" ] && slug="home"
  n=$((n+1))
  pc=$(curl -s -o "prod/$slug.html" -w "%{http_code}" "$PROD$path")
  vc=$(curl -s -o "prev/$slug.html" -w "%{http_code}" "$PREV$path")
  printf '%s\t%s\t%s\n' "$pc" "$vc" "$path" >> status.tsv

  if [ "$pc" = "200" ] && [ "$vc" = "200" ]; then
    normalize < "prod/$slug.html" | textof > "norm/$slug.prod.txt"
    normalize < "prev/$slug.html" | textof > "norm/$slug.prev.txt"
    normalize < "prod/$slug.html" | linksof > "norm/$slug.prod.links"
    normalize < "prev/$slug.html" | linksof > "norm/$slug.prev.links"
    tdiff=$(diff "norm/$slug.prod.txt" "norm/$slug.prev.txt")
    ldiff=$(diff "norm/$slug.prod.links" "norm/$slug.prev.links")
    if [ -n "$tdiff" ] || [ -n "$ldiff" ]; then
      { echo "########## $path";
        [ -n "$tdiff" ] && { echo "--- TEXT DIFF ---"; echo "$tdiff"; }
        [ -n "$ldiff" ] && { echo "--- LINK/ASSET DIFF ---"; echo "$ldiff"; }
        echo; } >> diffs/differences.txt
      echo "DIFF  $path" >> report.txt
    else
      echo "OK    $path" >> report.txt
    fi
  else
    echo "STATUS pc=$pc vc=$vc  $path" >> report.txt
  fi
  [ $((n % 40)) -eq 0 ] && echo "...processed $n"
done < urls_full.txt
echo "DONE: $n pages"

🤖 Review assisted by Claude Code

@rfay

rfay commented Jul 23, 2026

Copy link
Copy Markdown
Member

Manual clicking around also found no issues.

@rfay

rfay commented Jul 23, 2026

Copy link
Copy Markdown
Member

Claude caught a regression in get-started:

image

…tons

The Astro 7 Rust compiler no longer interprets escape sequences in plain
attribute strings the way the old Go compiler did, so the CtaButton labels
rendered a literal "\n" instead of a line break on /get-started/.

Switch the two `text=` props to expression syntax (`text={"...\n..."}`) so
the escape is a real newline character, which the button's `whitespace-pre-line`
class renders as a line break as before.

🤖 Developed with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@rfay

rfay commented Jul 23, 2026

Copy link
Copy Markdown
Member

I took the liberty of pushing the tiny change to windows.astro.

@rfay

rfay commented Jul 23, 2026

Copy link
Copy Markdown
Member

Claude commented on compressHTML — worth consideration, low risk

The default flipped from true (HTML-aware) to 'jsx' (React-style), a documented breaking change requiring whitespace review. The repo doesn't set it, so it takes the new default. My 216-page crawl found no whitespace regressions attributable to it (the only whitespace diff was the \n bug above, which is unrelated). So it's low-risk as-is; optionally pin compressHTML: true in astro.config.mjs to guarantee Astro-6-identical output, or leave it and rely on the crawl evidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants