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

Relative sourcemap base #327

Merged
merged 2 commits into from
Apr 1, 2019
Merged

Relative sourcemap base #327

merged 2 commits into from
Apr 1, 2019

Conversation

guybedford
Copy link
Contributor

@guybedford guybedford commented Mar 28, 2019

This fixes #319, by ensuring that the source maps paths match up to the input folder, using a custom sourceMapsBasePrefix option.

Ideally the CLI should know to configure this option based on the output directory location relative pathing, but by default it will likely usually be ../.

I compared the source maps here to the ones generated by TypeScript and the output file is pretty much identical now, but when I tried testing with node --inspect-brk in the Chrome dev tools, I still couldn't get the source map to apply.

I ran the source maps in the Webpack visualizer at https://sokra.github.io/source-map-visualization and can confirm they are all working 100%.

The only thing I can think here is either if my local setup isn't running file system source maps for some reason (so @styfle perhaps you can verify your side), or if the Webpack boostrap file is somehow making things invalid as it is the first source ("/webpack/bootstrap"). I tried changing this name to different forms but that didn't seem to make a difference.

Not sure what else to try, but source maps debugging is always like this the first time :)

@guybedford guybedford requested a review from styfle as a code owner March 28, 2019 22:51
@guybedford
Copy link
Contributor Author

There's a really odd CI failure on this one...

@guybedford
Copy link
Contributor Author

Ok I just tested in a TypeScript project and I'm also seeing the source maps not applying there so this may actually be something to do with my setup.

@styfle
Copy link
Member

styfle commented Mar 29, 2019

I had the same problem with the inspector and Chrome in the past couple weeks. Maybe it’s a mismatch between v8 in Node vs Chrome?

Try VS Code and see if that works because the tsc source maps work for me with Code.

I’ll restart CI.

@styfle
Copy link
Member

styfle commented Mar 29, 2019

@guybedford This is really close!

I found that the source map is observed by VS Code, however the line numbers look wrong.

Steps to reproduce

git clone https://github.com/styfle/ncc-bug-sourcemap
cd ncc-bug-sourcemap
git checkout pr327

Working with tsc

yarn build
code . # open with VS Code
node --inspect-brk dist
# Visit the Debugger and select "Attach"

Not working with ncc

# below is my copy of ncc built from your branch
/path/to/ncc/dist/ncc/cli.js build index.ts --source-map --no-source-map-register
code . # open with VS Code
node --inspect-brk dist
# Visit the Debugger and select "Attach"

animated gif

Copy link
Member

@styfle styfle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's room for improvement here since the line numbers don't match up.

@codecov-io
Copy link

Codecov Report

Merging #327 into master will increase coverage by 0.1%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #327     +/-   ##
=========================================
+ Coverage   69.45%   69.55%   +0.1%     
=========================================
  Files          12       12             
  Lines         383      381      -2     
=========================================
- Hits          266      265      -1     
+ Misses        117      116      -1
Impacted Files Coverage Δ
src/index.js 71.51% <100%> (+0.26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 99e71ef...8117ad8. Read the comment docs.

@guybedford
Copy link
Contributor Author

I just tested this out and I can replicate the source maps issue. But in my own test, the source maps worked fine.

I ran the source maps through the checker visualization at https://sokra.github.io/source-map-visualization/#custom and get them lining up correctly, see below.

image

So the above actually seems to be a VSCode / debugger source maps issue. This might be due to Node.js issues with source maps, which are being fixed thanks to the new compileFunction approach which has been worked on by bcoe.

@guybedford guybedford requested a review from styfle March 29, 2019 21:59
Copy link
Member

@styfle styfle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@styfle styfle merged commit 03422c6 into master Apr 1, 2019
@styfle styfle deleted the rel-sourcemaps branch April 1, 2019 12:51
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.

Support source-relative paths in source maps for debugger support
3 participants