Skip to content

fix(app): add source map support to TypeScript apps - #1581

Merged
rix0rrr merged 1 commit into
aws:masterfrom
mifisignal:source-code-map
Feb 4, 2019
Merged

rix0rrr merged 1 commit into
aws:masterfrom
mifisignal:source-code-map

Conversation

@mifisignal

@mifisignal mifisignal commented Jan 20, 2019 •

Copy link
Copy Markdown

Add source map support to the TypeScript app entry point template.
This won't retroactively fix existing CDK apps, but it will ensure
that apps generated in the future via cdk init --app will have
it enabled.

Fixes #1579


Pull Request Checklist

  • Testing
    • Unit test added
    • CLI change?: manually run integration tests and paste output as a PR comment
    • cdk-init template change?: coordinated update of integration tests with team
  • Docs
    • jsdocs: All public APIs documented
    • README: README and/or documentation topic updated
  • Title and Description
    • Change type: title prefixed with fix, feat will appear in changelog
    • Title: use lower-case and doesn't end with a period
    • Breaking?: last paragraph: "BREAKING CHANGE: <describe what changed + link for details>"
    • Issues: Indicate issues fixed via: "Fixes #xxx" or "Closes #xxx"
  • Sensitive Modules (requires 2 PR approvers)
    • IAM Policy Document (in @aws-cdk/aws-iam)
    • EC2 Security Groups and ACLs (in @aws-cdk/aws-ec2)
    • Grant APIs (only if not based on official documentation with a reference)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.

@mifisignal
mifisignal requested a review from a team as a code owner January 20, 2019 20:43
@mifisignal mifisignal changed the title (fix)app: add source map support to Typescript apps (fix)app: add source map support to TypeScript apps Jan 20, 2019
@mifisignal mifisignal changed the title (fix)app: add source map support to TypeScript apps fix(app): add source map support to TypeScript apps Jan 20, 2019
@mifisignal
mifisignal force-pushed the source-code-map branch 2 times, most recently from c0ef0d5 to cb248d6 Compare January 20, 2019 20:46
@rix0rrr

rix0rrr commented Jan 21, 2019

Copy link
Copy Markdown
Contributor

"source-map-support" also needs to be added as a dependency to package.json if we're going this route.

But I seem to recall we disabled this on purpose, I just don't remember why. @eladb, do you?

You can also get source map support by default on your machine by setting the following environment variable:

export NODE_OPTIONS="-r source-map-support"
cdk deploy

No need to change any files.

@eladb

eladb commented Jan 21, 2019

Copy link
Copy Markdown
Contributor

Source map support makes sense only if you actually have the sources on your machine, and most of our users don’t have them available. Moreover, there isn’t uncommon in the JavaScript world to source locations in stack trace output to jump into the JavaScript code, add a “printf debug” in order to diagnose a problem.

We can totally recommend Rico’s approach in our contribution guide for people who are debugging with sources

@rix0rrr

rix0rrr commented Jan 21, 2019

Copy link
Copy Markdown
Contributor

Although all source-map-support does is hook up to the NodeJS API and translate any stack traces using the source map in the source files.

I guess we might enable it by default from the toolkit or sth?

@mifisignal

mifisignal commented Jan 21, 2019 •

Copy link
Copy Markdown
Author

I'm a bit puzzled here. The context in question is a TypeScript app. When will one not have the sources for one's own app and its dependencies?

Having the correct lines in the stack trace, especially when the trace results from an error in user code (stacks, libs, etc.), makes for a pleasant UX. If it's possible to make this easy, let's make it work out of the box by default instead of asking the customer to do any gymnastics.

Add source map support to the TypeScript app entry point template.
This won't retroactively fix existing CDK apps, but it will ensure
that apps generated in the future via `cdk init --app` will have
it enabled.

Fixes aws#1579
@mifisignal

mifisignal commented Jan 21, 2019 •

Copy link
Copy Markdown
Author

@rix0rrr Added source-map-support to the package.json template.

@rix0rrr

rix0rrr commented Jan 24, 2019

Copy link
Copy Markdown
Contributor

I actually also feel we can merge this. It's what most people are going to want, and those that don't will be savvy enough to remove it.

@eladb

eladb commented Jan 29, 2019

Copy link
Copy Markdown
Contributor

okay by me

@rix0rrr
rix0rrr merged commit 5df22d9 into aws:master Feb 4, 2019
moofish32 pushed a commit to moofish32/aws-cdk that referenced this pull request Feb 5, 2019
Add source map support to the TypeScript app entry point template.
This won't retroactively fix existing CDK apps, but it will ensure
that apps generated in the future via `cdk init --app` will have
it enabled.

Fixes aws#1579
ali-n4i pushed a commit to ali-n4i/aws-cdk that referenced this pull request Jul 29, 2026
Add source map support to the TypeScript app entry point template.
This won't retroactively fix existing CDK apps, but it will ensure
that apps generated in the future via `cdk init --app` will have
it enabled.

Fixes aws#1579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document how to enable source map support

4 participants