upgrade astro to v7 (astro 5 -> 7, with the required API migrations) #9

Merged
matt merged 1 commit from astro-7 into main 2026-09-17 16:04:42 -04:00
Owner

What changed

astro 5.18.1 -> 7.3.3, plus the code and dependency fixes that the upgrade requires.

Why the version bump alone doesn't work

Four separate blockers, each fixed:

  1. Removed import path. astro.config.mjs imported vercelStatic from @astrojs/vercel/static. Adapter v11 removed that subpath - and the import was never used (the config has no adapter: key at all). Removed it.
  2. Sätteri is the new default markdown processor. astro 7 no longer bundles @astrojs/markdown-remark, which this config needs for rehype-pretty-code and remarkReadingTime. Added it.
  3. Vite is no longer hoisted. astro 7 ships Vite 8 nested under itself, so @tailwindcss/vite could not resolve it. Bumped @tailwindcss/vite to 4.3.3 and added an explicit vite@^8.
  4. typescript declared ^7.0.0, but @astrojs/check requires ^5 and astro check crashes on TS 7 (Cannot read properties of undefined (reading 'fileExists')). The committed lockfile pins 5.9.3, so npm ci - what CI runs - already installed TS 5. Declared ^5.9.3 to match reality.

Real API migrations

astro check then caught the parts that actually need code changes:

  • Astro.glob() was removed. Converted all four call sites to import.meta.glob(pattern, { eager: true }) - the same pattern used in the sibling site.
  • The MarkdownInstance type was removed. Added a local MarkdownPost interface in src/utils/data.util.ts and swapped the annotations in those four pages plus src/components/LatestPosts.astro.

Verification

On a clean checkout of this branch, running exactly what CI runs:

npm ci            -> exit 0
npm run build     -> exit 0   (astro check && astro build, 27 pages, sitemap written)

Content check against the live site: the visible text matches except six characters - the live page carries a stray 🛠️ "> fragment that the new build does not emit. Otherwise identical, and the page count is unchanged.

Review notes

  • package-lock.json is regenerated. The committed lock pinned @astrojs/vercel@9.0.5 and typescript@5.9.3 while package.json asked for ^11 and ^7. main cannot be built from a clean install in that state, which is why the astro-monorepo dependency PR left it that way. Worth a look at whether other repos drifted the same way.
  • The typescript pin is a correction, not a downgrade: it makes the declaration agree with the lockfile that CI already resolves.
  • Merging deploys (the workflow's push job is guarded to main), so this is deliberately opened as a PR rather than merged.
## What changed astro **5.18.1 -> 7.3.3**, plus the code and dependency fixes that the upgrade requires. ## Why the version bump alone doesn't work Four separate blockers, each fixed: 1. **Removed import path.** `astro.config.mjs` imported `vercelStatic` from `@astrojs/vercel/static`. Adapter v11 removed that subpath - and the import was never used (the config has no `adapter:` key at all). Removed it. 2. **Sätteri is the new default markdown processor.** astro 7 no longer bundles `@astrojs/markdown-remark`, which this config needs for `rehype-pretty-code` and `remarkReadingTime`. Added it. 3. **Vite is no longer hoisted.** astro 7 ships Vite 8 nested under itself, so `@tailwindcss/vite` could not resolve it. Bumped `@tailwindcss/vite` to 4.3.3 and added an explicit `vite@^8`. 4. **typescript declared ^7.0.0, but `@astrojs/check` requires ^5** and `astro check` crashes on TS 7 (`Cannot read properties of undefined (reading 'fileExists')`). The committed lockfile pins 5.9.3, so `npm ci` - what CI runs - already installed TS 5. Declared ^5.9.3 to match reality. ## Real API migrations `astro check` then caught the parts that actually need code changes: - **`Astro.glob()` was removed.** Converted all four call sites to `import.meta.glob(pattern, { eager: true })` - the same pattern used in the sibling site. - **The `MarkdownInstance` type was removed.** Added a local `MarkdownPost` interface in `src/utils/data.util.ts` and swapped the annotations in those four pages plus `src/components/LatestPosts.astro`. ## Verification On a **clean checkout of this branch**, running exactly what CI runs: ``` npm ci -> exit 0 npm run build -> exit 0 (astro check && astro build, 27 pages, sitemap written) ``` Content check against the live site: the visible text matches except six characters - the live page carries a stray `🛠️ "> ` fragment that the new build does not emit. Otherwise identical, and the page count is unchanged. ## Review notes - **`package-lock.json` is regenerated.** The committed lock pinned `@astrojs/vercel@9.0.5` and `typescript@5.9.3` while `package.json` asked for `^11` and `^7`. **`main` cannot be built from a clean install in that state**, which is why the astro-monorepo dependency PR left it that way. Worth a look at whether other repos drifted the same way. - The typescript pin is a *correction*, not a downgrade: it makes the declaration agree with the lockfile that CI already resolves. - Merging deploys (the workflow's push job is guarded to main), so this is deliberately opened as a PR rather than merged.
upgrade astro 5 to 7, and fix the dependency drift that blocked it
All checks were successful
build-and-deploy / testbuild (push) Has been skipped
build-and-deploy / build_and_deploy (push) Successful in 2s
build-and-deploy / build_and_deploy (pull_request) Has been skipped
build-and-deploy / testbuild (pull_request) Successful in 40s
c62abf99a4
The version bump alone fails, for four separate reasons:

- astro.config.mjs imported `vercelStatic` from '@astrojs/vercel/static'. That
  subpath was removed in adapter v11, and the import was never used (the config
  has no `adapter:` key at all). Removed it.
- astro 7 makes Satteri the default Markdown processor and no longer bundles
  @astrojs/markdown-remark, which this config needs for rehype-pretty-code and
  remarkReadingTime. Added it as a dependency.
- @tailwindcss/vite could not resolve `vite`: astro 7 ships Vite 8 nested under
  itself rather than hoisted, so the plugin could not see it. Bumped
  @tailwindcss/vite and added an explicit vite 8 dependency.
- typescript was declared as ^7.0.0 while @astrojs/check requires ^5, and
  `astro check` crashes on TS 7 (reading 'fileExists' of undefined). The
  committed lockfile pins 5.9.3, so `npm ci` - what CI actually runs - already
  installed 5. The declaration was simply wrong; aligned it to ^5.9.3.

Then the real API migrations, which `astro check` caught:

- Astro.glob() was removed. Converted all four call sites (src/pages/index.astro,
  src/pages/posts/index.astro, src/pages/tags/index.astro and
  src/pages/tags/[tag].astro) to import.meta.glob(pattern, { eager: true }).
- The MarkdownInstance type was removed. Added a local MarkdownPost interface in
  src/utils/data.util.ts and swapped the annotations in those four pages plus
  src/components/LatestPosts.astro.

Verified: `npm run build` (which is `astro check && astro build`) exits 0 and
emits 27 pages.

Note for review: package-lock.json is regenerated. The committed lock pinned
@astrojs/vercel 9.0.5 and typescript 5.9.3 while package.json asked for ^11 and
^7, so main cannot be built from a clean install in that state.
matt merged commit 90c8a227ce into main 2026-09-17 16:04:42 -04:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
goobercloud/website!9
No description provided.