Problem:
AWS CDK version 2 synth error when bundling a NodejsFunction with somewhat complicated Typescript source code.
Error:
RangeError: Maximum call stack size exceeded
Solution:
Upgrade to a more recent version of npm package "esbuild". In this case, upgrading to version 0.19.12 resolve the issue even though this isn't the most recent version available. Other third party npm package constraints did not allow the latest version to be installed. npm i -D esbuild@0.19.12