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

Support source map pragmas for stack traces #262

Merged
merged 2 commits into from
Nov 24, 2015
Merged

Support source map pragmas for stack traces #262

merged 2 commits into from
Nov 24, 2015

Conversation

novemberborn
Copy link
Member

This is a follow-up to #254. source-map-support can also resolve source maps from pragmas in the source file (or indeed embedded source maps). Now if the files under test are compiled separately but include the pragma, and the source maps are on disk, stack traces will be accurate. Same goes for third-party dependencies that include their source maps.

First commit makes the test explicit, the second commit adds another test for a file that includes a source map pragma. Without the modifications to lib/babel this test fails, but with the modifications it passes.

Explicitly test whether source maps are used to compute stack traces. Before
this was done in a test for reporting uncaught exceptions.
When using source maps to compute stack traces, if the source map is not in
memory, fall back to source-map-support's default retrieval function which can
get it from a source map pragma in the source file.

This means any dependency that has such pragmas (and the required map files) has
its errors mapped correctly, e.g. the code under test, or third-party
dependencies that ship with source maps.

This should also work for inline source maps, though no test case was included.
@sindresorhus
Copy link
Member

Looks good to me.

@jamestalmage
Copy link
Contributor

Hey @novemberborn,

Can we also make sure we are covering the case where the test file itself may have a source map?

This will require making Babel consume incoming source maps. Looking at the Babel 5 options, it seems there is an inputSourceMap option. So it is probably just a matter of retrieving it via sourceMapSupport.retrieveSourceMap(...)

sindresorhus added a commit that referenced this pull request Nov 24, 2015
Support source map pragmas for stack traces
@sindresorhus sindresorhus merged commit fb98d5d into avajs:master Nov 24, 2015
@sindresorhus
Copy link
Member

Looks good. @novemberborn Would be cool if you could do a followup pull request with ⬆️ :)

@novemberborn
Copy link
Member Author

@jamestalmage

Can we also make sure we are covering the case where the test file itself may have a source map?

To clarify, do you mean a case where the test file itself is the result of a compilation step, and then AVA's Babel hook transpiles it again? So we need to provide the input source map, if any, making sure the output source map can map all the way back to the original source?

@novemberborn novemberborn deleted the source-map-pragma branch November 24, 2015 11:04
@jamestalmage
Copy link
Contributor

yep. It's probably a niche case, but it just makes our source-map support complete. If we ever implement alternate compilers, it will be good to have, since we will likely always apply the power-assert transforms.

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.

3 participants