From 3258c04ac63cefc6af32340b02bda93aa0944fb8 Mon Sep 17 00:00:00 2001 From: Richard R Date: Wed, 10 Jun 2026 14:26:40 -0600 Subject: [PATCH] build(config): add custom externals mapping for @napi-rs/canvas in server webpack Configure webpack to treat @napi-rs/canvas as an external dependency under the 'canvas' module name when building the server bundle. This adjustment ensures proper module resolution and avoids bundling native dependencies directly, improving deployment reliability for environments requiring @napi-rs/canvas. --- next.config.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/next.config.ts b/next.config.ts index 78947e8..1cf8c6b 100644 --- a/next.config.ts +++ b/next.config.ts @@ -80,6 +80,14 @@ const nextConfig: NextConfig = { ], }, webpack: (config, { isServer }) => { + if (isServer) { + config.externals = [ + ...(config.externals || []), + { + canvas: 'commonjs @napi-rs/canvas', + }, + ]; + } if (isServer && bundleWorkerCompute) { config.resolve.alias = { ...(config.resolve.alias || {}),