Unverified Commit 8d5b9374 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: avoid chunk_item_id task and use selective cell access instead (#88411)

### What?

Use selection reads for module id to avoid functions
parent dd39efc7
...@@ -1577,6 +1577,7 @@ impl AppEndpoint { ...@@ -1577,6 +1577,7 @@ impl AppEndpoint {
let loadable_manifest_output = create_react_loadable_manifest( let loadable_manifest_output = create_react_loadable_manifest(
*dynamic_import_entries, *dynamic_import_entries,
*client_chunking_context,
client_relative_path.clone(), client_relative_path.clone(),
node_root.join(&format!( node_root.join(&format!(
"server/app{}/react-loadable-manifest", "server/app{}/react-loadable-manifest",
...@@ -1692,6 +1693,7 @@ impl AppEndpoint { ...@@ -1692,6 +1693,7 @@ impl AppEndpoint {
let loadable_manifest_output = create_react_loadable_manifest( let loadable_manifest_output = create_react_loadable_manifest(
*dynamic_import_entries, *dynamic_import_entries,
*client_chunking_context,
client_relative_path.clone(), client_relative_path.clone(),
node_root.join(&format!( node_root.join(&format!(
"server/app{}/react-loadable-manifest", "server/app{}/react-loadable-manifest",
......
...@@ -30,10 +30,7 @@ use turbo_tasks::{ ...@@ -30,10 +30,7 @@ use turbo_tasks::{
debug::ValueDebugFormat, trace::TraceRawVcs, debug::ValueDebugFormat, trace::TraceRawVcs,
}; };
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{ChunkableModule, ChunkingContext, availability_info::AvailabilityInfo},
ChunkableModule, ChunkingContext, ModuleChunkItemIdExt, ModuleId,
availability_info::AvailabilityInfo,
},
module::Module, module::Module,
module_graph::{ModuleGraph, ModuleGraphLayer}, module_graph::{ModuleGraph, ModuleGraphLayer},
output::{OutputAssetsReference, OutputAssetsWithReferenced}, output::{OutputAssetsReference, OutputAssetsWithReferenced},
...@@ -84,12 +81,7 @@ pub(crate) async fn collect_next_dynamic_chunks( ...@@ -84,12 +81,7 @@ pub(crate) async fn collect_next_dynamic_chunks(
chunking_context.async_loader_chunk_item(*module, module_graph, availability_info); chunking_context.async_loader_chunk_item(*module, module_graph, availability_info);
let async_chunk_group = async_loader.references().to_resolved().await?; let async_chunk_group = async_loader.references().to_resolved().await?;
let module_id = dynamic_entry Ok((*dynamic_entry, (*dynamic_entry, async_chunk_group)))
.chunk_item_id(chunking_context)
.to_resolved()
.await?;
Ok((*dynamic_entry, (module_id, async_chunk_group)))
}) })
.try_join() .try_join()
.await?; .await?;
...@@ -105,7 +97,10 @@ pub struct DynamicImportedChunks( ...@@ -105,7 +97,10 @@ pub struct DynamicImportedChunks(
#[bincode(with = "turbo_bincode::indexmap")] #[bincode(with = "turbo_bincode::indexmap")]
pub FxIndexMap< pub FxIndexMap<
ResolvedVc<NextDynamicEntryModule>, ResolvedVc<NextDynamicEntryModule>,
(ResolvedVc<ModuleId>, ResolvedVc<OutputAssetsWithReferenced>), (
ResolvedVc<NextDynamicEntryModule>,
ResolvedVc<OutputAssetsWithReferenced>,
),
>, >,
); );
......
use anyhow::Result; use anyhow::Result;
use next_core::{next_manifests::LoadableManifest, util::NextRuntime}; use next_core::{next_manifests::LoadableManifest, util::NextRuntime};
use turbo_tasks::{FxIndexMap, ResolvedVc, TryFlatJoinIterExt, Vc}; use turbo_tasks::{FxIndexMap, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc};
use turbo_tasks_fs::{File, FileContent, FileSystemPath}; use turbo_tasks_fs::{File, FileContent, FileSystemPath};
use turbopack_core::{ use turbopack_core::{
asset::AssetContent, asset::AssetContent,
chunk::{ChunkingContext, ModuleChunkItemIdExt},
output::{OutputAsset, OutputAssets}, output::{OutputAsset, OutputAssets},
virtual_output::VirtualOutputAsset, virtual_output::VirtualOutputAsset,
}; };
...@@ -14,6 +15,7 @@ use crate::dynamic_imports::DynamicImportedChunks; ...@@ -14,6 +15,7 @@ use crate::dynamic_imports::DynamicImportedChunks;
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn create_react_loadable_manifest( pub async fn create_react_loadable_manifest(
dynamic_import_entries: Vc<DynamicImportedChunks>, dynamic_import_entries: Vc<DynamicImportedChunks>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
client_relative_path: FileSystemPath, client_relative_path: FileSystemPath,
output_path: FileSystemPath, output_path: FileSystemPath,
runtime: NextRuntime, runtime: NextRuntime,
...@@ -22,31 +24,41 @@ pub async fn create_react_loadable_manifest( ...@@ -22,31 +24,41 @@ pub async fn create_react_loadable_manifest(
let mut loadable_manifest: FxIndexMap<String, LoadableManifest> = FxIndexMap::default(); let mut loadable_manifest: FxIndexMap<String, LoadableManifest> = FxIndexMap::default();
for (_, (module_id, chunk_output)) in dynamic_import_entries.into_iter() { let entries = dynamic_import_entries
let chunk_output = chunk_output.primary_assets().await?; .iter()
.map(|(_, (dynamic_entry, chunk_output))| {
let client_relative_path = client_relative_path.clone();
async move {
let module_id = dynamic_entry.chunk_item_id(chunking_context).await?;
let chunk_output = chunk_output.primary_assets().await?;
let id = &*module_id.await?; let client_relative_path_value = client_relative_path.clone();
let files = chunk_output
.iter()
.map(move |&file| {
let client_relative_path_value = client_relative_path_value.clone();
async move {
Ok(client_relative_path_value
.get_path_to(&*file.path().await?)
.map(|path| path.into()))
}
})
.try_flat_join()
.await?;
let client_relative_path_value = client_relative_path.clone(); Ok((module_id, files))
let files = chunk_output }
.iter() })
.map(move |&file| { .try_join()
let client_relative_path_value = client_relative_path_value.clone(); .await?;
async move {
Ok(client_relative_path_value
.get_path_to(&*file.path().await?)
.map(|path| path.into()))
}
})
.try_flat_join()
.await?;
for (module_id, files) in entries {
let manifest_item = LoadableManifest { let manifest_item = LoadableManifest {
id: id.into(), id: (&module_id).into(),
files, files,
}; };
loadable_manifest.insert(id.to_string(), manifest_item); loadable_manifest.insert(module_id.to_string(), manifest_item);
} }
let manifest_json = serde_json::to_string_pretty(&loadable_manifest)?; let manifest_json = serde_json::to_string_pretty(&loadable_manifest)?;
......
...@@ -1068,11 +1068,15 @@ impl PageEndpoint { ...@@ -1068,11 +1068,15 @@ impl PageEndpoint {
.is_production() .is_production()
{ {
let additional_assets = if emit_manifests == EmitManifests::Full { let additional_assets = if emit_manifests == EmitManifests::Full {
self.react_loadable_manifest(*dynamic_import_entries, NextRuntime::NodeJs) self.react_loadable_manifest(
.await? *dynamic_import_entries,
.iter() project.client_chunking_context(),
.map(|m| **m) NextRuntime::NodeJs,
.collect() )
.await?
.iter()
.map(|m| **m)
.collect()
} else { } else {
vec![] vec![]
}; };
...@@ -1196,6 +1200,7 @@ impl PageEndpoint { ...@@ -1196,6 +1200,7 @@ impl PageEndpoint {
async fn react_loadable_manifest( async fn react_loadable_manifest(
&self, &self,
dynamic_import_entries: Vc<DynamicImportedChunks>, dynamic_import_entries: Vc<DynamicImportedChunks>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
runtime: NextRuntime, runtime: NextRuntime,
) -> Result<Vc<OutputAssets>> { ) -> Result<Vc<OutputAssets>> {
let node_root = self.pages_project.project().node_root().owned().await?; let node_root = self.pages_project.project().node_root().owned().await?;
...@@ -1208,6 +1213,7 @@ impl PageEndpoint { ...@@ -1208,6 +1213,7 @@ impl PageEndpoint {
let loadable_path_prefix = get_asset_prefix_from_pathname(&self.pathname); let loadable_path_prefix = get_asset_prefix_from_pathname(&self.pathname);
Ok(create_react_loadable_manifest( Ok(create_react_loadable_manifest(
dynamic_import_entries, dynamic_import_entries,
chunking_context,
client_relative_path, client_relative_path,
node_root.join(&format!( node_root.join(&format!(
"server/pages{loadable_path_prefix}/react-loadable-manifest", "server/pages{loadable_path_prefix}/react-loadable-manifest",
...@@ -1388,8 +1394,11 @@ impl PageEndpoint { ...@@ -1388,8 +1394,11 @@ impl PageEndpoint {
server_assets.push(pages_manifest); server_assets.push(pages_manifest);
} }
if emit_manifests == EmitManifests::Full { if emit_manifests == EmitManifests::Full {
let loadable_manifest_output = let loadable_manifest_output = self.react_loadable_manifest(
self.react_loadable_manifest(*dynamic_import_entries, NextRuntime::NodeJs); *dynamic_import_entries,
this.pages_project.project().client_chunking_context(),
NextRuntime::NodeJs,
);
server_assets.extend(loadable_manifest_output.await?.iter().copied()); server_assets.extend(loadable_manifest_output.await?.iter().copied());
} }
...@@ -1453,7 +1462,11 @@ impl PageEndpoint { ...@@ -1453,7 +1462,11 @@ impl PageEndpoint {
if emit_manifests == EmitManifests::Full { if emit_manifests == EmitManifests::Full {
let loadable_manifest_output = self let loadable_manifest_output = self
.react_loadable_manifest(*dynamic_import_entries, NextRuntime::Edge) .react_loadable_manifest(
*dynamic_import_entries,
this.pages_project.project().client_chunking_context(),
NextRuntime::Edge,
)
.await?; .await?;
if pages_structure.should_create_pages_entries { if pages_structure.should_create_pages_entries {
server_assets.extend(loadable_manifest_output.iter().copied()); server_assets.extend(loadable_manifest_output.iter().copied());
......
...@@ -48,7 +48,7 @@ use turbopack_core::{ ...@@ -48,7 +48,7 @@ use turbopack_core::{
changed::content_changed, changed::content_changed,
chunk::{ chunk::{
ChunkingContext, EvaluatableAssets, UnusedReferences, ChunkingContext, EvaluatableAssets, UnusedReferences,
module_id_strategies::{DevModuleIdStrategy, ModuleIdStrategy}, chunk_id_strategy::{ModuleIdFallback, ModuleIdStrategy},
}, },
compile_time_info::CompileTimeInfo, compile_time_info::CompileTimeInfo,
context::AssetContext, context::AssetContext,
...@@ -2024,15 +2024,17 @@ impl Project { ...@@ -2024,15 +2024,17 @@ impl Project {
/// Gets the module id strategy for the project. /// Gets the module id strategy for the project.
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn module_ids(self: Vc<Self>) -> Result<Vc<Box<dyn ModuleIdStrategy>>> { pub async fn module_ids(self: Vc<Self>) -> Result<Vc<ModuleIdStrategy>> {
let module_id_strategy = *self.next_config().module_ids(self.next_mode()).await?; let module_id_strategy = *self.next_config().module_ids(self.next_mode()).await?;
match module_id_strategy { match module_id_strategy {
ModuleIdStrategyConfig::Named => Ok(Vc::upcast(DevModuleIdStrategy::new())), ModuleIdStrategyConfig::Named => Ok(ModuleIdStrategy {
module_id_map: None,
fallback: ModuleIdFallback::Ident,
}
.cell()),
ModuleIdStrategyConfig::Deterministic => { ModuleIdStrategyConfig::Deterministic => {
let module_graphs = self.whole_app_module_graphs().await?; let module_graphs = self.whole_app_module_graphs().await?;
Ok(Vc::upcast(get_global_module_id_strategy( Ok(get_global_module_id_strategy(*module_graphs.full))
*module_graphs.full,
)))
} }
} }
} }
......
...@@ -168,7 +168,7 @@ async fn build_manifest( ...@@ -168,7 +168,7 @@ async fn build_manifest(
let actions_value = actions.await?; let actions_value = actions.await?;
let loader_id = chunk_item.id().await?; let loader_id = chunk_item.id().await?;
let loader_id = match &*loader_id { let loader_id = match &loader_id {
ModuleId::Number(id) => ActionManifestModuleId::Number(*id), ModuleId::Number(id) => ActionManifestModuleId::Number(*id),
ModuleId::String(id) => ActionManifestModuleId::String(id), ModuleId::String(id) => ActionManifestModuleId::String(id),
}; };
......
...@@ -155,7 +155,7 @@ where ...@@ -155,7 +155,7 @@ where
.await?; .await?;
Ok(WebpackStatsModule { Ok(WebpackStatsModule {
name: chunk_item.asset_ident().path().await?.path.clone(), name: chunk_item.asset_ident().path().await?.path.clone(),
id: chunk_item.id().owned().await?, id: chunk_item.id().await?,
identifier: chunk_item.asset_ident().to_string().owned().await?, identifier: chunk_item.asset_ident().to_string().owned().await?,
chunks: chunks.into_iter().collect(), chunks: chunks.into_iter().collect(),
size, size,
......
...@@ -193,7 +193,12 @@ impl EcmascriptChunkItem for HmrEntryChunkItem { ...@@ -193,7 +193,12 @@ impl EcmascriptChunkItem for HmrEntryChunkItem {
let this = self.module.await?; let this = self.module.await?;
let module = this.module; let module = this.module;
let chunk_item = module.as_chunk_item(*self.module_graph, *self.chunking_context); let chunk_item = module.as_chunk_item(*self.module_graph, *self.chunking_context);
let id = self.chunking_context.chunk_item_id(chunk_item).await?; let id = self
.chunking_context
.chunk_item_id_strategy()
.await?
.get_id(chunk_item)
.await?;
let mut code = RopeBuilder::default(); let mut code = RopeBuilder::default();
writeln!(code, "{TURBOPACK_REQUIRE}({});", StringifyJs(&id))?; writeln!(code, "{TURBOPACK_REQUIRE}({});", StringifyJs(&id))?;
......
...@@ -17,7 +17,7 @@ use turbopack_browser::{ ...@@ -17,7 +17,7 @@ use turbopack_browser::{
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{
ChunkingConfig, ChunkingContext, MangleType, MinifyType, SourceMapSourceType, ChunkingConfig, ChunkingContext, MangleType, MinifyType, SourceMapSourceType,
SourceMapsType, UnusedReferences, module_id_strategies::ModuleIdStrategy, SourceMapsType, UnusedReferences, chunk_id_strategy::ModuleIdStrategy,
}, },
compile_time_info::{CompileTimeDefines, CompileTimeInfo, FreeVarReference, FreeVarReferences}, compile_time_info::{CompileTimeDefines, CompileTimeInfo, FreeVarReference, FreeVarReferences},
environment::{BrowserEnvironment, Environment, ExecutionEnvironment}, environment::{BrowserEnvironment, Environment, ExecutionEnvironment},
...@@ -420,7 +420,7 @@ pub struct ClientChunkingContextOptions { ...@@ -420,7 +420,7 @@ pub struct ClientChunkingContextOptions {
pub client_root_to_root_path: RcStr, pub client_root_to_root_path: RcStr,
pub asset_prefix: Vc<RcStr>, pub asset_prefix: Vc<RcStr>,
pub environment: Vc<Environment>, pub environment: Vc<Environment>,
pub module_id_strategy: Vc<Box<dyn ModuleIdStrategy>>, pub module_id_strategy: Vc<ModuleIdStrategy>,
pub export_usage: Vc<OptionBindingUsageInfo>, pub export_usage: Vc<OptionBindingUsageInfo>,
pub unused_references: Vc<UnusedReferences>, pub unused_references: Vc<UnusedReferences>,
pub minify: Vc<bool>, pub minify: Vc<bool>,
......
...@@ -7,7 +7,7 @@ use turbopack_browser::BrowserChunkingContext; ...@@ -7,7 +7,7 @@ use turbopack_browser::BrowserChunkingContext;
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{
ChunkingConfig, ChunkingContext, MangleType, MinifyType, SourceMapsType, UnusedReferences, ChunkingConfig, ChunkingContext, MangleType, MinifyType, SourceMapsType, UnusedReferences,
module_id_strategies::ModuleIdStrategy, chunk_id_strategy::ModuleIdStrategy,
}, },
compile_time_info::{CompileTimeDefines, CompileTimeInfo, FreeVarReference, FreeVarReferences}, compile_time_info::{CompileTimeDefines, CompileTimeInfo, FreeVarReference, FreeVarReferences},
environment::{EdgeWorkerEnvironment, Environment, ExecutionEnvironment, NodeJsVersion}, environment::{EdgeWorkerEnvironment, Environment, ExecutionEnvironment, NodeJsVersion},
...@@ -204,7 +204,7 @@ pub struct EdgeChunkingContextOptions { ...@@ -204,7 +204,7 @@ pub struct EdgeChunkingContextOptions {
pub node_root: FileSystemPath, pub node_root: FileSystemPath,
pub output_root_to_root_path: Vc<RcStr>, pub output_root_to_root_path: Vc<RcStr>,
pub environment: Vc<Environment>, pub environment: Vc<Environment>,
pub module_id_strategy: Vc<Box<dyn ModuleIdStrategy>>, pub module_id_strategy: Vc<ModuleIdStrategy>,
pub export_usage: Vc<OptionBindingUsageInfo>, pub export_usage: Vc<OptionBindingUsageInfo>,
pub unused_references: Vc<UnusedReferences>, pub unused_references: Vc<UnusedReferences>,
pub turbo_minify: Vc<bool>, pub turbo_minify: Vc<bool>,
......
...@@ -346,7 +346,7 @@ async fn build_manifest( ...@@ -346,7 +346,7 @@ async fn build_manifest(
get_client_reference_module_key(&server_path, "*"), get_client_reference_module_key(&server_path, "*"),
ManifestNodeEntry { ManifestNodeEntry {
name: rcstr!("*"), name: rcstr!("*"),
id: (&*client_chunk_item_id).into(), id: (&client_chunk_item_id).into(),
chunks: client_chunks_paths, chunks: client_chunks_paths,
// This should of course be client_is_async, but SSR can become // This should of course be client_is_async, but SSR can become
// async due to ESM externals, and // async due to ESM externals, and
...@@ -361,7 +361,7 @@ async fn build_manifest( ...@@ -361,7 +361,7 @@ async fn build_manifest(
rcstr!("*"), rcstr!("*"),
ManifestNodeEntry { ManifestNodeEntry {
name: rcstr!("*"), name: rcstr!("*"),
id: (&*ssr_chunk_item_id).into(), id: (&ssr_chunk_item_id).into(),
chunks: ssr_chunks_paths, chunks: ssr_chunks_paths,
// See above // See above
r#async: client_is_async || ssr_is_async, r#async: client_is_async || ssr_is_async,
...@@ -373,7 +373,7 @@ async fn build_manifest( ...@@ -373,7 +373,7 @@ async fn build_manifest(
rcstr!("*"), rcstr!("*"),
ManifestNodeEntry { ManifestNodeEntry {
name: rcstr!("*"), name: rcstr!("*"),
id: (&*rsc_chunk_item_id).into(), id: (&rsc_chunk_item_id).into(),
chunks: vec![], chunks: vec![],
r#async: rsc_is_async, r#async: rsc_is_async,
}, },
...@@ -383,18 +383,18 @@ async fn build_manifest( ...@@ -383,18 +383,18 @@ async fn build_manifest(
NextRuntime::NodeJs => { NextRuntime::NodeJs => {
entry_manifest entry_manifest
.ssr_module_mapping .ssr_module_mapping
.insert((&*client_chunk_item_id).into(), ssr_manifest_node); .insert((&client_chunk_item_id).into(), ssr_manifest_node);
entry_manifest entry_manifest
.rsc_module_mapping .rsc_module_mapping
.insert((&*client_chunk_item_id).into(), rsc_manifest_node); .insert((&client_chunk_item_id).into(), rsc_manifest_node);
} }
NextRuntime::Edge => { NextRuntime::Edge => {
entry_manifest entry_manifest
.edge_ssr_module_mapping .edge_ssr_module_mapping
.insert((&*client_chunk_item_id).into(), ssr_manifest_node); .insert((&client_chunk_item_id).into(), ssr_manifest_node);
entry_manifest entry_manifest
.edge_rsc_module_mapping .edge_rsc_module_mapping
.insert((&*client_chunk_item_id).into(), rsc_manifest_node); .insert((&client_chunk_item_id).into(), rsc_manifest_node);
} }
} }
} }
......
...@@ -16,7 +16,7 @@ use turbopack::{ ...@@ -16,7 +16,7 @@ use turbopack::{
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{
ChunkingConfig, MangleType, MinifyType, SourceMapSourceType, SourceMapsType, ChunkingConfig, MangleType, MinifyType, SourceMapSourceType, SourceMapsType,
UnusedReferences, module_id_strategies::ModuleIdStrategy, UnusedReferences, chunk_id_strategy::ModuleIdStrategy,
}, },
compile_time_defines, compile_time_defines,
compile_time_info::{CompileTimeDefines, CompileTimeInfo, FreeVarReferences}, compile_time_info::{CompileTimeDefines, CompileTimeInfo, FreeVarReferences},
...@@ -992,7 +992,7 @@ pub struct ServerChunkingContextOptions { ...@@ -992,7 +992,7 @@ pub struct ServerChunkingContextOptions {
pub node_root: FileSystemPath, pub node_root: FileSystemPath,
pub node_root_to_root_path: RcStr, pub node_root_to_root_path: RcStr,
pub environment: Vc<Environment>, pub environment: Vc<Environment>,
pub module_id_strategy: Vc<Box<dyn ModuleIdStrategy>>, pub module_id_strategy: Vc<ModuleIdStrategy>,
pub export_usage: Vc<OptionBindingUsageInfo>, pub export_usage: Vc<OptionBindingUsageInfo>,
pub unused_references: Vc<UnusedReferences>, pub unused_references: Vc<UnusedReferences>,
pub minify: Vc<bool>, pub minify: Vc<bool>,
......
...@@ -13,11 +13,10 @@ use turbopack_core::{ ...@@ -13,11 +13,10 @@ use turbopack_core::{
chunk::{ chunk::{
Chunk, ChunkGroupResult, ChunkItem, ChunkType, ChunkableModule, ChunkingConfig, Chunk, ChunkGroupResult, ChunkItem, ChunkType, ChunkableModule, ChunkingConfig,
ChunkingConfigs, ChunkingContext, EntryChunkGroupResult, EvaluatableAsset, ChunkingConfigs, ChunkingContext, EntryChunkGroupResult, EvaluatableAsset,
EvaluatableAssets, MinifyType, ModuleId, SourceMapSourceType, SourceMapsType, EvaluatableAssets, MinifyType, SourceMapSourceType, SourceMapsType, UnusedReferences,
UnusedReferences,
availability_info::AvailabilityInfo, availability_info::AvailabilityInfo,
chunk_group::{MakeChunkGroupResult, make_chunk_group}, chunk_group::{MakeChunkGroupResult, make_chunk_group},
module_id_strategies::{DevModuleIdStrategy, ModuleIdStrategy}, chunk_id_strategy::ModuleIdStrategy,
}, },
environment::Environment, environment::Environment,
ident::AssetIdent, ident::AssetIdent,
...@@ -161,11 +160,8 @@ impl BrowserChunkingContextBuilder { ...@@ -161,11 +160,8 @@ impl BrowserChunkingContextBuilder {
self self
} }
pub fn module_id_strategy( pub fn module_id_strategy(mut self, module_id_strategy: ResolvedVc<ModuleIdStrategy>) -> Self {
mut self, self.chunking_context.module_id_strategy = Some(module_id_strategy);
module_id_strategy: ResolvedVc<Box<dyn ModuleIdStrategy>>,
) -> Self {
self.chunking_context.module_id_strategy = module_id_strategy;
self self
} }
...@@ -298,7 +294,7 @@ pub struct BrowserChunkingContext { ...@@ -298,7 +294,7 @@ pub struct BrowserChunkingContext {
/// Whether to use manifest chunks for lazy compilation /// Whether to use manifest chunks for lazy compilation
manifest_chunks: bool, manifest_chunks: bool,
/// The module id strategy to use /// The module id strategy to use
module_id_strategy: ResolvedVc<Box<dyn ModuleIdStrategy>>, module_id_strategy: Option<ResolvedVc<ModuleIdStrategy>>,
/// The module export usage info, if available. /// The module export usage info, if available.
export_usage: Option<ResolvedVc<BindingUsageInfo>>, export_usage: Option<ResolvedVc<BindingUsageInfo>>,
/// Which references are unused and should be skipped (e.g. during codegen). /// Which references are unused and should be skipped (e.g. during codegen).
...@@ -349,7 +345,7 @@ impl BrowserChunkingContext { ...@@ -349,7 +345,7 @@ impl BrowserChunkingContext {
source_maps_type: SourceMapsType::Full, source_maps_type: SourceMapsType::Full,
current_chunk_method: CurrentChunkMethod::StringLiteral, current_chunk_method: CurrentChunkMethod::StringLiteral,
manifest_chunks: false, manifest_chunks: false,
module_id_strategy: ResolvedVc::upcast(DevModuleIdStrategy::new_resolved()), module_id_strategy: None,
export_usage: None, export_usage: None,
unused_references: None, unused_references: None,
chunking_configs: Default::default(), chunking_configs: Default::default(),
...@@ -833,8 +829,10 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -833,8 +829,10 @@ impl ChunkingContext for BrowserChunkingContext {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunk_item_id_from_ident(&self, ident: Vc<AssetIdent>) -> Vc<ModuleId> { fn chunk_item_id_strategy(&self) -> Vc<ModuleIdStrategy> {
self.module_id_strategy.get_module_id(ident) *self
.module_id_strategy
.unwrap_or_else(|| ModuleIdStrategy::default().resolved_cell())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -859,14 +857,14 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -859,14 +857,14 @@ impl ChunkingContext for BrowserChunkingContext {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn async_loader_chunk_item_id( async fn async_loader_chunk_item_ident(
self: Vc<Self>, self: Vc<Self>,
module: Vc<Box<dyn ChunkableModule>>, module: Vc<Box<dyn ChunkableModule>>,
) -> Result<Vc<ModuleId>> { ) -> Result<Vc<AssetIdent>> {
Ok(if self.await?.manifest_chunks { Ok(if self.await?.manifest_chunks {
self.chunk_item_id_from_ident(ManifestLoaderChunkItem::asset_ident_for(module)) ManifestLoaderChunkItem::asset_ident_for(module)
} else { } else {
self.chunk_item_id_from_ident(AsyncLoaderModule::asset_ident_for(module)) AsyncLoaderModule::asset_ident_for(module)
}) })
} }
......
...@@ -177,7 +177,7 @@ impl GenerateSourceMap for EcmascriptBrowserChunkContent { ...@@ -177,7 +177,7 @@ impl GenerateSourceMap for EcmascriptBrowserChunkContent {
if let Ok(id) = ModuleId::parse(&section) { if let Ok(id) = ModuleId::parse(&section) {
let entries = self.entries().await?; let entries = self.entries().await?;
for (entry_id, entry) in entries.iter() { for (entry_id, entry) in entries.iter() {
if id == **entry_id { if id == *entry_id {
let sm = entry.code.generate_source_map(); let sm = entry.code.generate_source_map();
return Ok(sm); return Ok(sm);
} }
......
use anyhow::Result; use anyhow::Result;
use either::Either; use either::Either;
use turbo_tasks::{FxIndexMap, ReadRef, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc}; use turbo_tasks::{FxIndexMap, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc};
use turbopack_core::{ use turbopack_core::{
chunk::{AsyncModuleInfo, ChunkItemExt, ModuleId}, chunk::{AsyncModuleInfo, ChunkItemExt, ModuleId},
code_builder::Code, code_builder::Code,
...@@ -39,7 +39,7 @@ impl EcmascriptDevChunkContentEntry { ...@@ -39,7 +39,7 @@ impl EcmascriptDevChunkContentEntry {
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
pub struct EcmascriptBrowserChunkContentEntries( pub struct EcmascriptBrowserChunkContentEntries(
#[bincode(with = "turbo_bincode::indexmap")] #[bincode(with = "turbo_bincode::indexmap")]
FxIndexMap<ReadRef<ModuleId>, EcmascriptDevChunkContentEntry>, FxIndexMap<ModuleId, EcmascriptDevChunkContentEntry>,
); );
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
......
...@@ -5,7 +5,7 @@ use either::Either; ...@@ -5,7 +5,7 @@ use either::Either;
use indoc::writedoc; use indoc::writedoc;
use serde::Serialize; use serde::Serialize;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ReadRef, ResolvedVc, TryJoinIterExt, ValueToString, Vc}; use turbo_tasks::{ResolvedVc, TryJoinIterExt, ValueToString, Vc};
use turbo_tasks_fs::{File, FileContent, FileSystemPath}; use turbo_tasks_fs::{File, FileContent, FileSystemPath};
use turbopack_core::{ use turbopack_core::{
asset::{Asset, AssetContent}, asset::{Asset, AssetContent},
...@@ -314,5 +314,5 @@ struct EcmascriptBrowserChunkRuntimeParams<'a, T> { ...@@ -314,5 +314,5 @@ struct EcmascriptBrowserChunkRuntimeParams<'a, T> {
/// instantiated. /// instantiated.
other_chunks: &'a [T], other_chunks: &'a [T],
/// List of module IDs that this chunk should instantiate when executed. /// List of module IDs that this chunk should instantiate when executed.
runtime_module_ids: Vec<ReadRef<ModuleId>>, runtime_module_ids: Vec<ModuleId>,
} }
...@@ -26,7 +26,7 @@ use super::{ ...@@ -26,7 +26,7 @@ use super::{
struct EcmascriptMergedUpdate<'a> { struct EcmascriptMergedUpdate<'a> {
/// A map from module id to latest module entry. /// A map from module id to latest module entry.
#[serde(skip_serializing_if = "FxIndexMap::is_empty")] #[serde(skip_serializing_if = "FxIndexMap::is_empty")]
entries: FxIndexMap<ReadRef<ModuleId>, EcmascriptModuleEntry>, entries: FxIndexMap<ModuleId, EcmascriptModuleEntry>,
/// A map from chunk path to the chunk update. /// A map from chunk path to the chunk update.
#[serde(skip_serializing_if = "FxIndexMap::is_empty")] #[serde(skip_serializing_if = "FxIndexMap::is_empty")]
chunks: FxIndexMap<&'a str, EcmascriptMergedChunkUpdate>, chunks: FxIndexMap<&'a str, EcmascriptMergedChunkUpdate>,
...@@ -50,7 +50,7 @@ enum EcmascriptMergedChunkUpdate { ...@@ -50,7 +50,7 @@ enum EcmascriptMergedChunkUpdate {
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
struct EcmascriptMergedChunkAdded { struct EcmascriptMergedChunkAdded {
#[serde(skip_serializing_if = "FxIndexSet::is_empty")] #[serde(skip_serializing_if = "FxIndexSet::is_empty")]
modules: FxIndexSet<ReadRef<ModuleId>>, modules: FxIndexSet<ModuleId>,
} }
#[derive(Serialize, Default)] #[derive(Serialize, Default)]
...@@ -60,16 +60,16 @@ struct EcmascriptMergedChunkDeleted { ...@@ -60,16 +60,16 @@ struct EcmascriptMergedChunkDeleted {
// modules in the chunk from the previous version. However, it's useful for // modules in the chunk from the previous version. However, it's useful for
// merging updates without access to an initial state. // merging updates without access to an initial state.
#[serde(skip_serializing_if = "FxIndexSet::is_empty")] #[serde(skip_serializing_if = "FxIndexSet::is_empty")]
modules: FxIndexSet<ReadRef<ModuleId>>, modules: FxIndexSet<ModuleId>,
} }
#[derive(Serialize, Default)] #[derive(Serialize, Default)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
struct EcmascriptMergedChunkPartial { struct EcmascriptMergedChunkPartial {
#[serde(skip_serializing_if = "FxIndexSet::is_empty")] #[serde(skip_serializing_if = "FxIndexSet::is_empty")]
added: FxIndexSet<ReadRef<ModuleId>>, added: FxIndexSet<ModuleId>,
#[serde(skip_serializing_if = "FxIndexSet::is_empty")] #[serde(skip_serializing_if = "FxIndexSet::is_empty")]
deleted: FxIndexSet<ReadRef<ModuleId>>, deleted: FxIndexSet<ModuleId>,
} }
#[derive(Serialize)] #[derive(Serialize)]
...@@ -117,7 +117,7 @@ impl MergedModuleMap { ...@@ -117,7 +117,7 @@ impl MergedModuleMap {
/// Returns the hash of the module with the given id, or `None` if the /// Returns the hash of the module with the given id, or `None` if the
/// module is not present in any of the versions. /// module is not present in any of the versions.
fn get(&self, id: &ReadRef<ModuleId>) -> Option<u64> { fn get(&self, id: &ModuleId) -> Option<u64> {
for version in &self.versions { for version in &self.versions {
if let Some(hash) = version.entries_hashes.get(id) { if let Some(hash) = version.entries_hashes.get(id) {
return Some(*hash); return Some(*hash);
......
...@@ -11,9 +11,9 @@ pub(super) enum EcmascriptChunkUpdate { ...@@ -11,9 +11,9 @@ pub(super) enum EcmascriptChunkUpdate {
} }
pub(super) struct EcmascriptChunkPartialUpdate { pub(super) struct EcmascriptChunkPartialUpdate {
pub added: FxIndexMap<ReadRef<ModuleId>, (u64, ResolvedVc<Code>)>, pub added: FxIndexMap<ModuleId, (u64, ResolvedVc<Code>)>,
pub deleted: FxIndexMap<ReadRef<ModuleId>, u64>, pub deleted: FxIndexMap<ModuleId, u64>,
pub modified: FxIndexMap<ReadRef<ModuleId>, ResolvedVc<Code>>, pub modified: FxIndexMap<ModuleId, ResolvedVc<Code>>,
} }
pub(super) async fn update_ecmascript_chunk( pub(super) async fn update_ecmascript_chunk(
......
use anyhow::{Result, bail}; use anyhow::{Result, bail};
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexMap, ReadRef, Vc}; use turbo_tasks::{FxIndexMap, Vc};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbo_tasks_hash::{Xxh3Hash64Hasher, encode_hex}; use turbo_tasks_hash::{Xxh3Hash64Hasher, encode_hex};
use turbopack_core::{chunk::ModuleId, version::Version}; use turbopack_core::{chunk::ModuleId, version::Version};
...@@ -11,7 +11,7 @@ use super::content_entry::EcmascriptBrowserChunkContentEntries; ...@@ -11,7 +11,7 @@ use super::content_entry::EcmascriptBrowserChunkContentEntries;
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "none")]
pub(super) struct EcmascriptBrowserChunkVersion { pub(super) struct EcmascriptBrowserChunkVersion {
pub(super) chunk_path: String, pub(super) chunk_path: String,
pub(super) entries_hashes: FxIndexMap<ReadRef<ModuleId>, u64>, pub(super) entries_hashes: FxIndexMap<ModuleId, u64>,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
......
...@@ -319,11 +319,9 @@ async fn build_internal( ...@@ -319,11 +319,9 @@ async fn build_internal(
module_graph = module_graph =
ModuleGraph::from_single_graph_without_unused_references(single_graph, binding_usage); ModuleGraph::from_single_graph_without_unused_references(single_graph, binding_usage);
let module_graph = module_graph.connect(); let module_graph = module_graph.connect();
let module_id_strategy = ResolvedVc::upcast( let module_id_strategy = get_global_module_id_strategy(module_graph)
get_global_module_id_strategy(module_graph) .to_resolved()
.to_resolved() .await?;
.await?,
);
let chunking_context: Vc<Box<dyn ChunkingContext>> = match target { let chunking_context: Vc<Box<dyn ChunkingContext>> = match target {
Target::Browser => { Target::Browser => {
......
use anyhow::{Result, bail};
use bincode::{Decode, Encode};
use rustc_hash::FxHashMap;
use turbo_tasks::{
NonLocalValue, ResolvedVc, ValueToString, Vc, debug::ValueDebugFormat, trace::TraceRawVcs,
};
use turbo_tasks_hash::hash_xxh3_hash64;
use super::ModuleId;
use crate::{chunk::ChunkItem, ident::AssetIdent, module::Module};
#[turbo_tasks::value(transparent, cell = "keyed")]
pub struct ModuleIds(FxHashMap<ResolvedVc<AssetIdent>, ModuleId>);
#[derive(
Default, Clone, PartialEq, Eq, ValueDebugFormat, TraceRawVcs, NonLocalValue, Encode, Decode,
)]
pub enum ModuleIdFallback {
Error,
#[default]
Ident,
}
#[turbo_tasks::value(shared)]
#[derive(Default)]
pub struct ModuleIdStrategy {
pub module_id_map: Option<ResolvedVc<ModuleIds>>,
pub fallback: ModuleIdFallback,
}
impl ModuleIdStrategy {
pub async fn get_id(&self, chunk_item: Vc<Box<dyn ChunkItem>>) -> Result<ModuleId> {
let ident = chunk_item.asset_ident();
self.get_id_from_ident(ident).await
}
pub async fn get_id_from_module(&self, module: Vc<Box<dyn Module>>) -> Result<ModuleId> {
let ident = module.ident();
self.get_id_from_ident(ident).await
}
pub async fn get_id_from_ident(&self, ident: Vc<AssetIdent>) -> Result<ModuleId> {
let ident = ident.to_resolved().await?;
if let Some(module_id_map) = self.module_id_map
&& let Some(module_id) = module_id_map.get(&ident).await?.as_deref().cloned()
{
return Ok(module_id);
}
match self.fallback {
ModuleIdFallback::Error => {
let ident_string = ident.to_string().await?;
if ident_string.ends_with("[app-client] (ecmascript, next/dynamic entry)") {
// TODO: This shouldn't happen, but is a temporary workaround to ignore
// next/dynamic imports of a server component from another
// server component.
return Ok(ModuleId::String(
hash_xxh3_hash64(ident.to_string().await?)
.to_string()
.into(),
));
}
bail!("ModuleId not found for ident: {}", ident.to_string().await?);
}
ModuleIdFallback::Ident => Ok(ModuleId::String(ident.to_string().owned().await?)),
}
}
}
...@@ -10,8 +10,8 @@ use turbo_tasks_hash::DeterministicHash; ...@@ -10,8 +10,8 @@ use turbo_tasks_hash::DeterministicHash;
use crate::{ use crate::{
asset::Asset, asset::Asset,
chunk::{ chunk::{
ChunkItem, ChunkType, ChunkableModule, EvaluatableAssets, ModuleId, ChunkItem, ChunkType, ChunkableModule, EvaluatableAssets,
availability_info::AvailabilityInfo, availability_info::AvailabilityInfo, chunk_id_strategy::ModuleIdStrategy,
}, },
environment::Environment, environment::Environment,
ident::AssetIdent, ident::AssetIdent,
...@@ -393,7 +393,8 @@ pub trait ChunkingContext { ...@@ -393,7 +393,8 @@ pub trait ChunkingContext {
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<Box<dyn ChunkItem>>; ) -> Vc<Box<dyn ChunkItem>>;
#[turbo_tasks::function] #[turbo_tasks::function]
fn async_loader_chunk_item_id(&self, module: Vc<Box<dyn ChunkableModule>>) -> Vc<ModuleId>; fn async_loader_chunk_item_ident(&self, module: Vc<Box<dyn ChunkableModule>>)
-> Vc<AssetIdent>;
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunk_group( fn chunk_group(
...@@ -429,19 +430,7 @@ pub trait ChunkingContext { ...@@ -429,19 +430,7 @@ pub trait ChunkingContext {
) -> Result<Vc<EntryChunkGroupResult>>; ) -> Result<Vc<EntryChunkGroupResult>>;
#[turbo_tasks::function] #[turbo_tasks::function]
async fn chunk_item_id_from_ident( async fn chunk_item_id_strategy(self: Vc<Self>) -> Result<Vc<ModuleIdStrategy>>;
self: Vc<Self>,
ident: Vc<AssetIdent>,
) -> Result<Vc<ModuleId>>;
#[turbo_tasks::function]
fn chunk_item_id(self: Vc<Self>, module: Vc<Box<dyn ChunkItem>>) -> Vc<ModuleId> {
self.chunk_item_id_from_ident(module.asset_ident())
}
#[turbo_tasks::function]
fn chunk_item_id_from_module(self: Vc<Self>, module: Vc<Box<dyn Module>>) -> Vc<ModuleId> {
self.chunk_item_id_from_ident(module.ident())
}
#[turbo_tasks::function] #[turbo_tasks::function]
async fn module_export_usage( async fn module_export_usage(
......
use anyhow::Result; use anyhow::Result;
use turbo_tasks::{ReadRef, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc}; use turbo_tasks::{ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbo_tasks_hash::Xxh3Hash64Hasher; use turbo_tasks_hash::Xxh3Hash64Hasher;
...@@ -11,8 +11,8 @@ use crate::{ ...@@ -11,8 +11,8 @@ use crate::{
#[turbo_tasks::value] #[turbo_tasks::value]
pub struct ChunkData { pub struct ChunkData {
pub path: String, pub path: String,
pub included: Vec<ReadRef<ModuleId>>, pub included: Vec<ModuleId>,
pub excluded: Vec<ReadRef<ModuleId>>, pub excluded: Vec<ModuleId>,
pub module_chunks: Vec<String>, pub module_chunks: Vec<String>,
} }
...@@ -94,12 +94,12 @@ impl ChunkData { ...@@ -94,12 +94,12 @@ impl ChunkData {
} = &*runtime_info; } = &*runtime_info;
let included = if let Some(included_ids) = included_ids { let included = if let Some(included_ids) = included_ids {
included_ids.await?.iter().copied().try_join().await? included_ids.owned().await?
} else { } else {
Vec::new() Vec::new()
}; };
let excluded = if let Some(excluded_ids) = excluded_ids { let excluded = if let Some(excluded_ids) = excluded_ids {
excluded_ids.await?.iter().copied().try_join().await? excluded_ids.owned().await?
} else { } else {
Vec::new() Vec::new()
}; };
......
pub mod availability_info; pub mod availability_info;
pub mod available_modules; pub mod available_modules;
pub mod chunk_group; pub mod chunk_group;
pub mod chunk_id_strategy;
pub(crate) mod chunk_item_batch; pub(crate) mod chunk_item_batch;
pub mod chunking; pub mod chunking;
pub(crate) mod chunking_context; pub(crate) mod chunking_context;
pub(crate) mod data; pub(crate) mod data;
pub(crate) mod evaluate; pub(crate) mod evaluate;
pub mod module_id_strategies;
use std::fmt::Display; use std::fmt::Display;
...@@ -85,7 +85,7 @@ impl ModuleId { ...@@ -85,7 +85,7 @@ impl ModuleId {
/// A list of module ids. /// A list of module ids.
#[turbo_tasks::value(transparent, shared)] #[turbo_tasks::value(transparent, shared)]
pub struct ModuleIds(Vec<ResolvedVc<ModuleId>>); pub struct ModuleIds(Vec<ModuleId>);
/// A [Module] that can be converted into a [Chunk]. /// A [Module] that can be converted into a [Chunk].
#[turbo_tasks::value_trait] #[turbo_tasks::value_trait]
...@@ -512,17 +512,22 @@ pub struct ChunkItemsWithAsyncModuleInfo(Vec<ChunkItemWithAsyncModuleInfo>); ...@@ -512,17 +512,22 @@ pub struct ChunkItemsWithAsyncModuleInfo(Vec<ChunkItemWithAsyncModuleInfo>);
pub trait ChunkItemExt { pub trait ChunkItemExt {
/// Returns the module id of this chunk item. /// Returns the module id of this chunk item.
fn id(self: Vc<Self>) -> Vc<ModuleId>; fn id(self: Vc<Self>) -> impl Future<Output = Result<ModuleId>> + Send;
} }
impl<T> ChunkItemExt for T impl<T> ChunkItemExt for T
where where
T: Upcast<Box<dyn ChunkItem>>, T: Upcast<Box<dyn ChunkItem>> + Send,
{ {
/// Returns the module id of this chunk item. /// Returns the module id of this chunk item.
fn id(self: Vc<Self>) -> Vc<ModuleId> { async fn id(self: Vc<Self>) -> Result<ModuleId> {
let chunk_item = Vc::upcast_non_strict(self); let chunk_item = Vc::upcast_non_strict(self);
chunk_item.chunking_context().chunk_item_id(chunk_item) chunk_item
.chunking_context()
.chunk_item_id_strategy()
.await?
.get_id(chunk_item)
.await
} }
} }
...@@ -531,17 +536,21 @@ pub trait ModuleChunkItemIdExt { ...@@ -531,17 +536,21 @@ pub trait ModuleChunkItemIdExt {
fn chunk_item_id( fn chunk_item_id(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Vc<ModuleId>; ) -> impl Future<Output = Result<ModuleId>> + Send;
} }
impl<T> ModuleChunkItemIdExt for T impl<T> ModuleChunkItemIdExt for T
where where
T: Upcast<Box<dyn Module>>, T: Upcast<Box<dyn Module>> + Send,
{ {
fn chunk_item_id( async fn chunk_item_id(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Vc<ModuleId> { ) -> Result<ModuleId> {
chunking_context.chunk_item_id_from_module(Vc::upcast_non_strict(self)) chunking_context
.chunk_item_id_strategy()
.await?
.get_id_from_module(Vc::upcast_non_strict(self))
.await
} }
} }
......
use anyhow::{Result, bail};
use rustc_hash::FxHashMap;
use turbo_tasks::{ResolvedVc, ValueToString, Vc};
use turbo_tasks_hash::hash_xxh3_hash64;
use super::ModuleId;
use crate::ident::AssetIdent;
#[turbo_tasks::value_trait]
pub trait ModuleIdStrategy {
#[turbo_tasks::function]
fn get_module_id(self: Vc<Self>, ident: Vc<AssetIdent>) -> Vc<ModuleId>;
}
#[turbo_tasks::value]
pub struct DevModuleIdStrategy;
impl DevModuleIdStrategy {
pub fn new() -> Vc<Self> {
DevModuleIdStrategy {}.cell()
}
pub fn new_resolved() -> ResolvedVc<Self> {
DevModuleIdStrategy {}.resolved_cell()
}
}
#[turbo_tasks::value_impl]
impl ModuleIdStrategy for DevModuleIdStrategy {
#[turbo_tasks::function]
async fn get_module_id(self: Vc<Self>, ident: Vc<AssetIdent>) -> Result<Vc<ModuleId>> {
Ok(ModuleId::String(ident.to_string().owned().await?).cell())
}
}
#[turbo_tasks::value(shared)]
pub struct GlobalModuleIdStrategy {
pub module_id_map: FxHashMap<ResolvedVc<AssetIdent>, u64>,
}
#[turbo_tasks::value_impl]
impl ModuleIdStrategy for GlobalModuleIdStrategy {
#[turbo_tasks::function]
async fn get_module_id(&self, ident: ResolvedVc<AssetIdent>) -> Result<Vc<ModuleId>> {
if let Some(module_id) = self.module_id_map.get(&ident) {
const JS_MAX_SAFE_INTEGER: u64 = (1u64 << 53) - 1;
if *module_id > JS_MAX_SAFE_INTEGER {
bail!("Numeric module id is too large: {}", module_id);
}
return Ok(ModuleId::Number(*module_id).cell());
}
let ident_string = ident.to_string().await?;
if ident_string.ends_with("[app-client] (ecmascript, next/dynamic entry)") {
// TODO: This shouldn't happen, but is a temporary workaround to ignore next/dynamic
// imports of a server component from another server component.
return Ok(ModuleId::String(
hash_xxh3_hash64(ident.to_string().await?)
.to_string()
.into(),
)
.cell());
}
bail!("ModuleId not found for ident: {ident_string:?}");
}
}
...@@ -357,7 +357,7 @@ impl OutputChunk for CssChunk { ...@@ -357,7 +357,7 @@ impl OutputChunk for CssChunk {
let entries_chunk_items = &content.chunk_items; let entries_chunk_items = &content.chunk_items;
let included_ids = entries_chunk_items let included_ids = entries_chunk_items
.iter() .iter()
.map(|chunk_item| chunk_item.id().to_resolved()) .map(|chunk_item| chunk_item.id())
.try_join() .try_join()
.await?; .await?;
let imports_chunk_items: Vec<_> = entries_chunk_items let imports_chunk_items: Vec<_> = entries_chunk_items
......
...@@ -387,7 +387,7 @@ impl EcmascriptChunkItem for ModuleChunkItem { ...@@ -387,7 +387,7 @@ impl EcmascriptChunkItem for ModuleChunkItem {
ResolvedVc::upcast(css_module); ResolvedVc::upcast(css_module);
let module_id = placeable.chunk_item_id(*self.chunking_context).await?; let module_id = placeable.chunk_item_id(*self.chunking_context).await?;
let module_id = StringifyJs(&*module_id); let module_id = StringifyJs(&module_id);
let original_name = StringifyJs(&original_name); let original_name = StringifyJs(&original_name);
exported_class_names exported_class_names
.push(format!("{TURBOPACK_IMPORT}({module_id})[{original_name}]")); .push(format!("{TURBOPACK_IMPORT}({module_id})[{original_name}]"));
......
...@@ -96,7 +96,7 @@ impl EcmascriptChunkItem for AsyncLoaderChunkItem { ...@@ -96,7 +96,7 @@ impl EcmascriptChunkItem for AsyncLoaderChunkItem {
} else { } else {
None None
}; };
let id = id.as_deref(); let id = id.as_ref();
let chunks_data = self.chunks_data().await?; let chunks_data = self.chunks_data().await?;
let chunks_data = chunks_data.iter().try_join().await?; let chunks_data = chunks_data.iter().try_join().await?;
......
...@@ -13,7 +13,7 @@ use crate::chunk::{ ...@@ -13,7 +13,7 @@ use crate::chunk::{
}; };
#[turbo_tasks::value(transparent, serialization = "none")] #[turbo_tasks::value(transparent, serialization = "none")]
pub struct CodeAndIds(SmallVec<[(ReadRef<ModuleId>, ReadRef<Code>); 1]>); pub struct CodeAndIds(SmallVec<[(ModuleId, ReadRef<Code>); 1]>);
#[turbo_tasks::value(transparent, serialization = "none")] #[turbo_tasks::value(transparent, serialization = "none")]
pub struct BatchGroupCodeAndIds( pub struct BatchGroupCodeAndIds(
...@@ -47,9 +47,9 @@ pub async fn item_code_and_ids( ...@@ -47,9 +47,9 @@ pub async fn item_code_and_ids(
async_info, async_info,
.. ..
}) => { }) => {
let id = chunk_item.id(); let id = chunk_item.id().await?;
let code = chunk_item.code(async_info.map(|info| *info)); let code = chunk_item.code(async_info.map(|info| *info));
smallvec![(id.await?, code.await?)] smallvec![(id, code.await?)]
} }
EcmascriptChunkItemOrBatchWithAsyncInfo::Batch(batch) => batch EcmascriptChunkItemOrBatchWithAsyncInfo::Batch(batch) => batch
.await? .await?
......
use serde::Serialize; use serde::Serialize;
use turbo_tasks::ReadRef;
use turbopack_core::chunk::{ChunkData, ModuleId}; use turbopack_core::chunk::{ChunkData, ModuleId};
#[derive(Serialize, Hash, PartialEq, Eq)] #[derive(Serialize, Hash, PartialEq, Eq)]
...@@ -10,9 +9,9 @@ pub enum EcmascriptChunkData<'a> { ...@@ -10,9 +9,9 @@ pub enum EcmascriptChunkData<'a> {
WithRuntimeInfo { WithRuntimeInfo {
path: &'a str, path: &'a str,
#[serde(skip_serializing_if = "<[_]>::is_empty", default)] #[serde(skip_serializing_if = "<[_]>::is_empty", default)]
included: &'a [ReadRef<ModuleId>], included: &'a [ModuleId],
#[serde(skip_serializing_if = "<[_]>::is_empty", default)] #[serde(skip_serializing_if = "<[_]>::is_empty", default)]
excluded: &'a [ReadRef<ModuleId>], excluded: &'a [ModuleId],
#[serde(skip_serializing_if = "<[_]>::is_empty", default)] #[serde(skip_serializing_if = "<[_]>::is_empty", default)]
module_chunks: &'a [String], module_chunks: &'a [String],
}, },
......
...@@ -5,8 +5,7 @@ use bincode::{Decode, Encode}; ...@@ -5,8 +5,7 @@ use bincode::{Decode, Encode};
use smallvec::SmallVec; use smallvec::SmallVec;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ use turbo_tasks::{
NonLocalValue, ResolvedVc, TaskInput, TryJoinIterExt, Upcast, ValueToString, Vc, NonLocalValue, ResolvedVc, TaskInput, Upcast, ValueToString, Vc, trace::TraceRawVcs,
trace::TraceRawVcs,
}; };
use turbo_tasks_fs::{FileSystemPath, rope::Rope}; use turbo_tasks_fs::{FileSystemPath, rope::Rope};
use turbopack_core::{ use turbopack_core::{
...@@ -53,7 +52,7 @@ pub enum RewriteSourcePath { ...@@ -53,7 +52,7 @@ pub enum RewriteSourcePath {
pub struct EcmascriptChunkItemContent { pub struct EcmascriptChunkItemContent {
pub inner_code: Rope, pub inner_code: Rope,
pub source_map: Option<Rope>, pub source_map: Option<Rope>,
pub additional_ids: SmallVec<[ResolvedVc<ModuleId>; 1]>, pub additional_ids: SmallVec<[ModuleId; 1]>,
pub options: EcmascriptChunkItemOptions, pub options: EcmascriptChunkItemOptions,
pub rewrite_source_path: RewriteSourcePath, pub rewrite_source_path: RewriteSourcePath,
pub placeholder_for_future_extensions: (), pub placeholder_for_future_extensions: (),
...@@ -122,8 +121,8 @@ impl EcmascriptChunkItemContent { ...@@ -122,8 +121,8 @@ impl EcmascriptChunkItemContent {
impl EcmascriptChunkItemContent { impl EcmascriptChunkItemContent {
async fn module_factory(&self) -> Result<ResolvedVc<Code>> { async fn module_factory(&self) -> Result<ResolvedVc<Code>> {
let mut code = CodeBuilder::default(); let mut code = CodeBuilder::default();
for additional_id in self.additional_ids.iter().try_join().await? { for additional_id in self.additional_ids.iter() {
writeln!(code, "{}, ", StringifyJs(&*additional_id))?; writeln!(code, "{}, ", StringifyJs(&additional_id))?;
} }
if self.options.module_and_exports { if self.options.module_and_exports {
code += "((__turbopack_context__, module, exports) => {\n"; code += "((__turbopack_context__, module, exports) => {\n";
......
...@@ -955,7 +955,7 @@ pub struct EcmascriptModuleContent { ...@@ -955,7 +955,7 @@ pub struct EcmascriptModuleContent {
pub source_map: Option<Rope>, pub source_map: Option<Rope>,
pub is_esm: bool, pub is_esm: bool,
pub strict: bool, pub strict: bool,
pub additional_ids: SmallVec<[ResolvedVc<ModuleId>; 1]>, pub additional_ids: SmallVec<[ModuleId; 1]>,
} }
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
...@@ -1235,7 +1235,7 @@ impl EcmascriptModuleContent { ...@@ -1235,7 +1235,7 @@ impl EcmascriptModuleContent {
**m != first_entry **m != first_entry
&& *modules.get(*m).unwrap() == MergeableModuleExposure::External && *modules.get(*m).unwrap() == MergeableModuleExposure::External
}) })
.map(|m| m.chunk_item_id(*options.chunking_context).to_resolved()) .map(|m| m.chunk_item_id(*options.chunking_context))
.try_join() .try_join()
.await? .await?
.into(); .into();
...@@ -2093,7 +2093,7 @@ async fn with_consumed_parse_result<T>( ...@@ -2093,7 +2093,7 @@ async fn with_consumed_parse_result<T>(
async fn emit_content( async fn emit_content(
content: CodeGenResult, content: CodeGenResult,
additional_ids: SmallVec<[ResolvedVc<ModuleId>; 1]>, additional_ids: SmallVec<[ModuleId; 1]>,
) -> Result<Vc<EcmascriptModuleContent>> { ) -> Result<Vc<EcmascriptModuleContent>> {
let CodeGenResult { let CodeGenResult {
program, program,
......
...@@ -135,7 +135,7 @@ impl EcmascriptChunkItem for ManifestLoaderChunkItem { ...@@ -135,7 +135,7 @@ impl EcmascriptChunkItem for ManifestLoaderChunkItem {
// We also need the manifest chunk item's id, which points to a CJS module that // We also need the manifest chunk item's id, which points to a CJS module that
// exports a promise for all of the necessary chunk loads. // exports a promise for all of the necessary chunk loads.
let item_id = &*this let item_id = this
.manifest .manifest
.chunk_item_id(*manifest.chunking_context) .chunk_item_id(*manifest.chunking_context)
.await?; .await?;
...@@ -145,7 +145,7 @@ impl EcmascriptChunkItem for ManifestLoaderChunkItem { ...@@ -145,7 +145,7 @@ impl EcmascriptChunkItem for ManifestLoaderChunkItem {
let placeable = let placeable =
ResolvedVc::try_downcast::<Box<dyn EcmascriptChunkPlaceable>>(manifest.inner) ResolvedVc::try_downcast::<Box<dyn EcmascriptChunkPlaceable>>(manifest.inner)
.ok_or_else(|| anyhow!("asset is not placeable in ecmascript chunk"))?; .ok_or_else(|| anyhow!("asset is not placeable in ecmascript chunk"))?;
let dynamic_id = &*placeable.chunk_item_id(*manifest.chunking_context).await?; let dynamic_id = placeable.chunk_item_id(*manifest.chunking_context).await?;
// This is the code that will be executed when the dynamic import is reached. // This is the code that will be executed when the dynamic import is reached.
// It will load the manifest chunk, which will load all the chunks needed by // It will load the manifest chunk, which will load all the chunks needed by
...@@ -172,8 +172,8 @@ impl EcmascriptChunkItem for ManifestLoaderChunkItem { ...@@ -172,8 +172,8 @@ impl EcmascriptChunkItem for ManifestLoaderChunkItem {
.map(|chunk_data| EcmascriptChunkData::new(chunk_data)) .map(|chunk_data| EcmascriptChunkData::new(chunk_data))
.collect::<Vec<_>>() .collect::<Vec<_>>()
), ),
item_id = StringifyModuleId(item_id), item_id = StringifyModuleId(&item_id),
dynamic_id = StringifyModuleId(dynamic_id), dynamic_id = StringifyModuleId(&dynamic_id),
)?; )?;
Ok(EcmascriptChunkItemContent { Ok(EcmascriptChunkItemContent {
......
...@@ -354,12 +354,17 @@ async fn to_single_pattern_mapping( ...@@ -354,12 +354,17 @@ async fn to_single_pattern_mapping(
if let Some(chunkable) = ResolvedVc::try_downcast::<Box<dyn ChunkableModule>>(module) { if let Some(chunkable) = ResolvedVc::try_downcast::<Box<dyn ChunkableModule>>(module) {
match resolve_type { match resolve_type {
ResolveType::AsyncChunkLoader => { ResolveType::AsyncChunkLoader => {
let loader_id = chunking_context.async_loader_chunk_item_id(*chunkable); let ident = chunking_context.async_loader_chunk_item_ident(*chunkable);
return Ok(SinglePatternMapping::ModuleLoader(loader_id.owned().await?)); let loader_id = chunking_context
.chunk_item_id_strategy()
.await?
.get_id_from_ident(ident)
.await?;
return Ok(SinglePatternMapping::ModuleLoader(loader_id));
} }
ResolveType::ChunkItem => { ResolveType::ChunkItem => {
let item_id = chunkable.chunk_item_id(chunking_context); let item_id = chunkable.chunk_item_id(chunking_context).await?;
return Ok(SinglePatternMapping::Module(item_id.owned().await?)); return Ok(SinglePatternMapping::Module(item_id));
} }
} }
} }
......
...@@ -143,7 +143,9 @@ impl WorkerAssetReferenceCodeGen { ...@@ -143,7 +143,9 @@ impl WorkerAssetReferenceCodeGen {
}; };
let item_id = chunking_context let item_id = chunking_context
.chunk_item_id_from_ident(loader.ident()) .chunk_item_id_strategy()
.await?
.get_id_from_ident(loader.ident())
.await?; .await?;
let visitor = create_visitor!(self.path, visit_mut_expr, |expr: &mut Expr| { let visitor = create_visitor!(self.path, visit_mut_expr, |expr: &mut Expr| {
......
...@@ -150,7 +150,7 @@ impl EcmascriptChunkItem for SideEffectsModuleChunkItem { ...@@ -150,7 +150,7 @@ impl EcmascriptChunkItem for SideEffectsModuleChunkItem {
format!( format!(
"{}{TURBOPACK_IMPORT}({});\n", "{}{TURBOPACK_IMPORT}({});\n",
if need_await { "await " } else { "" }, if need_await { "await " } else { "" },
StringifyModuleId(&*side_effect.chunk_item_id(*self.chunking_context).await?) StringifyModuleId(&side_effect.chunk_item_id(*self.chunking_context).await?)
) )
.as_bytes(), .as_bytes(),
); );
...@@ -160,7 +160,7 @@ impl EcmascriptChunkItem for SideEffectsModuleChunkItem { ...@@ -160,7 +160,7 @@ impl EcmascriptChunkItem for SideEffectsModuleChunkItem {
format!( format!(
"{TURBOPACK_EXPORT_NAMESPACE}({TURBOPACK_IMPORT}({}));\n", "{TURBOPACK_EXPORT_NAMESPACE}({TURBOPACK_IMPORT}({}));\n",
StringifyModuleId( StringifyModuleId(
&*module &module
.resolved_as .resolved_as
.chunk_item_id(*self.chunking_context) .chunk_item_id(*self.chunking_context)
.await? .await?
......
...@@ -8,10 +8,10 @@ use turbopack_core::{ ...@@ -8,10 +8,10 @@ use turbopack_core::{
chunk::{ chunk::{
Chunk, ChunkGroupResult, ChunkItem, ChunkType, ChunkableModule, ChunkingConfig, Chunk, ChunkGroupResult, ChunkItem, ChunkType, ChunkableModule, ChunkingConfig,
ChunkingConfigs, ChunkingContext, EntryChunkGroupResult, EvaluatableAssets, MinifyType, ChunkingConfigs, ChunkingContext, EntryChunkGroupResult, EvaluatableAssets, MinifyType,
ModuleId, SourceMapSourceType, SourceMapsType, UnusedReferences, SourceMapSourceType, SourceMapsType, UnusedReferences,
availability_info::AvailabilityInfo, availability_info::AvailabilityInfo,
chunk_group::{MakeChunkGroupResult, make_chunk_group}, chunk_group::{MakeChunkGroupResult, make_chunk_group},
module_id_strategies::{DevModuleIdStrategy, ModuleIdStrategy}, chunk_id_strategy::ModuleIdStrategy,
}, },
environment::Environment, environment::Environment,
ident::AssetIdent, ident::AssetIdent,
...@@ -109,11 +109,8 @@ impl NodeJsChunkingContextBuilder { ...@@ -109,11 +109,8 @@ impl NodeJsChunkingContextBuilder {
self self
} }
pub fn module_id_strategy( pub fn module_id_strategy(mut self, module_id_strategy: ResolvedVc<ModuleIdStrategy>) -> Self {
mut self, self.chunking_context.module_id_strategy = Some(module_id_strategy);
module_id_strategy: ResolvedVc<Box<dyn ModuleIdStrategy>>,
) -> Self {
self.chunking_context.module_id_strategy = module_id_strategy;
self self
} }
...@@ -194,7 +191,7 @@ pub struct NodeJsChunkingContext { ...@@ -194,7 +191,7 @@ pub struct NodeJsChunkingContext {
/// Whether to use manifest chunks for lazy compilation /// Whether to use manifest chunks for lazy compilation
manifest_chunks: bool, manifest_chunks: bool,
/// The strategy to use for generating module ids /// The strategy to use for generating module ids
module_id_strategy: ResolvedVc<Box<dyn ModuleIdStrategy>>, module_id_strategy: Option<ResolvedVc<ModuleIdStrategy>>,
/// The module export usage info, if available. /// The module export usage info, if available.
export_usage: Option<ResolvedVc<BindingUsageInfo>>, export_usage: Option<ResolvedVc<BindingUsageInfo>>,
/// Which references are unused and should be skipped (e.g. during codegen). /// Which references are unused and should be skipped (e.g. during codegen).
...@@ -241,7 +238,7 @@ impl NodeJsChunkingContext { ...@@ -241,7 +238,7 @@ impl NodeJsChunkingContext {
source_maps_type: SourceMapsType::Full, source_maps_type: SourceMapsType::Full,
manifest_chunks: false, manifest_chunks: false,
source_map_source_type: SourceMapSourceType::TurbopackUri, source_map_source_type: SourceMapSourceType::TurbopackUri,
module_id_strategy: ResolvedVc::upcast(DevModuleIdStrategy::new_resolved()), module_id_strategy: None,
export_usage: None, export_usage: None,
unused_references: None, unused_references: None,
chunking_configs: Default::default(), chunking_configs: Default::default(),
...@@ -579,8 +576,10 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -579,8 +576,10 @@ impl ChunkingContext for NodeJsChunkingContext {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunk_item_id_from_ident(&self, ident: Vc<AssetIdent>) -> Vc<ModuleId> { fn chunk_item_id_strategy(&self) -> Vc<ModuleIdStrategy> {
self.module_id_strategy.get_module_id(ident) *self
.module_id_strategy
.unwrap_or_else(|| ModuleIdStrategy::default().resolved_cell())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -605,14 +604,14 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -605,14 +604,14 @@ impl ChunkingContext for NodeJsChunkingContext {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn async_loader_chunk_item_id( async fn async_loader_chunk_item_ident(
self: Vc<Self>, self: Vc<Self>,
module: Vc<Box<dyn ChunkableModule>>, module: Vc<Box<dyn ChunkableModule>>,
) -> Result<Vc<ModuleId>> { ) -> Result<Vc<AssetIdent>> {
Ok(if self.await?.manifest_chunks { Ok(if self.await?.manifest_chunks {
self.chunk_item_id_from_ident(ManifestLoaderChunkItem::asset_ident_for(module)) ManifestLoaderChunkItem::asset_ident_for(module)
} else { } else {
self.chunk_item_id_from_ident(AsyncLoaderModule::asset_ident_for(module)) AsyncLoaderModule::asset_ident_for(module)
}) })
} }
......
...@@ -126,7 +126,7 @@ impl EcmascriptBuildNodeEntryChunk { ...@@ -126,7 +126,7 @@ impl EcmascriptBuildNodeEntryChunk {
r#" r#"
R.m({}) R.m({})
"#, "#,
StringifyJs(&*runtime_module_id), StringifyJs(&runtime_module_id),
)?; )?;
} }
} }
...@@ -141,7 +141,7 @@ impl EcmascriptBuildNodeEntryChunk { ...@@ -141,7 +141,7 @@ impl EcmascriptBuildNodeEntryChunk {
r#" r#"
module.exports=R.m({}).exports module.exports=R.m({}).exports
"#, "#,
StringifyJs(&*runtime_module_id), StringifyJs(&runtime_module_id),
)?; )?;
Ok(Code::cell(code.build())) Ok(Code::cell(code.build()))
......
use anyhow::{Context, Result}; use anyhow::{Context, Result, bail};
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use smallvec::SmallVec; use smallvec::SmallVec;
use tracing::Instrument; use tracing::Instrument;
...@@ -6,7 +6,10 @@ use turbo_rcstr::RcStr; ...@@ -6,7 +6,10 @@ use turbo_rcstr::RcStr;
use turbo_tasks::{ReadRef, ResolvedVc, TryJoinIterExt, ValueToString, Vc}; use turbo_tasks::{ReadRef, ResolvedVc, TryJoinIterExt, ValueToString, Vc};
use turbo_tasks_hash::hash_xxh3_hash64; use turbo_tasks_hash::hash_xxh3_hash64;
use turbopack_core::{ use turbopack_core::{
chunk::{ChunkableModule, ChunkingType, module_id_strategies::GlobalModuleIdStrategy}, chunk::{
ChunkableModule, ChunkingType, ModuleId,
chunk_id_strategy::{ModuleIdFallback, ModuleIdStrategy},
},
ident::AssetIdent, ident::AssetIdent,
module::Module, module::Module,
module_graph::{ModuleGraph, RefData}, module_graph::{ModuleGraph, RefData},
...@@ -16,7 +19,7 @@ use turbopack_ecmascript::async_chunk::module::AsyncLoaderModule; ...@@ -16,7 +19,7 @@ use turbopack_ecmascript::async_chunk::module::AsyncLoaderModule;
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn get_global_module_id_strategy( pub async fn get_global_module_id_strategy(
module_graph: ResolvedVc<ModuleGraph>, module_graph: ResolvedVc<ModuleGraph>,
) -> Result<Vc<GlobalModuleIdStrategy>> { ) -> Result<Vc<ModuleIdStrategy>> {
let span = tracing::info_span!("compute module id map"); let span = tracing::info_span!("compute module id map");
async move { async move {
let module_graph = module_graph.await?; let module_graph = module_graph.await?;
...@@ -61,11 +64,20 @@ pub async fn get_global_module_id_strategy( ...@@ -61,11 +64,20 @@ pub async fn get_global_module_id_strategy(
finalize_module_ids(&mut module_id_map); finalize_module_ids(&mut module_id_map);
Ok(GlobalModuleIdStrategy { Ok(ModuleIdStrategy {
module_id_map: module_id_map module_id_map: Some(ResolvedVc::cell(
.into_iter() module_id_map
.map(|(ident, (_, hash))| (ident, hash)) .into_iter()
.collect(), .map(|(ident, (_, hash))| {
const JS_MAX_SAFE_INTEGER: u64 = (1u64 << 53) - 1;
if hash > JS_MAX_SAFE_INTEGER {
bail!("Numeric module id is too large: {}", hash);
}
Ok((ident, ModuleId::Number(hash)))
})
.collect::<Result<FxHashMap<_, _>>>()?,
)),
fallback: ModuleIdFallback::Error,
} }
.cell()) .cell())
} }
......
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