Buckets:
| use anyhow::Result; | |
| use indoc::formatdoc; | |
| use turbo_rcstr::rcstr; | |
| use turbo_tasks::{ResolvedVc, Vc}; | |
| use turbopack_core::{ | |
| chunk::{AsyncModuleInfo, ChunkableModule, ChunkingContext, ModuleChunkItemIdExt}, | |
| ident::AssetIdent, | |
| module::{Module, ModuleSideEffects}, | |
| module_graph::ModuleGraph, | |
| reference::{ModuleReference, ModuleReferences, SingleChunkableModuleReference}, | |
| resolve::ExportUsage, | |
| source::OptionSource, | |
| }; | |
| use turbopack_ecmascript::{ | |
| chunk::{ | |
| EcmascriptChunkItemContent, EcmascriptChunkPlaceable, EcmascriptExports, | |
| ecmascript_chunk_item, | |
| }, | |
| references::esm::EsmExports, | |
| runtime_functions::{TURBOPACK_EXPORT_NAMESPACE, TURBOPACK_IMPORT}, | |
| utils::StringifyJs, | |
| }; | |
| /// A [`NextDynamicEntryModule`] is a marker asset used to indicate which | |
| /// dynamic assets should appear in the dynamic manifest. | |
| pub struct NextDynamicEntryModule { | |
| module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>, | |
| } | |
| impl NextDynamicEntryModule { | |
| pub fn new(module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>) -> Vc<Self> { | |
| NextDynamicEntryModule { module }.cell() | |
| } | |
| } | |
| impl NextDynamicEntryModule { | |
| fn module_reference(&self) -> Vc<Box<dyn ModuleReference>> { | |
| Vc::upcast(SingleChunkableModuleReference::new( | |
| Vc::upcast(*self.module), | |
| rcstr!("next/dynamic reference"), | |
| ExportUsage::all(), | |
| )) | |
| } | |
| } | |
| impl Module for NextDynamicEntryModule { | |
| fn ident(&self) -> Vc<AssetIdent> { | |
| self.module | |
| .ident() | |
| .with_modifier(rcstr!("next/dynamic entry")) | |
| } | |
| fn source(&self) -> Vc<OptionSource> { | |
| Vc::cell(None) | |
| } | |
| async fn references(&self) -> Result<Vc<ModuleReferences>> { | |
| Ok(Vc::cell(vec![self.module_reference().to_resolved().await?])) | |
| } | |
| fn side_effects(self: Vc<Self>) -> Vc<ModuleSideEffects> { | |
| // This just exports another import | |
| ModuleSideEffects::ModuleEvaluationIsSideEffectFree.cell() | |
| } | |
| } | |
| impl ChunkableModule for NextDynamicEntryModule { | |
| fn as_chunk_item( | |
| self: ResolvedVc<Self>, | |
| module_graph: ResolvedVc<ModuleGraph>, | |
| chunking_context: ResolvedVc<Box<dyn ChunkingContext>>, | |
| ) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> { | |
| ecmascript_chunk_item(ResolvedVc::upcast(self), module_graph, chunking_context) | |
| } | |
| } | |
| impl EcmascriptChunkPlaceable for NextDynamicEntryModule { | |
| fn get_exports(&self) -> Vc<EcmascriptExports> { | |
| let module_reference = self.module_reference(); | |
| EsmExports::reexport_including_default(module_reference) | |
| } | |
| async fn chunk_item_content( | |
| &self, | |
| chunking_context: Vc<Box<dyn ChunkingContext>>, | |
| _module_graph: Vc<ModuleGraph>, | |
| _async_module_info: Option<Vc<AsyncModuleInfo>>, | |
| _estimated: bool, | |
| ) -> Result<Vc<EcmascriptChunkItemContent>> { | |
| let module_id = self.module.chunk_item_id(chunking_context).await?; | |
| Ok(EcmascriptChunkItemContent { | |
| inner_code: formatdoc!( | |
| r#" | |
| {TURBOPACK_EXPORT_NAMESPACE}({TURBOPACK_IMPORT}({})); | |
| "#, | |
| StringifyJs(&module_id), | |
| ) | |
| .into(), | |
| ..Default::default() | |
| } | |
| .cell()) | |
| } | |
| } | |
Xet Storage Details
- Size:
- 3.68 kB
- Xet hash:
- 221ce82ded456bb4fa48cca0690d34c880861ec5b1a8f55d730930d34cffeaf1
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.