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

fix(lsp): improved npm specifier to import map entry mapping #22016

Merged

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Jan 21, 2024

Extracted out from #22004

Upgrades to the latest deno_semver

matches
.push(format!("{}{}", entry.raw_key, key_sub_path));
}
}
}
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code now goes from import map entry to npm package req and from that figures out a match instead of going from pkg req -> specifier, then calling import_map.lookup on the possible specifiers. We can no longer rely on a mapping from PkgReq -> specifier because we normalize and eliminate duplicate PackageReqs based on their RangeSetAndTag since denoland/deno_semver@98f9174

} else if let Some(file_stem) = file_name.strip_suffix(".d.mts") {
search_paths
.push(specifier_path.with_file_name(format!("{}.mjs", file_stem)));
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found this situation while writing the test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that's a tricky one

@@ -1342,7 +1342,7 @@ dependencies = [
"import_map",
"indexmap",
"log",
"monch",
"monch 0.4.3",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This duplicate monch dep will be fixed in denoland/deno_graph#361

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dsherret dsherret merged commit fbfeedb into denoland:main Jan 21, 2024
14 checks passed
@dsherret dsherret deleted the fix_improved_npm_import_map_support branch January 21, 2024 22:19
bartlomieju pushed a commit to bartlomieju/deno that referenced this pull request Jan 22, 2024
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 this pull request may close these issues.

2 participants