Maybe a clue in github.com/evanw/esbuild/issues/3324
From the Issue thread:
In summary, this runtime error is caused by bundling CJS libraries into ESM context (i.e. bundle express in format: 'esm'). esbuild uses closures to wrap these CJS liraries, and Node.js forbids dynamic (i.e. not at the top level) require on builtin modules.
I would still suggest you to exclude these dependencies from your bundle with --packages=external or --external:express since your runtime supports loading them from the file system, and it also bundles less code.