payload icon indicating copy to clipboard operation
payload copied to clipboard

perf: reduce memory usage and improve speed during dev, by caching payload config & sanitization

Open AlessioGr opened this issue 1 year ago • 0 comments

Previously, during dev, the payload config would be loaded and sanitized between every single page transition twice. This lead to higher memory usage during dev. This PR makes sure it only happens once when payload is started.

This PR does not change the behavior in prod, as it was already cached nicely there. It will only affect dev

How to use

If you don't change anything, everything will still work and you will get no performance improvements. => Backwards-compatible and non-breaking.

To benefit from improved performance and lower memory usage, simply wrap your payload config argument in a function:

- buildConfig({
+ buildConfig(() => ({
   // Config here
- })
+ }))

Todo

Get HMR to work

AlessioGr avatar Nov 25 '24 06:11 AlessioGr