Download next.js/turbopack/crates/turbopack-ecmascript/src/worker_chunk/module.rs from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 3.45 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/turbopack/crates/turbopack-ecmascript/src/worker_chunk/module.rs
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/turbopack/crates/turbopack-ecmascript/src/worker_chunk/module.rs
-
curl -L -o module.rs https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/turbopack/crates/turbopack-ecmascript/src/worker_chunk/module.rs
3.45 kB
| use anyhow::Result; | |
| use turbo_rcstr::{RcStr, rcstr}; | |
| use turbo_tasks::{ResolvedVc, ValueToString, Vc}; | |
| use turbopack_core::{ | |
| asset::{Asset, AssetContent}, | |
| chunk::{ | |
| ChunkGroupType, ChunkableModule, ChunkableModuleReference, ChunkingContext, ChunkingType, | |
| ChunkingTypeOption, | |
| }, | |
| ident::AssetIdent, | |
| module::Module, | |
| module_graph::ModuleGraph, | |
| reference::{ModuleReference, ModuleReferences}, | |
| resolve::ModuleResolveResult, | |
| }; | |
| use super::chunk_item::WorkerLoaderChunkItem; | |
| /// The WorkerLoaderModule is a module that creates a separate root chunk group for the given module | |
| /// and exports a URL to pass to the worker constructor. | |
| pub struct WorkerLoaderModule { | |
| pub inner: ResolvedVc<Box<dyn ChunkableModule>>, | |
| } | |
| impl WorkerLoaderModule { | |
| pub fn new(module: ResolvedVc<Box<dyn ChunkableModule>>) -> Vc<Self> { | |
| Self::cell(WorkerLoaderModule { inner: module }) | |
| } | |
| pub fn asset_ident_for(module: Vc<Box<dyn ChunkableModule>>) -> Vc<AssetIdent> { | |
| module.ident().with_modifier(rcstr!("worker loader")) | |
| } | |
| } | |
| impl Module for WorkerLoaderModule { | |
| fn ident(&self) -> Vc<AssetIdent> { | |
| Self::asset_ident_for(*self.inner) | |
| } | |
| async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> { | |
| Ok(Vc::cell(vec![ResolvedVc::upcast( | |
| WorkerModuleReference::new(*ResolvedVc::upcast(self.await?.inner)) | |
| .to_resolved() | |
| .await?, | |
| )])) | |
| } | |
| } | |
| impl Asset for WorkerLoaderModule { | |
| fn content(&self) -> Vc<AssetContent> { | |
| panic!("content() should not be called"); | |
| } | |
| } | |
| impl ChunkableModule for WorkerLoaderModule { | |
| fn as_chunk_item( | |
| self: ResolvedVc<Self>, | |
| module_graph: ResolvedVc<ModuleGraph>, | |
| chunking_context: ResolvedVc<Box<dyn ChunkingContext>>, | |
| ) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> { | |
| Vc::upcast( | |
| WorkerLoaderChunkItem { | |
| module: self, | |
| module_graph, | |
| chunking_context, | |
| } | |
| .cell(), | |
| ) | |
| } | |
| } | |
| struct WorkerModuleReference { | |
| module: ResolvedVc<Box<dyn Module>>, | |
| } | |
| impl WorkerModuleReference { | |
| pub fn new(module: ResolvedVc<Box<dyn Module>>) -> Vc<Self> { | |
| Self::cell(WorkerModuleReference { module }) | |
| } | |
| } | |
| impl ChunkableModuleReference for WorkerModuleReference { | |
| fn chunking_type(self: Vc<Self>) -> Vc<ChunkingTypeOption> { | |
| Vc::cell(Some(ChunkingType::Isolated { | |
| _ty: ChunkGroupType::Evaluated, | |
| merge_tag: None, | |
| })) | |
| } | |
| } | |
| impl ModuleReference for WorkerModuleReference { | |
| fn resolve_reference(&self) -> Vc<ModuleResolveResult> { | |
| *ModuleResolveResult::module(self.module) | |
| } | |
| } | |
| impl ValueToString for WorkerModuleReference { | |
| fn to_string(&self) -> Vc<RcStr> { | |
| Vc::cell(rcstr!("worker module")) | |
| } | |
| } | |