Skip to content

Hot reload not working for collection hooks #5

Open
@jamesvclements

Description

@jamesvclements

I'm working on a plugin that adds a new collection with a few fields and hooks. Hot reload is working perfectly when I add new fields to the new collection—they instantly show up on the dashboard. But if I had new collection hooks, the changes aren't captured. I have to stop and restart the server for changes to the collection's hooks to be picked up.

I tried both anonymous inline functions in beforeChange

hooks: {
    beforeChange: [() => { console.log('only shows up after manually restarting server') }]
}

and importing the hook from a separate file like in the docs:

import { CollectionBeforeChangeHook } from "payload/types";
const beforeChangeHook: CollectionBeforeChangeHook = async ({
}) => {
  console.log('still only shows up after manually restarting server');
};
export default beforeChangeHook;

Any thoughts on why hooks might be cached or not captured, or if I might have something wrong in my set-up?
The collection is being added per the example:

config.collections = [
  ...(config.collections || []),
  // Add additional collections here
  Videos
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions