Without --platform=node, esbuild assumes a browser: it uses the browser field in package.json when present, prefers browser export conditions, does not treat Node builtins as external, and defaults the output format to iife.
Building a server entry point this way produces confusing errors. Importing node:fs yields Could not resolve "fs" with a hint about the platform, or a bundle that inlines a browser shim for a Node module. If the code does resolve, the iife wrapper means exports is not populated, so a CommonJS consumer of the output gets an empty object.
Pass --platform=node, which switches the default format to cjs, marks Node builtins external, and prefers the node export condition and the main field. Set --format=esm explicitly if the output is meant to be an ES module, and remember that changing the format changes which conditions the resolver picks, so a package can resolve to a different file in the two builds.