[Plugin] All collections disappear even when returning untouched config from plugin

default discord avatar
sawariz0r
3 months ago
9

So I've ironed out the issues with Webpack I had earlier and got things to run.



/api works fine, all collections and data is visible there.


/admin - while rendering it seems to have some issues figuring out collections to render, etc.



The admin panel seems to have fully reverted to default (users only have the base fields)



The original issue was with providing an empty mockfile/object

module.exports = {}

, but fixed and would render when provided

module.exports = () => () => ({})

which closer resembles the plugin signature.



Double and triple-checked the config returned from the plugin and it contains all collections. Even when returning it immediately it still happens.


Only when I remove the plugin from the plugins:[] the admin panel works as normal.



link to file dump, pre repackaging:


https://github.com/prpldevelopment/plugin-firebase

Ideas? 🙏

  • discord user avatar
    alessiogr
    Payload Team
    3 months ago

    One thing I noticed:



    https://github.com/prpldevelopment/plugin-firebase/blob/main/firebaseNotifications.ts#L128

    Make sure to include potential pre-existing afterchange hooks with the spread operator as well - otherwise, it would break any other plugins adding their own afterchange hooks (as it completely overrides those)



    As for your webpack config:


    https://github.com/prpldevelopment/plugin-firebase/blob/main/extendWebpackConfig.ts#L22

    I'm not sure if it's a good idea to alias the entire firebaseNotifications file. This

    might

    be the reason your collections are disappearing on the client



    I'd make sure all of your server-only code is in a separate file (so extract the server-only code from your firebaseNotifications.ts into another file) and alias that instead

  • default discord avatar
    sawariz0r
    3 months ago
    Make sure to include potential pre-existing afterchange hooks with the spread operator as well - otherwise, it would break any other plugins adding their own afterchange hooks (as it completely overrides those)

    Done! Haven't pushed those updates yet, but I'll give the latter idea a spin. Thanks 🙂



    Guess the fix I put together earlier just hid the actual problems. When not aliasing "firebase-admin" I get os.platform is not a fn.


    And aliasing it gives me the second one.



    Double checked config, looks fine still. Api still works 🥲

    image.png
    image.png
  • discord user avatar
    alessiogr
    Payload Team
    3 months ago

    can you commit the changes, so i can check it out?



    don't think you need the firebase.ts. Also don't think you need any of the webpack fallbacks.



    Should be enough to move the hook contents + all of its firebase imports to its own file, and then alias that file. And no other file, just that one



    Then in the hook in the firebasenotifications.ts file, you just call that function. And make sure you don't import any firebase stuff in the firebase notifications.ts

  • default discord avatar
    sawariz0r
    3 months ago

    Sometimes you just need to sleep on it. Removed the fallbacks and did the things you mentioned, works like a charm! Thanks a bunch 🙏

  • discord user avatar
    alessiogr
    Payload Team
    3 months ago

    Perfect, you're welcome!!

  • default discord avatar
    sawariz0r
    3 months ago

    And the first notification sent from the plugin. Now on to some refactoring 🥳

    IMG_4742.png
Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.