Closed blickly closed 4 years ago
Trying to reboot the discussion on this.
Chris.Lesz@2013-07-27T16:42:27.000Z It would be nice if closure-compiler was actuall recognizing /usr/bin/cpp output
# linenumber "file-name"
That would help looking for correct file in case of error/warning reporting when the file is actually generated from a preprocessor.
I realize that «# anything» is actually a syntax error in ECMA Scripts but it would be ok to recognize a valid pattern, like: ///#line 103 "script.src.js" or even /* @line 103 {script.src.js} / to keep the comment convention consistent.
Chris.Lesz@2013-07-27T16:48:48.000Z Sorry, I don't know how to change Type-Defect into Type-Enhancement
johnlenz@google.com@2013-07-27T18:27:58.000Z I think LINE, etc would be OK.
I don't really care what the compiler supports, as long as we have a way to specify the current linenumber and file. It makes locating the source for warnings/errors infinitely easier (if the input has been preprocessed/concatenated). I'm willing to do the work, as long as we agree on the syntax we support.
Do the "input source maps" not work for your use case? That is the tool agnostic way to get things mapped back to the original source location.
The input source maps depend on the compiler knowing which line they are compiling from which file (the compiler is actually writing the input source map file). However, the problem here is that the compiler actually does not know which file it is compiling and what the correct linenumber is, due to preprocessing of the source files outside the compiler.
I.e. example, I have three source files: a.js b.h c.h
In a.js the content is: var a;
var d;
var e;
In b.h the content is: var b;
In c.h the content is: var c;
Before compiling them, I combine all three files using the following command: cpp a.js >a.JS which creates a.JS Then I invoke: google-closure-compiler a.JS
What I'm trying to achieve is the following:
The compiler does write a source map, but that isn't what I was talking about. You can provide source maps with the inputs. There are a couple of ways of doing this but the easiest way is to include the source map within the source you are providing the JS compiler by using the a data URL in the sourceMapUrl annotation. The associated sources can also be data url encoded so the entire thing is self contained (if you like). For example, we do this with our TypeScript tooling, see https://github.com/angular/tsickle and with J2CL (https://github.com/google/j2cl) to map back to the original source files.
I didn't know the compiler can accept source maps for input. Hopefully that then also works for commandline reporting of errors and warnings by the compiler. But, yes, that looks like a solution, thanks.
Please reopen if that doesn't work for you.
This issue was imported from Closure Compiler's previous home at http://closure-compiler.googlecode.com
The original discussion is archived at: http://blickly.github.io/closure-compiler-issues/#1052