Skip to content

Commit

Permalink
fix(nextjs): resolve Webpack "module not found" errors (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
drichar authored Aug 10, 2024
1 parent fffb747 commit b0eea4d
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions examples/nextjs/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
/** @see https://github.com/WalletConnect/walletconnect-monorepo/issues/1908#issuecomment-1487801131 */
webpack: (config) => {
webpack: (config, { isServer }) => {
/** @see https://github.com/WalletConnect/walletconnect-monorepo/issues/1908#issuecomment-1487801131 */
config.externals.push('pino-pretty', 'lokijs', 'encoding')

/**
* Provide fallbacks for optional wallet dependencies.
* This allows the app to build and run without these packages installed,
* enabling users to include only the wallet packages they need.
* Each package is set to 'false', which means Webpack will provide an empty module
* if the package is not found, preventing build errors for unused wallets.
*/
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
'@agoralabs-sh/avm-web-provider': false,
'@blockshake/defly-connect': false,
'@magic-ext/algorand': false,
'@perawallet/connect': false,
'@perawallet/connect-beta': false,
'@walletconnect/modal': false,
'@walletconnect/sign-client': false,
'lute-connect': false,
'magic-sdk': false
}
}
return config
}
}
Expand Down

0 comments on commit b0eea4d

Please sign in to comment.