Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: bgw/resolved-code-gen
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -288,27 +288,46 @@ 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,
ty: VisitClientReferenceNodeType,
}

#[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 } => {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
),
Expand All @@ -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,
Expand Down
Loading