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

Set sourceRoot in babel-register transform to fix paths in stacks #3608

Merged
merged 1 commit into from Aug 18, 2016
Merged

Set sourceRoot in babel-register transform to fix paths in stacks #3608

merged 1 commit into from Aug 18, 2016

Conversation

danez
Copy link
Member

@danez danez commented Jul 27, 2016

This is the followup of #3523 which was reverted.

This change fixes the stacktraces by setting sourceRoot in the options. This does not touch the sources or file property in the map, but adds a property called sourceRoot. By spec the sourceRoot is prepended to sources and file.

Resolving Sources
If the sources are not absolute URLs after prepending of the “sourceRoot”, the sources are resolved relative to the SourceMap (like resolving script src in a html document).

Printing absolute paths is also more in line with node itself, which prints absolute paths in its traces.

I tested the previously failing project with this change and it worked.

i also thought about tests, but the main blocker right now is that there is no way to unregister babel-register which messes then with other tests. As soon as we merge #3139 it might get possible to write tests and after the test to properly unhook.

@danez danez added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Jul 27, 2016
@codecov-io
Copy link

codecov-io commented Jul 27, 2016

Current coverage is 87.53% (diff: 100%)

No coverage report found for master at 35a258f.

Powered by Codecov. Last update 35a258f...54115fb

@hzoo
Copy link
Member

hzoo commented Jul 27, 2016

We can make a new pr for #3139 with the changes

@just-boris
Copy link

Hello! As far as pirates will not come soon, it there a chance to merge this?

@just-boris
Copy link

Hello again! Any updates about this?

I figured out that source map issue makes my tests unusable.

I have typical React-components folder with the following structure:

app/components/
├── button
│   ├── index.js
│   └── styles.scss
└── table
    ├── index.js
    └── styles.scss

I have an index.js file for each components, but then I run tests with mocha and babel-register hook and I am getting useless error messages.

 TypeError: Cannot read property 'label' of undefined
      at mapStateToProps (index.js:45:17)

I see only filename, but this is index.js which gives me zero information about actual place in source code.

@just-boris
Copy link

Also, I tested this fix, it gives full paths to stacktrace, and doesn't break coverage report.

@hzoo hzoo added this to the Next Patch milestone Aug 9, 2016
@danez danez merged commit ea69362 into babel:master Aug 18, 2016
@danez danez deleted the fix-register-sourcemaps branch August 18, 2016 20:42
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 7, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants