Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl<Fs: FileSystem + Send + Sync> ResolverGeneric<Fs> {
ctx.with_fully_specified(self.options.fully_specified);
let cached_path = self.cache.value(path);
let cached_path = self.require(&cached_path, specifier, ctx).await?;
let path = self.load_realpath(&cached_path).await?;
let path = self.load_realpath(&cached_path, ctx).await?;

let package_json = cached_path
.find_package_json(&self.cache.fs, &self.options, ctx)
Expand Down Expand Up @@ -681,11 +681,19 @@ impl<Fs: FileSystem + Send + Sync> ResolverGeneric<Fs> {
Ok(None)
}

async fn load_realpath(&self, cached_path: &CachedPath) -> Result<PathBuf, ResolveError> {
async fn load_realpath(
&self,
cached_path: &CachedPath,
ctx: &mut Ctx,
) -> Result<PathBuf, ResolveError> {
if self.options.symlinks {
cached_path
.realpath(&self.cache.fs)
.await
.map(|path| {
ctx.add_file_dependency(&path);
path
})
.map_err(ResolveError::from)
} else {
Ok(cached_path.to_path_buf())
Expand Down
7 changes: 6 additions & 1 deletion src/tests/symlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,16 @@ async fn test() -> io::Result<()> {
.map(|r| r.full_path());
assert_eq!(filename, Ok(root.join("lib/index.js")), "{comment:?}");

let mut ctx = &mut Default::default();
let resolved_path = resolver_without_symlinks
.resolve(&path, request)
.resolve_with_context(&path, request, &mut ctx)
.await
.map(|r| r.full_path());
assert_eq!(resolved_path, Ok(path.join(request)));
assert!(
ctx.file_dependencies.contains(&resolved_path.unwrap()),
"file dependencies should contain resolved path {comment:?}"
);
}

Ok(())
Expand Down