Skip to content

Commit

Permalink
Add a FileSystemPathOption::none for cached cell reuse (vercel/turbor…
Browse files Browse the repository at this point in the history
…epo#5717)

### Description

Adds `FileSystemPathOption::none()`, which returns a stably cached cell
to a `None` value.

### Testing Instructions


Closes WEB-1376
  • Loading branch information
jridgewell authored Aug 15, 2023
1 parent 3e1b64d commit efc1cc2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions crates/turbo-tasks-fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,14 @@ impl FileSystemPath {
#[turbo_tasks::value(transparent)]
pub struct FileSystemPathOption(Option<Vc<FileSystemPath>>);

#[turbo_tasks::value_impl]
impl FileSystemPathOption {
#[turbo_tasks::function]
pub fn none() -> Vc<Self> {
Vc::cell(None)
}
}

#[turbo_tasks::value_impl]
impl FileSystemPath {
/// Create a new Vc<FileSystemPath> from a path withing a FileSystem. The
Expand Down Expand Up @@ -1112,7 +1120,7 @@ impl FileSystemPath {
Self::new_normalized(this.fs, path).resolve().await?,
)))
} else {
Ok(Vc::cell(None))
Ok(FileSystemPathOption::none())
}
}

Expand All @@ -1128,7 +1136,7 @@ impl FileSystemPath {
)));
}
}
Ok(Vc::cell(None))
Ok(FileSystemPathOption::none())
}

#[turbo_tasks::function]
Expand Down
2 changes: 1 addition & 1 deletion crates/turbopack-css/src/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl CssChunk {
while !*path.is_inside(current).await? {
let parent = current.parent().resolve().await?;
if parent == current {
return Ok(Vc::cell(None));
return Ok(FileSystemPathOption::none());
}
current = parent;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/turbopack-ecmascript/src/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl EcmascriptChunk {
while !*path.is_inside_or_equal(current).await? {
let parent = current.parent().resolve().await?;
if parent == current {
return Ok(Vc::cell(None));
return Ok(FileSystemPathOption::none());
}
current = parent;
}
Expand Down

0 comments on commit efc1cc2

Please sign in to comment.