Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 4 additions & 8 deletions crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -930,9 +930,7 @@ impl AppProject {
.take(server_component_entries.len().saturating_sub(1))
{
let graph = SingleModuleGraph::new_with_entries_visited_intern(
// This should really be ChunkGroupEntry::Shared(module.await?.module),
// but that breaks everything for some reason.
vec![ChunkGroupEntry::Entry(vec![ResolvedVc::upcast(*module)])],
vec![ChunkGroupEntry::Shared(ResolvedVc::upcast(*module))],
visited_modules,
should_trace,
should_read_binding_usage,
Expand Down Expand Up @@ -1895,9 +1893,7 @@ impl AppEndpoint {
async {
let chunk_group = chunking_context.chunk_group(
server_component.ident(),
ChunkGroup::Shared(ResolvedVc::upcast(
server_component.await?.module,
)),
ChunkGroup::Shared(ResolvedVc::upcast(server_component)),
module_graph,
current_chunk_group.await?.availability_info,
);
Expand Down Expand Up @@ -2157,9 +2153,9 @@ impl Endpoint for AppEndpoint {
.await?,
);

Ok(Vc::cell(vec![ChunkGroupEntry::Entry(vec![
Ok(Vc::cell(vec![ChunkGroupEntry::Shared(
server_actions_loader,
])]))
)]))
}

#[turbo_tasks::function]
Expand Down
3 changes: 1 addition & 2 deletions crates/next-api/src/server_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ async fn build_manifest(
}

// Now create the manifest entries
for (hash_id, (layer, name, filename)) in &action_metadata {
for (hash_id, (_layer, name, filename)) in &action_metadata {
let entry = mapping.entry(hash_id.as_str()).or_default();
entry.workers.insert(
&key,
Expand All @@ -211,7 +211,6 @@ async fn build_manifest(
filename: filename.as_str(),
},
);
entry.layer.insert(&key, *layer);

// Hoist the filename and exported_name to the entry level
entry.exported_name = name.as_str();
Expand Down
30 changes: 21 additions & 9 deletions crates/next-core/src/app_page_loader_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,13 @@ impl AppPageLoaderTreeBuilder {
// This should use the same importing mechanism as create_module_tuple_code, so that
// the relative order of items is retained (which isn't the case
// when mixing ESM imports and requires).
self.base
.imports
.push(format!("const {identifier} = require(\"{inner_module_id}\");").into());
self.base.imports.push(
format!(
"const {identifier} = require(/*turbopackChunkingType: \
shared*/\"{inner_module_id}\");"
)
.into(),
);

let source = dynamic_image_metadata_source(
*ResolvedVc::upcast(self.base.module_asset_context),
Expand Down Expand Up @@ -234,9 +238,13 @@ impl AppPageLoaderTreeBuilder {
// This should use the same importing mechanism as create_module_tuple_code, so that the
// relative order of items is retained (which isn't the case when mixing ESM imports and
// requires).
self.base
.imports
.push(format!("const {identifier} = require(\"{inner_module_id}\");").into());
self.base.imports.push(
format!(
"const {identifier} = require(/*turbopackChunkingType: \
shared*/\"{inner_module_id}\");"
)
.into(),
);
let module = StructuredImageModuleType::create_module(
Vc::upcast(FileSource::new(path.clone())),
BlurPlaceholderMode::None,
Expand Down Expand Up @@ -295,9 +303,13 @@ impl AppPageLoaderTreeBuilder {
// This should use the same importing mechanism as create_module_tuple_code, so that the
// relative order of items is retained (which isn't the case when mixing ESM imports and
// requires).
self.base
.imports
.push(format!("const {identifier} = require(\"{inner_module_id}\");").into());
self.base.imports.push(
format!(
"const {identifier} = require(/*turbopackChunkingType: \
shared*/\"{inner_module_id}\");"
)
.into(),
);

let module = self
.base
Expand Down
2 changes: 1 addition & 1 deletion crates/next-core/src/base_loader_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl BaseLoaderTreeBuilder {
self.imports.push(
formatdoc!(
r#"
const {} = () => require("MODULE_{}");
const {} = () => require(/*turbopackChunkingType: shared*/"MODULE_{}");
"#,
identifier,
i
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ pub async fn get_app_client_references_chunks(
client_references_by_server_component.into_iter()
{
let parent_chunk_group = *chunk_group_info
.get_index_of(ChunkGroup::Shared(ResolvedVc::upcast(
server_component.await?.module,
)))
.get_index_of(ChunkGroup::Shared(ResolvedVc::upcast(server_component)))
.await?;

let base_ident = server_component.ident();
Expand Down
30 changes: 9 additions & 21 deletions crates/next-core/src/next_dynamic/dynamic_module.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;
use indoc::formatdoc;
use turbo_rcstr::{RcStr, rcstr};
use turbo_rcstr::rcstr;
use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::{
chunk::{AsyncModuleInfo, ChunkableModule, ChunkingContext, ModuleChunkItemIdExt},
Expand Down Expand Up @@ -36,20 +36,12 @@ impl NextDynamicEntryModule {
}
}

fn dynamic_ref_description() -> RcStr {
rcstr!("next/dynamic reference")
}

impl NextDynamicEntryModule {
async fn module_reference(&self) -> Result<ResolvedVc<Box<dyn ModuleReference>>> {
Ok(ResolvedVc::upcast(
SingleChunkableModuleReference::new(
Vc::upcast(*self.module),
dynamic_ref_description(),
ExportUsage::all(),
)
.to_resolved()
.await?,
fn module_reference(&self) -> Vc<Box<dyn ModuleReference>> {
Vc::upcast(SingleChunkableModuleReference::new(
Vc::upcast(*self.module),
rcstr!("next/dynamic reference"),
ExportUsage::all(),
))
}
}
Expand All @@ -70,8 +62,9 @@ impl Module for NextDynamicEntryModule {

#[turbo_tasks::function]
async fn references(&self) -> Result<Vc<ModuleReferences>> {
Ok(Vc::cell(vec![self.module_reference().await?]))
Ok(Vc::cell(vec![self.module_reference().to_resolved().await?]))
}

#[turbo_tasks::function]
fn side_effects(self: Vc<Self>) -> Vc<ModuleSideEffects> {
// This just exports another import
Expand All @@ -95,12 +88,7 @@ impl ChunkableModule for NextDynamicEntryModule {
impl EcmascriptChunkPlaceable for NextDynamicEntryModule {
#[turbo_tasks::function]
fn get_exports(&self) -> Vc<EcmascriptExports> {
let module_reference: Vc<Box<dyn ModuleReference>> =
Vc::upcast(SingleChunkableModuleReference::new(
Vc::upcast(*self.module),
dynamic_ref_description(),
ExportUsage::all(),
));
let module_reference = self.module_reference();
EsmExports::reexport_including_default(module_reference)
}

Expand Down
10 changes: 8 additions & 2 deletions crates/next-core/src/next_image/source_asset.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::io::Write;

use anyhow::{Result, bail};
use turbo_rcstr::rcstr;
use turbo_tasks::{ResolvedVc, Vc};
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, ValueToString, Vc};
use turbo_tasks_fs::{FileContent, rope::RopeBuilder};
use turbopack_core::{
asset::{Asset, AssetContent},
Expand Down Expand Up @@ -47,6 +47,12 @@ impl Source for StructuredImageFileSource {
.with_modifier(modifier)
.rename_as(rcstr!("*.mjs"))
}

#[turbo_tasks::function]
async fn description(&self) -> Result<Vc<RcStr>> {
let ident = self.image.ident().to_string().await?;
Ok(Vc::cell(format!("structured image of {}", ident).into()))
}
}

#[turbo_tasks::value_impl]
Expand Down
2 changes: 0 additions & 2 deletions crates/next-core/src/next_manifests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,6 @@ pub struct ActionManifestEntry<'a> {
/// module that exports it.
pub workers: FxIndexMap<&'a str, ActionManifestWorkerEntry<'a>>,

pub layer: FxIndexMap<&'a str, ActionLayer>,

#[serde(rename = "exportedName")]
pub exported_name: &'a str,

Expand Down
1 change: 0 additions & 1 deletion crates/next-core/src/next_server_component/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod server_component_module;
pub(crate) mod server_component_reference;
pub(crate) mod server_component_transition;

pub use server_component_transition::NextServerComponentTransition;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use turbopack_core::{
ident::AssetIdent,
module::{Module, ModuleSideEffects},
module_graph::ModuleGraph,
reference::{ModuleReference, ModuleReferences},
reference::{ModuleReference, ModuleReferences, SingleChunkableModuleReference},
resolve::ExportUsage,
source::OptionSource,
};
use turbopack_ecmascript::{
Expand All @@ -21,8 +22,6 @@ use turbopack_ecmascript::{
utils::StringifyJs,
};

use super::server_component_reference::NextServerComponentModuleReference;

#[turbo_tasks::value(shared)]
pub struct NextServerComponentModule {
pub module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
Expand Down Expand Up @@ -62,11 +61,11 @@ impl NextServerComponentModule {
}

impl NextServerComponentModule {
async fn module_reference(&self) -> Result<ResolvedVc<Box<dyn ModuleReference>>> {
Ok(ResolvedVc::upcast(
NextServerComponentModuleReference::new(Vc::upcast(*self.module))
.to_resolved()
.await?,
fn module_reference(&self) -> Vc<Box<dyn ModuleReference>> {
Vc::upcast(SingleChunkableModuleReference::new(
Vc::upcast(*self.module),
rcstr!("Next.js Server Component"),
ExportUsage::all(),
))
}
}
Expand All @@ -87,8 +86,9 @@ impl Module for NextServerComponentModule {

#[turbo_tasks::function]
async fn references(&self) -> Result<Vc<ModuleReferences>> {
Ok(Vc::cell(vec![self.module_reference().await?]))
Ok(Vc::cell(vec![self.module_reference().to_resolved().await?]))
}

#[turbo_tasks::function]
fn side_effects(self: Vc<Self>) -> Vc<ModuleSideEffects> {
// This just exports another import
Expand All @@ -112,9 +112,7 @@ impl ChunkableModule for NextServerComponentModule {
impl EcmascriptChunkPlaceable for NextServerComponentModule {
#[turbo_tasks::function]
fn get_exports(&self) -> Vc<EcmascriptExports> {
let module_reference: Vc<Box<dyn ModuleReference>> = Vc::upcast(
NextServerComponentModuleReference::new(Vc::upcast(*self.module)),
);
let module_reference = self.module_reference();
EsmExports::reexport_including_default(module_reference)
}

Expand Down

This file was deleted.

Loading
Loading