Skip to content

Fix coffee script stack traces in tests - #567

Merged
arthurschreiber merged 2 commits into
masterfrom
arthur/fix-coffee-script-stack-traces-in-tests
Apr 11, 2017
Merged

arthurschreiber merged 2 commits into
masterfrom
arthur/fix-coffee-script-stack-traces-in-tests

Conversation

@arthurschreiber

Copy link
Copy Markdown
Collaborator

While looking through the travis errors of #566 at https://travis-ci.org/tediousjs/tedious/jobs/220815074, I noticed that the stack traces for Coffee Script code are all messed up.

After some fiddling around, I figured out that this is because both coffee-script/register as well as babel-register (via source-map-support) install a custom Error.prepareStackTrace function, and the former gets overwritten by the latter.

Fortunately, coffee-script/register generates inline source maps in the transpilation result, and source-map-support has optional support for these source maps, but it's not enabled in babel-register. But enabling it is easy, so we can make sure stack traces look good for code transpiled through coffee-script as well as babel. 👍

Both `coffee-script` as well as `source-map-support` (loaded through `babel-register`) patch `Error.prepareStackTrace` to modify stack traces to point to correct error locations for transpiled code. Unfortunately, these two patches don't play well together.

But `coffee-script/register` automatically generates inline source maps, which `source-map-support` has support for via the `hookRequire` option. So in the end, we can make those two play together by configuring `source-map-support` correctly.
@arthurschreiber
arthurschreiber merged commit e22fbc3 into master Apr 11, 2017
@arthurschreiber
arthurschreiber deleted the arthur/fix-coffee-script-stack-traces-in-tests branch April 11, 2017 07:10
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.

1 participant