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.
This commit is contained in:
Richard R 2026-06-10 14:26:40 -06:00
parent 2d205008ef
commit 3258c04ac6

View file

@ -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 || {}),