diff --git a/crates/node_binding/binding.d.ts b/crates/node_binding/binding.d.ts index a12a53cb965a..f00995443555 100644 --- a/crates/node_binding/binding.d.ts +++ b/crates/node_binding/binding.d.ts @@ -1081,6 +1081,7 @@ export interface JsTap { export interface NodeFsStats { isFile: boolean isDirectory: boolean + isSymlink: boolean atimeMs: number mtimeMs: number ctimeMs: number diff --git a/crates/rspack_fs_node/src/node.rs b/crates/rspack_fs_node/src/node.rs index 2e958df75948..405bbacb37ad 100644 --- a/crates/rspack_fs_node/src/node.rs +++ b/crates/rspack_fs_node/src/node.rs @@ -47,6 +47,7 @@ pub struct ThreadsafeNodeFS { pub struct NodeFsStats { pub is_file: bool, pub is_directory: bool, + pub is_symlink: bool, pub atime_ms: u32, pub mtime_ms: u32, pub ctime_ms: u32, @@ -59,7 +60,7 @@ impl From for FileMetadata { Self { is_file: value.is_file, is_directory: value.is_directory, - is_symlink: false, + is_symlink: value.is_symlink, atime_ms: value.atime_ms as u64, mtime_ms: value.mtime_ms as u64, ctime_ms: value.ctime_ms as u64, diff --git a/crates/rspack_fs_node/src/write.rs b/crates/rspack_fs_node/src/write.rs index a053a0f8ed4c..f9141596a247 100644 --- a/crates/rspack_fs_node/src/write.rs +++ b/crates/rspack_fs_node/src/write.rs @@ -194,7 +194,14 @@ impl ReadableFileSystem for NodeFileSystem { } fn symlink_metadata(&self, path: &Utf8Path) -> Result { - self.metadata(path) + let res = futures::executor::block_on(self.0.lstat.call_with_promise(path.to_string())) + .map_err(map_error_to_fs_error)?; + match res { + Either::A(stats) => Ok(stats.into()), + Either::B(_) => Err(new_fs_error( + "input file system call symlink_metadata failed", + )), + } } fn canonicalize(&self, path: &Utf8Path) -> Result { diff --git a/packages/rspack/src/FileSystem.ts b/packages/rspack/src/FileSystem.ts index f6b7b3aacecf..08b27f8b82d2 100644 --- a/packages/rspack/src/FileSystem.ts +++ b/packages/rspack/src/FileSystem.ts @@ -39,6 +39,7 @@ function __to_binding_stat(stat: IStats): NodeFsStats { return { isFile: stat.isFile(), isDirectory: stat.isDirectory(), + isSymlink: stat.isSymbolicLink(), atimeMs: stat.atimeMs, mtimeMs: stat.atimeMs, ctimeMs: stat.atimeMs,