Unverified Commit c2d28fa7 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: remove unused IncludeModulesModule (#76868)

Using this would break the module graph and chunking now anyway .
parent ec2ca8b6
...@@ -906,25 +906,12 @@ impl PageEndpoint { ...@@ -906,25 +906,12 @@ impl PageEndpoint {
} = *self.internal_ssr_chunk_module().await?; } = *self.internal_ssr_chunk_module().await?;
let project = this.pages_project.project(); let project = this.pages_project.project();
// The SSR and Client Graphs are not connected in Pages Router.
// We are only interested in get_next_dynamic_imports_for_endpoint at the
// moment, which only needs the client graph anyway.
let module_graph = project.module_graph(*ssr_module, ChunkGroupType::Entry); let module_graph = project.module_graph(*ssr_module, ChunkGroupType::Entry);
let next_dynamic_imports = if let PageEndpointType::Html = this.ty { let next_dynamic_imports = if let PageEndpointType::Html = this.ty {
// The SSR and Client Graphs are not connected in Pages Router.
// We are only interested in get_next_dynamic_imports_for_endpoint at the
// moment, which only needs the client graph anyway.
//
// If we do want to change this to have both included. We'd need to create a
// `IncludeModulesModule` that includes both SSR and Client (and use that both
// there and in Project::get_all_entries):
// let client_module = self.client_module().to_resolved().await?;
// let ssr_module = self.internal_ssr_chunk_module().await?.ssr_module;
// Ok(Vc::upcast(IncludeModulesModule::new(
// self.source()
// .ident()
// .with_modifier(Vc::cell("unified entrypoint".into())),
// vec![*client_module, *ssr_module],
// )))
let client_availability_info = self.client_chunks().await?.availability_info; let client_availability_info = self.client_chunks().await?.availability_info;
let client_module_graph = self.client_module_graph(); let client_module_graph = self.client_module_graph();
......
use anyhow::Result;
use turbo_rcstr::RcStr;
use turbo_tasks::{ResolvedVc, TryJoinIterExt, ValueToString, Vc};
use turbo_tasks_fs::glob::Glob;
use turbopack_core::{
asset::{Asset, AssetContent},
chunk::{ChunkItem, ChunkType, ChunkableModule, ChunkableModuleReference, ChunkingContext},
ident::AssetIdent,
module::Module,
module_graph::ModuleGraph,
reference::{ModuleReference, ModuleReferences},
resolve::ModuleResolveResult,
};
use turbopack_ecmascript::chunk::{
EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkPlaceable, EcmascriptChunkType,
EcmascriptExports,
};
/// A virtual module that references other modules, but doesn't do anything at
/// runtime. It can be used to include modules into a chunk.
#[turbo_tasks::value]
pub struct IncludeModulesModule {
ident: ResolvedVc<AssetIdent>,
modules: Vec<ResolvedVc<Box<dyn Module>>>,
}
#[turbo_tasks::value_impl]
impl IncludeModulesModule {
#[turbo_tasks::function]
pub fn new(
ident: ResolvedVc<AssetIdent>,
modules: Vec<ResolvedVc<Box<dyn Module>>>,
) -> Vc<Self> {
Self { ident, modules }.cell()
}
}
impl Asset for IncludeModulesModule {
fn content(self: Vc<Self>) -> Vc<AssetContent> {
todo!("IncludeModulesModule doesn't implement content()")
}
}
#[turbo_tasks::value_impl]
impl Module for IncludeModulesModule {
#[turbo_tasks::function]
fn ident(&self) -> Vc<AssetIdent> {
*self.ident
}
#[turbo_tasks::function]
async fn references(&self) -> Result<Vc<ModuleReferences>> {
Ok(Vc::cell(
self.modules
.iter()
.map(|&module| async move {
Ok(ResolvedVc::upcast(
IncludedModuleReference::new(*module).to_resolved().await?,
))
})
.try_join()
.await?,
))
}
}
#[turbo_tasks::value_impl]
impl EcmascriptChunkPlaceable for IncludeModulesModule {
#[turbo_tasks::function]
fn get_exports(self: Vc<Self>) -> Vc<EcmascriptExports> {
EcmascriptExports::None.cell()
}
#[turbo_tasks::function]
fn is_marked_as_side_effect_free(self: Vc<Self>, _: Vc<Glob>) -> Vc<bool> {
Vc::cell(true)
}
}
#[turbo_tasks::value_impl]
impl ChunkableModule for IncludeModulesModule {
#[turbo_tasks::function]
fn as_chunk_item(
self: ResolvedVc<Self>,
_module_graph: Vc<ModuleGraph>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Vc<Box<dyn ChunkItem>> {
Vc::upcast(
IncludeModulesChunkItem {
module: self,
chunking_context,
}
.cell(),
)
}
}
/// The chunk item for [`IncludeModulesModule`].
#[turbo_tasks::value]
struct IncludeModulesChunkItem {
module: ResolvedVc<IncludeModulesModule>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
}
#[turbo_tasks::value_impl]
impl ChunkItem for IncludeModulesChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(*self.chunking_context)
}
#[turbo_tasks::function]
fn asset_ident(&self) -> Vc<AssetIdent> {
self.module.ident()
}
#[turbo_tasks::function]
fn ty(&self) -> Vc<Box<dyn ChunkType>> {
Vc::upcast(Vc::<EcmascriptChunkType>::default())
}
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(*self.module)
}
}
#[turbo_tasks::value_impl]
impl EcmascriptChunkItem for IncludeModulesChunkItem {
#[turbo_tasks::function]
fn content(&self) -> Vc<EcmascriptChunkItemContent> {
EcmascriptChunkItemContent {
..Default::default()
}
.cell()
}
}
/// A module reference that references a module that is references from the
/// [`IncludeModulesModule`].
#[turbo_tasks::value]
pub struct IncludedModuleReference {
pub module: ResolvedVc<Box<dyn Module>>,
}
#[turbo_tasks::value_impl]
impl IncludedModuleReference {
#[turbo_tasks::function]
pub fn new(module: ResolvedVc<Box<dyn Module>>) -> Vc<Self> {
IncludedModuleReference { module }.cell()
}
}
#[turbo_tasks::value_impl]
impl ValueToString for IncludedModuleReference {
#[turbo_tasks::function]
fn to_string(&self) -> Vc<RcStr> {
Vc::cell("module".into())
}
}
#[turbo_tasks::value_impl]
impl ModuleReference for IncludedModuleReference {
#[turbo_tasks::function]
fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
*ModuleResolveResult::module(self.module)
}
}
#[turbo_tasks::value_impl]
impl ChunkableModuleReference for IncludedModuleReference {}
...@@ -3,7 +3,6 @@ pub mod app_client_shared_chunks; ...@@ -3,7 +3,6 @@ pub mod app_client_shared_chunks;
pub mod app_entry; pub mod app_entry;
pub mod app_page_entry; pub mod app_page_entry;
pub mod app_route_entry; pub mod app_route_entry;
pub mod include_modules_module;
pub mod metadata; pub mod metadata;
use std::{ use std::{
......
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