From 83ba1aa37318f39e3faa753445fcd9e84016aae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Guti=C3=A9rrez?= <35082514+alezmad@users.noreply.github.com> Date: Thu, 9 Apr 2026 00:26:06 +0100 Subject: [PATCH] fix(web): restore serverExternalPackages for Payload + use --webpack for build Root cause: Next.js 16 defaults to Turbopack for builds, but Payload CMS's richtext-lexical imports .css files that fail during route collection in Node ESM context. Fix: add @payloadcms/richtext-lexical and @payloadcms/next back to serverExternalPackages so Next.js skips their internal imports during route collection. Use --webpack explicitly since Turbopack production builds are incompatible with Payload (payloadcms/payload#14786). Co-Authored-By: Claude Sonnet 4.6 --- apps/web/next.config.ts | 2 ++ apps/web/package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index 4d69822..7014e2e 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -87,6 +87,8 @@ const config: NextConfig = { "payload", "@payloadcms/db-postgres", "@payloadcms/db-sqlite", + "@payloadcms/richtext-lexical", + "@payloadcms/next", "sharp", ], turbopack: { diff --git a/apps/web/package.json b/apps/web/package.json index 9d0a1b9..b3f56e3 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -4,7 +4,7 @@ "private": true, "type": "module", "scripts": { - "build": "next build", + "build": "next build --webpack", "clean": "git clean -xdf .cache .next .turbo node_modules", "dev": "next dev", "format": "prettier --check . --ignore-path ../../.gitignore",