fix(node): better detection for when to surface node resolution errors (#24653)

This commit is contained in:
David Sherret 2024-07-23 20:22:24 -04:00 committed by GitHub
parent 445e05a39d
commit 52ababc4bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 678 additions and 519 deletions

View file

@ -446,15 +446,14 @@ impl<TGraphContainer: ModuleGraphContainer>
specifier: &str,
referrer: &ModuleSpecifier,
) -> Result<ModuleSpecifier, AnyError> {
if let Some(result) = self.shared.node_resolver.resolve_if_in_npm_package(
specifier,
referrer,
NodeResolutionMode::Execution,
) {
return match result? {
Some(res) => Ok(res.into_url()),
None => Err(generic_error("not found")),
};
if self.shared.node_resolver.in_npm_package(referrer) {
return Ok(
self
.shared
.node_resolver
.resolve(specifier, referrer, NodeResolutionMode::Execution)?
.into_url(),
);
}
let graph = self.graph_container.graph();