Download next.js/turbopack/crates/turbopack-css/src/chunk/source_map.rs from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/turbopack/crates/turbopack-css/src/chunk/source_map.rs
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/turbopack/crates/turbopack-css/src/chunk/source_map.rs
-
curl -L -o source_map.rs https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/turbopack/crates/turbopack-css/src/chunk/source_map.rs
1.55 kB
| use anyhow::Result; | |
| use turbo_tasks::{ResolvedVc, Vc}; | |
| use turbo_tasks_fs::{File, FileSystemPath}; | |
| use turbopack_core::{ | |
| asset::{Asset, AssetContent}, | |
| chunk::ChunkingContext, | |
| output::OutputAsset, | |
| source_map::{GenerateSourceMap, SourceMap}, | |
| }; | |
| use super::CssChunk; | |
| /// Represents the source map of an css chunk. | |
| pub struct CssChunkSourceMapAsset { | |
| chunk: ResolvedVc<CssChunk>, | |
| } | |
| impl CssChunkSourceMapAsset { | |
| pub fn new(chunk: ResolvedVc<CssChunk>) -> Vc<Self> { | |
| CssChunkSourceMapAsset { chunk }.cell() | |
| } | |
| } | |
| impl OutputAsset for CssChunkSourceMapAsset { | |
| async fn path(self: Vc<Self>) -> Result<Vc<FileSystemPath>> { | |
| let this = self.await?; | |
| let ident = this.chunk.ident_for_path(); | |
| Ok(this | |
| .chunk | |
| .await? | |
| .chunking_context | |
| .chunk_path(Some(Vc::upcast(self)), ident, None, ".css".into()) | |
| .await? | |
| .append(".map")? | |
| .cell()) | |
| } | |
| } | |
| impl Asset for CssChunkSourceMapAsset { | |
| async fn content(&self) -> Result<Vc<AssetContent>> { | |
| if let Some(sm) = &*self.chunk.generate_source_map().await? { | |
| Ok(AssetContent::file(File::from(sm.clone()).into())) | |
| } else { | |
| Ok(AssetContent::file( | |
| File::from(SourceMap::empty_rope()).into(), | |
| )) | |
| } | |
| } | |
| } | |