Sigfried
Sigfried

Reputation: 3100

How do I make eval'd javascript code accessible to the debugger?

I just spent a long time trying to figure out how to use source maps to get eval'd javascript code to show up in the debugger where I could put break points on it and stuff. I kept seeing hints that it was possible, but most of what I read had to do with source mapping minified code or CoffeeScript, and generally it all seemed impossibly complicated. But then I stumbled on the answer, which was ridiculously easy, and I'll answer my own question below.

Upvotes: 2

Views: 241

Answers (1)

Sigfried
Sigfried

Reputation: 3100

Just put this at the end of the eval block:

//@ sourceURL=foo.js

In the Chrome sources panel, foo.js now shows up under '(no domain)'.

Upvotes: 1

Related Questions