Skip to content

templates: fix builds for 4.x breaking changes#16888

Merged
denolfe merged 3 commits into
mainfrom
templates/fix-breaking-changes
Jun 5, 2026
Merged

templates: fix builds for 4.x breaking changes#16888
denolfe merged 3 commits into
mainfrom
templates/fix-breaking-changes

Conversation

@denolfe

@denolfe denolfe commented Jun 4, 2026

Copy link
Copy Markdown
Member

Overview

The build-and-test-templates CI 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 plugins to storage

  • Import maps point at @payloadcms/ui instead of removed @payloadcms/next subpaths

    • The @payloadcms/next/rsc and @payloadcms/next/client subpaths were removed; generated import maps now reference @payloadcms/ui/rsc and @payloadcms/ui. Applied with @payloadcms/codemod's migrate-next-subpath-exports across all templates.
  • Bare src/ imports replaced with the @/ path alias

    • Website-based templates imported from src/..., which no longer resolves under Turbopack. Switched to the configured @/ alias (maps to ./src/*).
  • Slug generic dropped on Pages / Posts (TypeScript 6 regression workaround)

    • The documented CollectionConfig<'pages'> + defaultPopulate pattern 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 the SelectType that the collections array element expects. Dropping the generic lets defaultPopulate fall back to SelectType so the templates build, at the cost of field-name checking on defaultPopulate. 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/codemod rather 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, since payload build regenerates 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 blank and website (chunk.reason.enqueueModel is not a function when loading the admin under next 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 --filter does not match the non-workspace templates, so their E2E and int steps currently no-op.


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
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

📦 esbuild Bundle Analysis for payload

This analysis was generated by esbuild-bundle-analyzer. 🤖
This PR introduced no changes to the esbuild bundle! 🙌

@denolfe denolfe marked this pull request as ready for review June 5, 2026 01:46
// 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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a regression that will need to be addressed separately.

paulpopus
paulpopus previously approved these changes Jun 5, 2026
…g-changes

# Conflicts:
#	templates/blank/src/app/(payload)/admin/importMap.js
@denolfe denolfe merged commit e19b0d7 into main Jun 5, 2026
22 of 24 checks passed
@denolfe denolfe deleted the templates/fix-breaking-changes branch June 5, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants