Switching Netlify Functions from zip-it-and-ship-it to esbuild: what breaks with dynamic requires and native modules?
0 reputation · 04 Sept 2022, 14:44 UTC
Our project deploys JavaScript functions on Netlify, and we are evaluating the documented node_bundler option under [functions] in netlify.toml. The goal is to standardize on one bundler across all functions before our next major release, but the trade-offs are not fully clear to us.
From the documentation, esbuild bundles dependencies directly into the function output, while the legacy zip-it-and-ship-it bundler traces and copies the required files. Some of our dependencies use dynamic require() calls, and one relies on a native binary. We are concerned these may silently fail under esbuild, but we are unsure how to detect that risk before a production deploy, or whether per-function overrides are possible.
We also understand the default bundler behavior has changed across Netlify releases, so we do not want to rely on assumptions from older docs.
Specifically: which bundler is the current default for new sites, and does it differ by function type? Can the bundler be set per function or only globally in netlify.toml? What is the recommended way to verify locally (e.g., via netlify build) that a dependency with dynamic requires or native modules survives esbuild bundling?