Closed ova2 closed 9 years ago
Why didn't setSourceMapLocationMappings work for you?
I don't know why. It only appends prefix. Right? I tried options.setSourceMapLocationMappings(
", ""),
options.setSourceMapLocationMappings(".", "")
, options.setSourceMapLocationMappings(
"", ".")`, etc. Nothing works. The patch in "sources" is absolute.
It should be a prefix something like
options.setSourceMapLocationMappings(ImmutableList.of(new LocationMapping("C:/Projects/primefaces-extensions/core/target/classes/META-INF/resources/primefaces-extensions/","")))
Perhaps with the slashes the other way.
I tried your suggestion. It doesn't work. I assume it is the same bug as here https://github.com/google/closure-compiler/issues/588
Huh, I could fix this problem. The SourceMap.java has
// Replace backslashes (the file separator used on Windows systems).
if (File.separatorChar == '\\') {
sourceFile = sourceFile.replace('\\', '/');
}
And this was the problem. I didn't know why you do this guys. I fixed the problem by doing the same:
File sourceMapFile = new File(outputFilePath + ".map");
options.setSourceMapOutputPath(sourceMapFile.getCanonicalPath());
String prefix = outputFilePath.substring(0, outputFilePath.lastIndexOf(File.separator) + 1);
// Replace backslashes (the file separator used on Windows systems).
// This is needed due to the same code in SourceMap.java
if (File.separatorChar == '\\') {
prefix = prefix.replace('\\', '/');
}
List<SourceMap.LocationMapping> sourceMapLocationMappings =
ImmutableList.of(new SourceMap.LocationMapping(prefix, ""));
options.setSourceMapLocationMappings(sourceMapLocationMappings);
You fixed the issue for ANT task https://github.com/google/closure-compiler/issues/588 But if you use Maven, the issue with absolute path in "sources" is still here. I use
CompilerOptions
andcom.google.javascript.jscomp.Compiler
I get something like in the source map
but it should be
because the source map and the source JS file are located in the same folder.
How to fix this issue? Setting
options.setSourceMapLocationMappings(...)
didn't help as well.