Skip to content

Commit

Permalink
Turbopack: use try_join instead of future::try_join_all (#73261)
Browse files Browse the repository at this point in the history
These were the only 2 occurrences in the codebase.

Might be a candidate for an ast-grep lint rule
  • Loading branch information
mischnic authored and wyattjoh committed Nov 28, 2024
1 parent 8a31b4e commit 0fb5dac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
22 changes: 12 additions & 10 deletions turbopack/crates/turbopack-core/src/chunk/chunk_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::collections::HashSet;

use anyhow::Result;
use auto_hash_map::AutoSet;
use futures::future::try_join_all;
use turbo_tasks::{
FxIndexMap, FxIndexSet, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Value, Vc,
};
Expand Down Expand Up @@ -152,15 +151,18 @@ pub async fn make_chunk_group(
.await?
.clone_value();

let rebased_modules = try_join_all(traced_modules.into_iter().map(|module| {
RebasedAsset::new(
*module,
module.ident().path().root(),
module.ident().path().root(),
)
.to_resolved()
}))
.await?;
let rebased_modules = traced_modules
.into_iter()
.map(|module| {
RebasedAsset::new(
*module,
module.ident().path().root(),
module.ident().path().root(),
)
.to_resolved()
})
.try_join()
.await?;

referenced_output_assets.extend(rebased_modules.into_iter().map(ResolvedVc::upcast));

Expand Down
14 changes: 6 additions & 8 deletions turbopack/crates/turbopack-node/src/transforms/webpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::mem::take;
use anyhow::{bail, Context, Result};
use async_trait::async_trait;
use either::Either;
use futures::future::try_join_all;
use serde::{Deserialize, Serialize};
use serde_json::{json, Value as JsonValue};
use serde_with::serde_as;
Expand Down Expand Up @@ -279,13 +278,12 @@ impl WebpackLoadersProcessedAsset {
Either::Left(str) => File::from(str),
Either::Right(bytes) => File::from(bytes.binary),
};
let assets = try_join_all(
emitted_assets_to_virtual_sources(processed.assets)
.await?
.into_iter()
.map(|v| v.to_resolved()),
)
.await?;
let assets = emitted_assets_to_virtual_sources(processed.assets)
.await?
.into_iter()
.map(|v| v.to_resolved())
.try_join()
.await?;

let content =
AssetContent::File(FileContent::Content(file).resolved_cell()).resolved_cell();
Expand Down

0 comments on commit 0fb5dac

Please sign in to comment.