weixin_39605326 2020-11-30 15:19
浏览 0

Provide original file/line number support for concatenated JavaScript files

Originally reported on Google Code with ID 2423


Say you're developing a complex web app with many JS files.  You will
typically serve your page with your JS files merged into one or two files
for loading efficiency.

It would be nice if Firebug had some way of detecting this and reporting JS
errors with the *original* file's URL and the *original* file's line
numbers, rather than the line numbers in the honking concatenated file.

[NOTE: I understand that minifying the merged JS files makes this idea
untenable, but I think it is still worthwhile to solve the problem for
development mode -- I use merged but unminified concatenated files for
development all the time].

One way to do this would be to have special directives in the merged files
which specify where each original file starts, along with its URL.

For example, each new file merged into the concatenated file could start
with a comment:

/*** Merged from:  http://path/to/originalFile.js ***/
...

/*** Merged from:  http://path/to/someOtherFile.js ***/
...

Then when firebug is reporting errors, it could note that this is a merged
file and report the error as coming from the URL of the original file, with
the line number relative to the "Merged from" comment.

Note that I'm not attached to that particular method of signalling where
files begin -- we can probably come up with something better.

I'm happy to write JS to support this, but am not familiar with coding in
Firebug so if someone is willing to help shepherd me in implementing this,
I'm game.

I'm going to stop here and see if there's any reaction to this.  If anyone
is interested in working on this or needs more details, please note in the
bug and I'll write more as necessary.  

Reported by owenoak on 2009-10-24 19:40:19

该提问来源于开源项目:firebug/firebug

  • 写回答

9条回答 默认 最新

  • weixin_39605326 2020-11-30 15:19
    关注
    
    I think this could be added as a Firebug extension.
    
    If you have a Firebug module that listens for onSourceFileCreated(), you can see the
    sourceFile objects. If you create new sourceFile objects breaking up the jsdIScripts
    as appropriate for each source zone, the rest of Firebug should work. The only bug
    might be if another module looks at onSourceFileCreated() first and depend upon the
    first sourceFile. But I guess this is unlikely for now.
    

    Reported by johnjbarton.com on 2009-10-26 03:09:07 - Labels added: Type-Enhancement, extension, debugger, Test-case-needed, 15

    评论

报告相同问题?