Unverified Commit 69c2d0c4 authored by lichu acuña's avatar lichu acuña Committed by GitHub

Fix next server component modules in graph traversal (#69157)

Next entry modules with the "client modules" or "client modules ssr" modifiers were not being reached by graph traversal. Now they are.
parent af6ff371
...@@ -18,12 +18,12 @@ use crate::{ ...@@ -18,12 +18,12 @@ use crate::{
}; };
#[turbo_tasks::function] #[turbo_tasks::function]
fn client_modules_modifier() -> Vc<RcStr> { pub fn client_modules_modifier() -> Vc<RcStr> {
Vc::cell("client modules".into()) Vc::cell("client modules".into())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn client_modules_ssr_modifier() -> Vc<RcStr> { pub fn client_modules_ssr_modifier() -> Vc<RcStr> {
Vc::cell("client modules ssr".into()) Vc::cell("client modules ssr".into())
} }
......
...@@ -6,7 +6,7 @@ use turbopack_core::{ ...@@ -6,7 +6,7 @@ use turbopack_core::{
asset::{Asset, AssetContent}, asset::{Asset, AssetContent},
chunk::{ChunkItem, ChunkItemExt, ChunkType, ChunkableModule, ChunkingContext}, chunk::{ChunkItem, ChunkItemExt, ChunkType, ChunkableModule, ChunkingContext},
ident::AssetIdent, ident::AssetIdent,
module::Module, module::{Module, Modules},
reference::ModuleReferences, reference::ModuleReferences,
}; };
use turbopack_ecmascript::{ use turbopack_ecmascript::{
...@@ -14,11 +14,14 @@ use turbopack_ecmascript::{ ...@@ -14,11 +14,14 @@ use turbopack_ecmascript::{
EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkPlaceable, EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkPlaceable,
EcmascriptChunkType, EcmascriptExports, EcmascriptChunkType, EcmascriptExports,
}, },
references::esm::EsmExports, references::{esm::EsmExports, external_module::IncludeIdentModule},
utils::StringifyJs, utils::StringifyJs,
}; };
use super::server_component_reference::NextServerComponentModuleReference; use super::server_component_reference::NextServerComponentModuleReference;
use crate::next_app::app_client_references_chunks::{
client_modules_modifier, client_modules_ssr_modifier,
};
#[turbo_tasks::function] #[turbo_tasks::function]
fn modifier() -> Vc<RcStr> { fn modifier() -> Vc<RcStr> {
...@@ -57,6 +60,18 @@ impl Module for NextServerComponentModule { ...@@ -57,6 +60,18 @@ impl Module for NextServerComponentModule {
Vc::upcast(self.module), Vc::upcast(self.module),
))]) ))])
} }
#[turbo_tasks::function]
fn additional_layers_modules(self: Vc<Self>) -> Vc<Modules> {
let base_ident = self.ident();
let ssr_entry_module = Vc::upcast(IncludeIdentModule::new(
base_ident.with_modifier(client_modules_ssr_modifier()),
));
let client_entry_module = Vc::upcast(IncludeIdentModule::new(
base_ident.with_modifier(client_modules_modifier()),
));
Vc::cell(vec![ssr_entry_module, client_entry_module])
}
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
......
...@@ -244,3 +244,34 @@ impl EcmascriptChunkItem for CachedExternalModuleChunkItem { ...@@ -244,3 +244,34 @@ impl EcmascriptChunkItem for CachedExternalModuleChunkItem {
)) ))
} }
} }
/// A module that only has an ident and no content. This is used
/// to include a module's ident in the module graph before the module
/// itself is resolved, as is the case with NextServerComponentModule's
/// "client modules" and "client modules ssr".
#[turbo_tasks::value]
pub struct IncludeIdentModule {
ident: Vc<AssetIdent>,
}
#[turbo_tasks::value_impl]
impl IncludeIdentModule {
#[turbo_tasks::function]
pub fn new(ident: Vc<AssetIdent>) -> Vc<Self> {
Self { ident }.cell()
}
}
impl Asset for IncludeIdentModule {
fn content(self: Vc<Self>) -> Vc<AssetContent> {
todo!("IncludeIdentModule doesn't implement content()")
}
}
#[turbo_tasks::value_impl]
impl Module for IncludeIdentModule {
#[turbo_tasks::function]
fn ident(&self) -> Vc<AssetIdent> {
self.ident
}
}
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