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 versions 12.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 in package.json, and not be imported in the .ts file in /bin.
When running the synth using tsx instead of ts-node, stack traces for uncaught errors should be correct.
Current Behavior
The generated package.json file includes source-map-support as a dependency, and the generated .ts file in /bin includes import 'source-map-support/register';
When running the synth using tsx via npx tsx bin/<project>.ts, the stack trace will be incorrect, and point to an incorrect line number:
Error: Duh!
at new TsxIssue447Stack (/Users/me/tsx-issue447/lib/tsx-issue447-stack.ts:2:1366)
at /Users/me/tsx-issue447/bin/tsx-issue447.ts:3:950
at Object.<anonymous> (/Users/me/tsx-issue447/bin/tsx-issue447.ts:4:3)
Reproduction Steps
nvm use 20
mkdir tsx-issue447 && cd tsx-issue447
npx cdk init app --language typescript
sed -i.bak 's/\/\/ The code.*$/throw new Error("Duh!");/' lib/tsx-issue447-stack.ts
npx tsx bin/tsx-issue447.ts
Possible Solution
Remove the library from dependencies, and remove the import
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:
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