webpack < 5 used to include polyfills

default discord avatar
Wandering Nerd
4 months ago
3

I'm using the Next.js starter template and trying to make API calls using afterChange hook to third party services using their SDK, but that results in 100s of the following exception.



BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.


This is no longer the case. Verify if you need this module and configure a polyfill for it.



It works normally on the Next.js side though. Any idea on how to resolve this? StackOverflow answers do not work for me as none talks about 100s of exception at the same time.

  • discord user avatar
    denolfe
    Payload Team
    3 months ago

    Your hook is likely pulling in a library for server-only code. You'll need to alias that code. Documentation here:

    https://payloadcms.com/docs/admin/webpack#aliasing-server-only-modules
  • default discord avatar
    Dushyant
    2 months ago

    Hi, apparently this documentation is for working with JavaScript, but the same thing doesn't work with TypeScript (I'm guessing the final path of the compiled TS file is different?). Is there any documentation for this?



    NVM I resolved this. The thing wasn't working with

    ts-node

    , but when I compiled the project with

    tsc

    and then run it, it worked

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.