cdk-lib: Typescript template uses obsolete 'source-map-support/register' #30231
Labels
@aws-cdk/core
Related to core CDK functionality
bug
This issue is a bug.
effort/medium
Medium work item – several days of effort
p2
package/tools
Related to AWS CDK Tools or CLI
Describe the bug
When creating a Typescript project via
cdk init app --language typescript
, the generated code importssource-map-support/register
. This library is obsolete, and is not required for node versions12.12.0
or higher (see docs).The library interferes with
tsx
, and results in invalid stack traces (see this bug report).ts-node
does not appear to be affected, but stack traces equally work without the library.Expected Behavior
source-map-support
should not be included inpackage.json
, and not be imported in the .ts file in /bin.When running the synth using
tsx
instead ofts-node
, stack traces for uncaught errors should be correct.Current Behavior
The generated
package.json
file includessource-map-support
as a dependency, and the generated .ts file in /bin includesimport 'source-map-support/register';
When running the synth using
tsx
vianpx tsx bin/<project>.ts
, the stack trace will be incorrect, and point to an incorrect line number:Reproduction Steps
Possible Solution
Remove the library from dependencies, and remove the import
Changes required:
aws-cdk/packages/aws-cdk/lib/init-templates/app/typescript/bin/%name%.template.ts
Line 2 in 7624c62
aws-cdk/packages/aws-cdk/lib/init-templates/app/typescript/package.json
Line 25 in 7624c62
Additional Information/Context
No response
CDK CLI Version
2.141.0 (build 3d1c06e)
Framework Version
No response
Node.js Version
v20.11.1, v18.17.0, v16.20.2
OS
OSX
Language
TypeScript
Language Version
5.4.5
Other information
No response
The text was updated successfully, but these errors were encountered: