refactor: make ParsedModule implement Sync (#11581)

This commit is contained in:
David Sherret 2021-08-06 10:36:16 -04:00 committed by GitHub
parent e9ddc7a41a
commit 466d3df9d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 436 additions and 230 deletions

View file

@ -349,7 +349,7 @@ impl Module {
// parse out any triple slash references
for comment in parsed_module.get_leading_comments().iter() {
if let Some((ts_reference, _)) = parse_ts_reference(comment) {
let location = parsed_module.get_location(&comment.span);
let location = parsed_module.get_location(comment.span.lo);
match ts_reference {
TypeScriptReference::Path(import) => {
let specifier =
@ -386,12 +386,7 @@ impl Module {
for desc in dependencies.iter().filter(|desc| {
desc.kind != swc_ecmascript::dep_graph::DependencyKind::Require
}) {
let loc = parsed_module.source_map.lookup_char_pos(desc.span.lo);
let location = Location {
filename: self.specifier.to_string(),
col: loc.col_display,
line: loc.line,
};
let location = parsed_module.get_location(desc.span.lo);
// In situations where there is a potential issue with resolving the
// import specifier, that ends up being a module resolution error for a
@ -468,7 +463,7 @@ impl Module {
let referrer_scheme = self.specifier.scheme();
let specifier_scheme = specifier.scheme();
let location = maybe_location.unwrap_or(Location {
filename: self.specifier.to_string(),
specifier: self.specifier.to_string(),
line: 0,
col: 0,
});