Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use swc instead of source-map-mappings for source maps #4348

Closed
bartlomieju opened this issue Mar 13, 2020 · 3 comments · Fixed by #4368
Closed

Use swc instead of source-map-mappings for source maps #4348

bartlomieju opened this issue Mar 13, 2020 · 3 comments · Fixed by #4368

Comments

@bartlomieju
Copy link
Member

Yet another place where we want to use swc is source maps. swc has SourceMap struct, that might be used for that purpose.

Currently source maps are generated by TS compiler and source-map-mappings crate is used to perform the lookup.

To boil down: wanted ability to parse tsc generated source map file in swc and provide high level interface to lookups using interface shown below:

pub trait SourceMapGetter {
  fn get_source_line(
    &self,
    script_name: &str,
    line_number: usize,
  ) -> Option<String>;
  fn get_original_position(
    &self,
    script_name: String,
    line_number: i64,
    column: i64,
  ) -> (String, i64, i64);
}

Ref #3983 #4323 #4140

CC @ry @kdy1

@kdy1
Copy link

kdy1 commented Mar 14, 2020

I think sec_common need some revamp bedore this.
I copied it from rustc source code, and as cargo works by creating multiple process, rustc just leaks sourcemap.

I'm consideriing api like SourceMap.remove or storing Weak instead of Arc, but I'm not sure about it at now.

Also, swc does not do remapping at the moment.

@kitsonk
Copy link
Contributor

kitsonk commented Mar 14, 2020

What is insufficient with the Rust crate we already use for source map remapping, it is the one from the team that created source maps to begin with. Why move it to swc????

@bartlomieju
Copy link
Member Author

bartlomieju commented Mar 14, 2020

@kitsonk source-map-mappings crate is sufficient, but it is very outdated causing our binary to have multiple versions of same crates.

@kdy1 I read through Cargo.toml in swc repo and it seems you're using get-sentry/rust-sourcemap crate. It's API is very similar to source-map-mappings so I'll try to switch the crates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants