question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot get URLs to map via sourceURL= to local files (same files map in Chrome DevTools)

See original GitHub issue

I initially filed this under “Other” because I didn’t have a great test case, but I have subsequently created one – see below.

I can’t get URLs executed via eval()ed source code that uses //# sourceURL=[url] to specify the source location to map to local files when developing.

I’ve created a GitHub gist to illustrate.

Steps to reproduce:

  1. Clone the gist into a directory.
  2. Start a server that serves that directory.
  3. Copy launch.json to .vscode/launch.json (sorry, gists cannot contain directories)
  4. Open VSCode to that directory
  5. Start a Chrome instance with the debugger on port 9222

Test case 1: Open browser to [server]/index.html

This will cause the sourceURL "eval.js" to be used for the evaluated eval.js script. Note that the script.js script maps correctly, but that VSCode will not map the eval.js script to the local eval.js (Chrome DevTools will, if you mount the directory in the Filesystems tab.)

Test case 2: Open browser to [server]/index.html?full

This will cause the sourceURL "[server]/eval.js" to be used for the evaluated eval.js script. Note that VSCode will not map the script to the local eval.js (Chrome DevTools will, if you mount the directory in the Filesystems tab.)

Should this work? Or am I on the wrong path?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
davidpcaldwellcommented, Feb 26, 2022

Fascinating, I was trying to debug in VSCode, couldn’t get my breakpoints to be hit, searched the issue database, saw this issue that looked like it might be relevant, opened it, and:

  1. Found that I was the reporter of the original issue,
  2. Found that I’d been given some advice about how to resolve the issue,
  3. Found that that advice worked.

Glad the internet has a better memory than I do!

1reaction
davidpcaldwellcommented, Dec 19, 2020

Just to be super-clear, though, in my case they’d be unbound at the beginning, then I could hit a debugger statement and bind them, and they’d remain bound until I refreshed (i.e., reloaded the page, or restarted from the debugger), when I could (in real time) watch them become unbound again. Don’t know if that’s helpful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't find javascript source map to debug in chrome devtools
Open DevTools · Open source tab · Open the minified JS file · Right-click in source code (editor) area · Select the option,...
Read more >
"Map to File System Resources" option missing from pop-up ...
I am trying to set up my DevTools workspace so that I can save changes directly to my site files, but I am...
Read more >
Map the processed code to your original source code, for ...
Source maps map your compiled, minified code to your original source code files. In DevTools, you can then read and debug your familiar, ......
Read more >
Map Preprocessed Code to Source Code - Chrome Developers
Use source maps to map your source code to your compiled code. ... DevTools to load your original files in addition to your...
Read more >
4 Reasons Why Your Source Maps are Broken - Sentry Blog
To do that, browser agents expect your bundled JavaScript files to ... Using UglifyJS 3.3 $ uglifyjs --source-map url=script.min.js.map ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found