upgrade astro to v7 (astro 5 -> 7, with the required API migrations) #9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "astro-7"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:
astro.config.mjsimportedvercelStaticfrom@astrojs/vercel/static. Adapter v11 removed that subpath - and the import was never used (the config has noadapter:key at all). Removed it.@astrojs/markdown-remark, which this config needs forrehype-pretty-codeandremarkReadingTime. Added it.@tailwindcss/vitecould not resolve it. Bumped@tailwindcss/viteto 4.3.3 and added an explicitvite@^8.@astrojs/checkrequires ^5 andastro checkcrashes on TS 7 (Cannot read properties of undefined (reading 'fileExists')). The committed lockfile pins 5.9.3, sonpm ci- what CI runs - already installed TS 5. Declared ^5.9.3 to match reality.Real API migrations
astro checkthen caught the parts that actually need code changes:Astro.glob()was removed. Converted all four call sites toimport.meta.glob(pattern, { eager: true })- the same pattern used in the sibling site.MarkdownInstancetype was removed. Added a localMarkdownPostinterface insrc/utils/data.util.tsand swapped the annotations in those four pages plussrc/components/LatestPosts.astro.Verification
On a clean checkout of this branch, running exactly what CI runs:
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.jsonis regenerated. The committed lock pinned@astrojs/vercel@9.0.5andtypescript@5.9.3whilepackage.jsonasked for^11and^7.maincannot 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 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.