Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

webpack < 5 used to include polyfills

default discord avatar
iokl2 years 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
    2 years 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
    dushybag2 years 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_69948last year

    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

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.