sourceURL injected into scripts for custom elements

37 views
Skip to first unread message

Rick Byers

unread,
Jul 11, 2013, 2:53:23 PM7/11/13
to polymer-dev
Hi,
What is the purpose of the '//# sourceURL' tag that gets added to the end of evaled scripts in HTMLElementElement.js?  Mapping back to the original file would make sense if the lines matched up or if there were sourcemaps available to map the locations, but otherwise it just seems to make debugging more difficult.

In particular, I can debug my web components scripts with DevTools alright in the simple scenario, but when working on a larger project I prefer to use DevTools workspaces feature where it maps network URLs to my on disk resources so I can edit inline easily.  When this is enabled, debugging is broken - dev tools jumps to the files from disk but since the line numbers don't match those from the evalled scripts I'm always at the wrong position.  For my purposes I've found it most convenient to just disable the code that adds the '//# sourceURL' tokens.

I'm guessing there's no reasonable way to generate a source map on the fly, but perhaps we could just add the necessary blank lines so that the line numbers in the eval'd script line up with the original line numbers of the source file?

Thanks,
   Rick

Eric Bidelman

unread,
Jul 11, 2013, 4:38:26 PM7/11/13
to Rick Byers, paul...@chromium.org, polymer-dev
+paulirish might have some ideas from the workspaces perspective




--
 
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
Visit this group at http://groups.google.com/group/polymer-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/CAFUtAY-Od%2BVyDmSsEcK5Y4vw-rayPmZRVSOHYn%3D8E6b3zuc99Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Scott Miles

unread,
Jul 11, 2013, 4:47:55 PM7/11/13
to Eric Bidelman, Rick Byers, paul...@chromium.org, polymer-dev
The reason those sourceUrls are generated is so that those blocks of code are sanely named for debugging. Otherwise they are anonymous scripts and it's impossible to find your component code or set breakpoints.

I'm confused how removing them does anything good, because at that point those scripts are completely disembodied from any source files (in terms of being live script). However, I admit to being a `workspace` n00b, so we will have to try it out and see what you are seeing.

Scott


Rick Byers

unread,
Jul 11, 2013, 5:01:57 PM7/11/13
to Scott Miles, Eric Bidelman, paul...@chromium.org, polymer-dev
On Thu, Jul 11, 2013 at 4:47 PM, Scott Miles <sjm...@google.com> wrote:
The reason those sourceUrls are generated is so that those blocks of code are sanely named for debugging. Otherwise they are anonymous scripts and it's impossible to find your component code or set breakpoints.

Yeah I started hitting this too - I agree it's not what we'd want.  I've switched now to just munging the name so it doesn't match the URL and trigger the workspace logic (eg. add a 'GENERATED_' prefix, or simply use the short name instead of the full url as the sourceURL), but still gives me a useful name.

I'm confused how removing them does anything good, because at that point those scripts are completely disembodied from any source files (in terms of being live script). However, I admit to being a `workspace` n00b, so we will have to try it out and see what you are seeing.

I was originally just stopping on exceptions which worked fine.  But yeah setting breakpoints is important too. 
Reply all
Reply to author
Forward
0 new messages