Home

>

Tools

>

Payload CMS

>

Releases

>

3.0.0-beta.49

Payload CMS Release: 3.0.0-beta.49

Pre Release

Tag Name: v3.0.0-beta.49

Release Date: 6/17/2024

Payload CMS LogoPayload CMS

Payload CMS is a modern, self-hosted headless content management system built with TypeScript, Node.js, and MongoDB. It's designed specifically for developers who want full control over their content management system while maintaining a powerful admin interface for content editors.

TL;DR

PayloadCMS v3.0.0-beta.49 introduces significant performance improvements through pre-bundling the UI library and simplifying import paths. This release dramatically speeds up compile times while cleaning up the export structure. However, it includes breaking changes that require updating import statements in your code.

Highlight of the Release

    • Dramatically improved compile times through UI library pre-bundling
    • Simplified import structure with most exports now available directly from 'payload'
    • New barrel files (@payloadcms/ui/client and @payloadcms/ui/server) for optimized imports
    • Component CSS now automatically included with individual component imports

Migration Guide

Updating Import Paths

For PayloadCMS Core Imports:

  • Replace subpath imports with direct imports from 'payload'
  • Before: import { buildConfig } from 'payload/config'
  • After: import { buildConfig } from 'payload'

For UI Components in Admin UI:

  • Use the new barrel files instead of direct component paths
  • Before: import { Button } from '@payloadcms/ui/elements/Button'
  • After: import { Button } from '@payloadcms/ui/client'

For Template Imports:

  • Update template imports to use the new location
  • Before: import { Default } from '@payloadcms/ui/templates/Default'
  • After: import { Default } from '@payloadcms/next/templates'

For Icon Components:

  • Note that some components have been renamed for clarity
  • Before: import { LogOut } from '@payloadcms/ui/icons/LogOut'
  • After: import { LogOutIcon } from '@payloadcms/ui/icons/LogOut'

External Applications

If you're using PayloadCMS UI components in your own frontend applications (outside the admin UI), you can continue importing directly from component paths. These imports will now automatically include the necessary CSS.

Upgrade Recommendations

This is a beta release with significant breaking changes to import paths, but with major performance benefits. We recommend:

  1. For Development Environments: Upgrade to take advantage of the performance improvements, but be prepared to update import paths throughout your codebase.

  2. For Production Environments: Consider waiting for the stable 3.0.0 release unless compile time performance is a critical issue in your workflow.

  3. Testing Process: After upgrading, thoroughly test your admin UI customizations and any external applications that use PayloadCMS UI components.

The performance benefits make this upgrade worthwhile for most development environments, despite the breaking changes.

Bug Fixes

No specific bug fixes were mentioned in this release.

New Features

Simplified Import Structure

PayloadCMS now exposes a cleaner, more intuitive import structure with just three main exports:

  1. payload - Contains all types and server-only PayloadCMS code
  2. payload/shared - Utilities that work in both browser and Node environments
  3. payload/node - Heavy utilities intended only for Node scripts

This means most imports can now come directly from 'payload' rather than various subpaths, significantly simplifying the mental model for developers.

Pre-bundled UI Library

The UI package has been pre-bundled for use within the PayloadCMS admin, introducing two new export paths:

  1. @payloadcms/ui/client - All client components in a single barrel file
  2. @payloadcms/ui/server - All server components in a single barrel file

This optimization keeps compile times fast and admin UI bundle sizes small.

Improved Component CSS Handling

Individual component exports now include their corresponding CSS automatically, making it easier to use PayloadCMS UI components in external applications without bloating your app with unused styles.

Security Updates

No security fixes were mentioned in this release.

Performance Improvements

Dramatic Compile Time Improvements

This release significantly speeds up compile times by pre-bundling the entire UI package. The new approach:

  1. Creates optimized barrel files that reduce the number of imports needed
  2. Implements a smarter CSS bundling strategy that avoids loading unnecessary styles
  3. Reduces the compiler's workload by minimizing the number of files it needs to process

The result is a "pretty awesome initial compilation performance boost" as mentioned in the release notes, making local development much faster and more efficient.

Impact Summary

This release represents a significant architectural improvement for PayloadCMS, focusing on developer experience and build performance. By pre-bundling the UI library and simplifying import paths, the team has addressed one of the most common pain points in large PayloadCMS projects: slow compile times.

The changes will require some refactoring of import statements in existing projects, but the performance gains and simplified mental model should more than compensate for this one-time effort. The new approach is particularly beneficial for projects with extensive admin UI customizations.

The release also improves the experience of using PayloadCMS UI components in external applications by automatically including component CSS, eliminating the need for manual style imports.

Overall, this beta release demonstrates PayloadCMS's commitment to performance optimization and developer experience improvements as they move toward the stable 3.0 release.

Full Release Notes

v3.0.0-beta.49 (2024-06-17)

Features

đźš§ BREAKING CHANGES

New file import locations

Exports from the payload package have been significantly cleaned up. Now, just about everything is able to be imported from payload directly, rather than an assortment of subpath exports. This means that things like import { buildConfig } from 'payload/config' are now just imported via import { buildConfig } from 'payload'. The mental model is significantly simpler for developers, but you might need to update some of your imports.

Payload now exposes only three exports:

  1. payload - all types and server-only Payload code
  2. payload/shared - utilities that can be used in either the browser or in Node environments
  3. payload/node - heavy utilities that should only be imported in Node scripts and never be imported into bundled code like Next.js

UI library pre-bundling

With this release, we've dramatically sped up the compile time for Payload by pre-bundling our entire UI package for use inside of the Payload admin itself. There are new exports that should be used within Payload custom components:

  1. @payloadcms/ui/client - all client components
  2. @payloadcms/ui/server - all server components

For all of your custom Payload admin UI components, you should be importing from one of these two pre-compiled barrel files rather than importing from the more deeply nested exports directly. That will keep compile times nice and speedy, and will also make sure that the bundled JS for your admin UI is kept small.

For example, whereas before, if you imported the Payload Button, you would have imported it like this:

import { Button } from '@payloadcms/ui/elements/Button'

Now, you would import it like this:

import { Button } from '@payloadcms/ui/client'

This is a significant DX / performance optimization that we're pretty pumped about.

However, if you are importing or re-using Payload UI components outside of the Payload admin UI, for example in your own frontend apps, you can import from the individual component exports which will make sure that the bundled JS is kept to a minimum in your frontend apps. So in your own frontend, you can continue to import directly to the components that you want to consume rather than importing from the pre-compiled barrel files.

Individual component exports will now come with their corresponding CSS and everything will work perfectly as-expected.

Specific exports have changed

  • '@payloadcms/ui/templates/Default' and '@payloadcms/ui/templates/Minimal' are now exported from '@payloadcms/next/templates'
  • Some components are now more explicitly named while being exported, such as the LogOut icon. Old: import { LogOut } from '@payloadcms/ui/icons/LogOut' New: import { LogOutIcon } from '@payloadcms/ui/icons/LogOut'

Background info

In effort to make local dev as fast as possible, we need to import as few files as possible so that the compiler has less to process. One way we've achieved this in the Admin Panel was to remove all .scss imports from all components in the @payloadcms/ui module using a build process. This stripped all import './index.scss' statements out of each component before injecting them into dist. Instead, it bundles all of the CSS into a single main.css file, and we import that at the root of the app.

While this concept is still the right solution to the problem, this particular approach is not viable when using these components outside the Admin Panel, where not only does this root stylesheet not exist, but where it would also bloat your app with unused styles. Instead, we need to keep these .scss imports in place so they are imported directly alongside your components, as expected. Then, we need create a new build step that separately compiles the components without their stylesheets—this way your app can consume either as needed from the new client and server barrel files within @payloadcms/ui, i.e. from within @payloadcms/next and all other admin-specific packages and plugins.

This way, all other applications will simply import using the direct file paths, just as they did before. Except now they come with stylesheets.

And we've gotten a pretty awesome initial compilation performance boost.

Contributors

Statistics:

File Changed300
Line Additions758
Line Deletions791
Line Changes1,549
Total Commits2

User Affected:

  • Need to update import paths for PayloadCMS components
  • Will benefit from simplified import structure and faster compile times
  • Must adapt to new bundling approach for custom admin UI components

Contributors:

jacobsfletchdenolfe