Skip to content

Commit 3ecaf4b

Browse files
committed
fixup
1 parent 9aca4f7 commit 3ecaf4b

File tree

1 file changed

+19
-17
lines changed
  • turbopack/crates/turbopack-css/src/chunk

1 file changed

+19
-17
lines changed

turbopack/crates/turbopack-css/src/chunk/mod.rs

+19-17
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub mod source_map;
44
use std::fmt::Write;
55

66
use anyhow::{bail, Result};
7+
use swc_core::common::pass::Either;
78
use turbo_rcstr::RcStr;
89
use turbo_tasks::{
910
FxIndexSet, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Value, ValueDefault, ValueToString,
@@ -314,27 +315,28 @@ impl OutputAsset for CssChunk {
314315
let this = self.await?;
315316
let content = this.content.await?;
316317
let mut references = content.referenced_output_assets.owned().await?;
317-
if content.chunk_items.len() > 1 {
318-
references.extend(
319-
content
320-
.chunk_items
321-
.iter()
322-
.map(|item| async {
323-
Ok(item
324-
.references()
325-
.await?
326-
.into_iter()
327-
.copied()
328-
.chain(std::iter::once(ResolvedVc::upcast(
318+
let single_item_chunks = content.chunk_items.len() > 1;
319+
references.extend(
320+
content
321+
.chunk_items
322+
.iter()
323+
.map(|item| async {
324+
let references = item.references().await?.into_iter().copied();
325+
Ok(if single_item_chunks {
326+
Either::Left(
327+
references.chain(std::iter::once(ResolvedVc::upcast(
329328
SingleItemCssChunk::new(*this.chunking_context, **item)
330329
.to_resolved()
331330
.await?,
332-
))))
331+
))),
332+
)
333+
} else {
334+
Either::Right(references)
333335
})
334-
.try_flat_join()
335-
.await?,
336-
);
337-
}
336+
})
337+
.try_flat_join()
338+
.await?,
339+
);
338340
if *this
339341
.chunking_context
340342
.reference_chunk_source_maps(Vc::upcast(self))

0 commit comments

Comments
 (0)