templates: fix builds for 4.x breaking changes#16888
Merged
Merged
Conversation
Migrate templates to 4.x APIs via @payloadcms/codemod plus manual fixes: - Move storage adapters from plugins to the top-level storage array (#16596) - Rewrite removed @payloadcms/next/{rsc,client} subpaths to @payloadcms/ui in import maps - Replace bare src/ imports with the @/ path alias - Drop the slug generic on Pages/Posts so defaultPopulate stays assignable to the collections array
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖 |
denolfe
commented
Jun 5, 2026
| // This config controls what's populated by default when a post is referenced | ||
| // https://payloadcms.com/docs/queries/select#defaultpopulate-collection-config-property | ||
| // Type safe if the collection slug generic is passed to `CollectionConfig` - `CollectionConfig<'posts'> | ||
| // The slug generic (e.g. CollectionConfig<'pages'>) is intentionally omitted: a slug-typed config is not |
Member
Author
There was a problem hiding this comment.
This is a regression that will need to be addressed separately.
paulpopus
previously approved these changes
Jun 5, 2026
…g-changes # Conflicts: # templates/blank/src/app/(payload)/admin/importMap.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The
build-and-test-templatesCI job was disabled while 4.x breaking changes landed, so the templates drifted and no longer build against current core packages. This updates each template to the new 4.x APIs so they build again.CI for the re-enabled job: payloadcms/payload#16880.
Key Changes
Storage adapters moved from
pluginstostoragestoragearray instead ofplugins(feat!: move storage adapters to storage property instead of plugins for early initialisation #16596).vercelBlobStorage/r2Storagecalls were relocated inwith-vercel-mongodb,with-vercel-postgres,with-vercel-website, andwith-cloudflare-d1. This was the source of theTypeError: plugin is not a functionfailures. Applied with@payloadcms/codemod'smigrate-storage-adapters-to-config.Import maps point at
@payloadcms/uiinstead of removed@payloadcms/nextsubpaths@payloadcms/next/rscand@payloadcms/next/clientsubpaths were removed; generated import maps now reference@payloadcms/ui/rscand@payloadcms/ui. Applied with@payloadcms/codemod'smigrate-next-subpath-exportsacross all templates.Bare
src/imports replaced with the@/path aliassrc/..., which no longer resolves under Turbopack. Switched to the configured@/alias (maps to./src/*).Slug generic dropped on
Pages/Posts(TypeScript 6 regression workaround)CollectionConfig<'pages'>+defaultPopulatepattern compiled under TypeScript 5.7 (3.x) but not under TypeScript 6.0.3 (the feat!: bump minimum typescript version to 6.0.3 #16692 bump): the generated select interface is no longer assignable to theSelectTypethat thecollectionsarray element expects. Dropping the generic letsdefaultPopulatefall back toSelectTypeso the templates build, at the cost of field-name checking ondefaultPopulate. This is a core type regression that affects any 4.x project using the pattern under TS 6, so the real fix belongs in core; the templates carry a commented workaround to be reverted once that lands.Design Decisions
Most changes were applied with
@payloadcms/codemodrather than by hand, so the same transforms users will run produce the same result. Import maps are left as the minimal subpath rewrite rather than a full local regeneration, sincepayload buildregenerates them during the build.Scope is template builds. All six matrix templates build with packed local packages, verified locally via
script:pack --all+build-template-with-local-pkgs.The remaining E2E failures on
blankandwebsite(chunk.reason.enqueueModel is not a functionwhen loading the admin undernext dev) are a pre-existing runtime issue, present before this change and unrelated to the build fixes. Only the workspace templates (blank,website,ecommerce) run E2E in this job;pnpm --filterdoes not match the non-workspace templates, so their E2E and int steps currently no-op.