Failed to build react-square-web-payments-sdk library with nextjs project

Hello developer, I’m currently building an integration of React Square Web Payments SDK with NextJS. I am getting build error below. Don’t able to understand why am getting this error in nextjs. Kindly help me here.

Dependency packages:

Error: require() of ES Module D:\nft-nxtjs\NFT-NEXT\node_modules@square\web-sdk\dist\index.js from D:\nft-nxtjs\NFT-NEXT\node_modules\react-square-web-payments-sdk\dist\rswps.cjs.js not supported. Instead change the require of index.js in D:\nft-nxtjs\NFT-NEXT\node_modules\react-square-web-payments-sdk\dist\rswps.cjs.js to a dynamic import() which is available in all CommonJS modules.

I haven’t verified this with next@12 but hopefully gets you pointed in the right direction Cannot Find Module · Issue #56 · square/web-sdk · GitHub