Unverified Commit 1df81bce authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

refactor(turbopack/next-core): Use ResolvedVc in VisitClientReferenceNodeState (#74710)

parent 0098b4f8
......@@ -95,7 +95,7 @@ impl Default for ClientReferenceGraphResult {
}
}
#[turbo_tasks::value(shared, local)]
#[turbo_tasks::value(shared)]
pub struct VisitedClientReferenceGraphNodes(HashSet<VisitClientReferenceNode>);
#[turbo_tasks::value_impl]
......@@ -169,11 +169,11 @@ pub async fn client_reference_graph(
.await?
{
VisitClientReferenceNodeState::InServerComponent {
server_component: *server_component,
server_component,
}
} else {
VisitClientReferenceNodeState::Entry {
entry_path: module.ident().path().resolve().await?,
entry_path: module.ident().path().to_resolved().await?,
}
},
ty: VisitClientReferenceNodeType::Internal(
......@@ -244,7 +244,7 @@ pub struct ServerEntries {
#[turbo_tasks::function]
pub async fn find_server_entries(entry: ResolvedVc<Box<dyn Module>>) -> Result<Vc<ServerEntries>> {
let entry_path = entry.ident().path().resolve().await?;
let entry_path = entry.ident().path().to_resolved().await?;
let graph = AdjacencyMap::new()
.skip_duplicates()
.visit(
......@@ -288,7 +288,16 @@ struct VisitClientReference {
}
#[derive(
Clone, Eq, PartialEq, Hash, Serialize, Deserialize, Debug, ValueDebugFormat, TraceRawVcs,
Clone,
Eq,
PartialEq,
Hash,
Serialize,
Deserialize,
Debug,
ValueDebugFormat,
TraceRawVcs,
NonLocalValue,
)]
struct VisitClientReferenceNode {
state: VisitClientReferenceNodeState,
......@@ -296,19 +305,29 @@ struct VisitClientReferenceNode {
}
#[derive(
Clone, Copy, Eq, PartialEq, Hash, Serialize, Deserialize, Debug, ValueDebugFormat, TraceRawVcs,
Clone,
Copy,
Eq,
PartialEq,
Hash,
Serialize,
Deserialize,
Debug,
ValueDebugFormat,
TraceRawVcs,
NonLocalValue,
)]
enum VisitClientReferenceNodeState {
Entry {
entry_path: Vc<FileSystemPath>,
entry_path: ResolvedVc<FileSystemPath>,
},
InServerComponent {
server_component: Vc<NextServerComponentModule>,
server_component: ResolvedVc<NextServerComponentModule>,
},
InServerUtil,
}
impl VisitClientReferenceNodeState {
fn server_component(&self) -> Option<Vc<NextServerComponentModule>> {
fn server_component(&self) -> Option<ResolvedVc<NextServerComponentModule>> {
match self {
VisitClientReferenceNodeState::Entry { .. } => None,
VisitClientReferenceNodeState::InServerComponent { server_component } => {
......@@ -389,12 +408,7 @@ impl Visit<VisitClientReferenceNode> for VisitClientReference {
state: node.state,
ty: VisitClientReferenceNodeType::ClientReference(
ClientReference {
server_component: match node.state.server_component() {
Some(server_component) => {
Some(server_component.to_resolved().await?)
}
None => None,
},
server_component: node.state.server_component(),
ty: ClientReferenceType::EcmascriptClientReference {
parent_module,
module: client_reference_module,
......@@ -412,12 +426,7 @@ impl Visit<VisitClientReferenceNode> for VisitClientReference {
state: node.state,
ty: VisitClientReferenceNodeType::ClientReference(
ClientReference {
server_component: match node.state.server_component() {
Some(server_component) => {
Some(server_component.to_resolved().await?)
}
None => None,
},
server_component: node.state.server_component(),
ty: ClientReferenceType::CssClientReference(
css_client_reference_asset,
),
......@@ -432,7 +441,7 @@ impl Visit<VisitClientReferenceNode> for VisitClientReference {
{
return Ok(VisitClientReferenceNode {
state: VisitClientReferenceNodeState::InServerComponent {
server_component: *server_component_asset,
server_component: server_component_asset,
},
ty: VisitClientReferenceNodeType::ServerComponentEntry(
server_component_asset,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment