Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cdk-lib: Typescript template uses obsolete 'source-map-support/register' #30231

Closed
samloibl opened this issue May 16, 2024 · 3 comments · Fixed by #32113
Closed

cdk-lib: Typescript template uses obsolete 'source-map-support/register' #30231

samloibl opened this issue May 16, 2024 · 3 comments · Fixed by #32113
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

Comments

@samloibl
Copy link

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 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

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

@samloibl samloibl added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 16, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label May 16, 2024
@pahud pahud added @aws-cdk/core Related to core CDK functionality p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels May 16, 2024
@pahud
Copy link
Contributor

pahud commented May 16, 2024

Thank you for bringing this to our attention. We'll discuss this with the team.

Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

1 similar comment
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
Projects
None yet
2 participants