This changes sourcemap parsing so that source names are not automatically prefixed with the sourceRoot field. The problem with doing that is that reading and then immediately writing a sourcemap would result in the source names changing.
Instead, SourceMap now maintains a copy of the vector of source names with the sourceRoot prefix prepended. Obviously this copy needs to be kept in sync with the original source names whenever a source name or the sourceRoot changes.
Note that this PR changes the behavior of SourceMapBuilder somewhat. Now, there is no difference between parsing a sourcemap like
let mut builder = SourceMapBuilder::new(None);
builder.set_source_root(Some("root"));
builder.add_source("foo.js");
builder.add_source("bar.js");
builder.into_sourcemap();
Before, the parsed version would've contained the sources "root/foo.js" and "root/bar.js", while the constructed version would've had "foo.js" and "bar.js"
This changes sourcemap parsing so that source names are not automatically prefixed with the
sourceRoot
field. The problem with doing that is that reading and then immediately writing a sourcemap would result in the source names changing.Instead,
SourceMap
now maintains a copy of the vector of source names with thesourceRoot
prefix prepended. Obviously this copy needs to be kept in sync with the original source names whenever a source name or thesourceRoot
changes.Note that this PR changes the behavior of
SourceMapBuilder
somewhat. Now, there is no difference between parsing a sourcemap likeand constructing it with a builder:
Before, the parsed version would've contained the sources
"root/foo.js"
and"root/bar.js"
, while the constructed version would've had"foo.js"
and"bar.js"