Closed kdy1 closed 2 years ago
Processed SourceMap
struct, has sourceRoot
already resolved, and all sources
are correctly mapped to appropriate paths.
We could potentially add the extract_source_root
option to RewriteOptions
, which could then be used like so:
let sm = SourceMap::from_reader(input)?;
let processed_sm = sm.rewrite(&RewriteOptions {
extract_source_root: true,
..Default::default()
})?;
processed_sm.to_writer(output)?;
extract_source_root
would use a simple find common path algorithm for that.
wdyt @Swatinem @loewenheim?
The raw sourcemaps should have support for parsing/serializing from raw json, and also read/write when constructing with minimal validation.
While resolving sourceRoot
at parse time might be the right choice for sentry, I think the swc
usecase would rather have the raw values.
Using a default "find common path prefix" sounds interesting, but I think having a more explicit option is the better idea.
Thank you!
Published in 6.2.0
.
Related: https://github.com/swc-project/swc/issues/2362
I want to generate sourcemap like
but I found that
SourceMapBuilder
does not provide a way to generate a sourcemap withsourceRoot