Skip to content

An AI-powered search engine with a generative UI

fix: add webpack config to handle ESM modules

Yoshiki Miuraf5358744c729
diff --git a/next.config.mjs b/next.config.mjs
index a89da5cd..5ca38df7 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -21,6 +21,29 @@ const nextConfig = {
pathname: '/**' // Brave search cached images
}
]
+ },
+ webpack: (config, { isServer }) => {
+ // Handle ESM packages that cause issues
+ config.module.rules.push({
+ test: /\.m?js$/,
+ include: /node_modules/,
+ type: 'javascript/auto',
+ resolve: {
+ fullySpecified: false
+ }
+ })
+
+ // Add fallback for problematic modules
+ if (!isServer) {
+ config.resolve.fallback = {
+ ...config.resolve.fallback,
+ fs: false,
+ path: false,
+ crypto: false
+ }
+ }
+
+ return config
}
}