Struct deskulpt::bundler::common::PathResolver
source · struct PathResolver(PathBuf);
Expand description
The Deskulpt-customized path resolver for SWC bundler.
It is in charge of resolving the module specifiers in the import statements. Note that module specifiers that are ignored in the first place will not go through this resolver at all.
This path resolver intends to resolve the following types of imports:
- Extension-less relative paths, e.g.,
import foo from "./foo"
- Relative paths, e.g.,
import foo from "./foo.js"
It is not designed to resolve the following types of imports:
- Absolute path imports, e.g.,
import foo from "/foo"
- URL imports, e.g.,
import foo from "https://example.com/foo"
- Node resolution imports, e.g.,
import globals from "globals"
- Relative imports that go beyond the root
Tuple Fields§
§0: PathBuf
Implementations§
source§impl PathResolver
impl PathResolver
sourcefn resolve_as_file(&self, path: &Path) -> Result<PathBuf, Error>
fn resolve_as_file(&self, path: &Path) -> Result<PathBuf, Error>
Helper function for resolving a path by treating it as a file.
If path
refers to a file then it is directly returned. Otherwise, path
with
each extension in EXTENSIONS
is tried in order.
sourcefn resolve_filename(
&self,
base: &FileName,
module_specifier: &str,
) -> Result<FileName, Error>
fn resolve_filename( &self, base: &FileName, module_specifier: &str, ) -> Result<FileName, Error>
Helper function for the [Resolve
] trait.
Note that errors emitted here do not need to provide information about base
and module_specifier
because the call to this function should have already
been wrapped in an SWC context that provides this information.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PathResolver
impl RefUnwindSafe for PathResolver
impl Send for PathResolver
impl Sync for PathResolver
impl Unpin for PathResolver
impl UnwindSafe for PathResolver
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more