ホーム 記事一覧 ブック DH週間トピックス 検索 このサイトについて
English

Astro 4 から 5 へのアップグレード記録

背景 Astro 4 + MDX + Tailwind CSS で構築していたウェブサイトで、pnpm の overrides により astro 5.x が強制的にインストールされる状態になっていました。@astrojs/mdx@2.x(Astro 4 用)と astro 5.x の間で互換性がなく、ビルドが失敗していました。 Package subpath './jsx/renderer.js' is not defined by "exports" in astro/package.json Astro 4 に戻すよりも、Astro 5 へアップグレードする方が合理的と判断し、移行を実施しました。 変更点 1. パッケージの更新 // Before "@astrojs/mdx": "^2.0.0", "astro": "^4.0.3" // After "@astrojs/mdx": "^4.0.0", "astro": "^5.0.0" @astrojs/tailwind と tailwindcss はそのままです。 2. Content Collections の type 指定を削除 Astro 5 では defineCollection の type: "content" が不要になりました。 // Before const news = defineCollection({ type: "content", schema, }); // After const news = defineCollection({ schema, }); 3. entry.slug から entry.id への変更 Astro 5 では Content Collections の slug プロパティが廃止され、id に統一されました。 ...