#Can't import Payload in Next.js project built with Webpack

1 messages · Page 1 of 1 (latest)

ivory agate
#

Hi folks - trying to use the Payload Local API in an existing Next.js project that is built with Webpack. However, it seems that importing payload in a Webpack project is not possible because payload/dist/config/load.js uses require.extensions, so I get this error:

require.extensions is not supported by webpack. Use a loader instead.

Import trace for requested module:
./node_modules/payload/dist/config/load.js
./node_modules/payload/dist/payload.js
./node_modules/payload/dist/index.js
./src/app/payload.ts
./src/app/articles/page.tsx

Any advice on how to move forward with this? Thanks.

dull orbitBOT
ivory agate
#

Going to leave an update here for anyone who might find this:

My solution was to move to the Payload 3 beta, which no longer uses require.extensions for loading config and therefore is compatible with a webpack build.

Will post more about my final setup in my other thread: #1246113121245069354 message