webpack < 5 used to include polyfills

default discord avatar
iokl
10 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
    10 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
    dushybag
    8 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

  • default discord avatar
    ignasi_69948
    last month

    Hi, I can't manage to create an alias or to run it compiling with tsc. I'm new to typescript. How should I create an alias? Documentation is not clear enough for me

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.