pub trait ModuleResolver: Send + Sync {
// Required methods
fn workspace_config(&self, root: &Path) -> ResolverConfig;
fn module_of_file(
&self,
root: &Path,
file: &Path,
cfg: &ResolverConfig,
) -> Vec<ModuleId>;
fn resolve(
&self,
from_file: &Path,
spec: &ImportSpec,
cfg: &ResolverConfig,
) -> Resolution;
}Expand description
Per-language module resolver.
Implements the Rust/TS/Python/etc-specific logic for turning an import specifier into a resolved file path.
Required Methods§
Sourcefn workspace_config(&self, root: &Path) -> ResolverConfig
fn workspace_config(&self, root: &Path) -> ResolverConfig
Read workspace config from the given root (e.g. Cargo.toml, tsconfig.json).
Sourcefn module_of_file(
&self,
root: &Path,
file: &Path,
cfg: &ResolverConfig,
) -> Vec<ModuleId>
fn module_of_file( &self, root: &Path, file: &Path, cfg: &ResolverConfig, ) -> Vec<ModuleId>
Return the canonical module identity/ies of a file within the workspace.
Sourcefn resolve(
&self,
from_file: &Path,
spec: &ImportSpec,
cfg: &ResolverConfig,
) -> Resolution
fn resolve( &self, from_file: &Path, spec: &ImportSpec, cfg: &ResolverConfig, ) -> Resolution
Resolve an import specifier from from_file to a target file + name.