Repository: vercel/next.js
File: crates/next-api/src/project_asset_hashes_manifest.rs (Rust)

Code before:
        outputs
            .await?
            .into_iter()
            .map(|asset| ExpandOutputAssetsInput::Asset(*asset)),
        true,
    )
    .await?;

    Ok(Vc::cell(
        output_assets
            .into_iter()
            .map(async |asset| {
                if let Some(path) = root.get_path_to(&*asset.path().await?) {
                    Ok(Some((asset, RcStr::from(path))))
                } else {
                    Ok(None)
                }
            })
            .try_flat_join()
            .await?,
    ))
}

#[turbo_tasks::value_impl]
impl Asset for AssetHashesManifestAsset {
    #[turbo_tasks::function]
    async fn content(&self) -> Result<Vc<AssetContent>> {
        let entrypoint_groups = self.project.get_all_endpoint_groups(false).await?;

        let mut files = entrypoint_groups
            .iter()
            .map(|(_, EndpointGroup { primary, .. })| {
                if let &[entry] = &primary.as_slice() {
                    expand_outputs(endpoint_outputs(*entry.endpoint), self.asset_root.clone())
                } else {
                    let endpoints = Vc::cell(primary.iter().map(|entry| entry.endpoint).collect());
                    expand_outputs(endpoints_outputs(endpoints), self.asset_root.clone())
                }
            })
            .try_flat_join()
            .await?;
        // deduplicate shared assets across entrypoints
        files.sort_unstable_by(|(_, a), (_, b)| a.cmp(b));
        files.dedup_by(|(_, a), (_, b)| a == b);

        let asset_paths = files
            .into_iter()
            .map(async |(asset, path)| {
                Ok((
                    path,
                    asset

Review comment (suggestion):
Since it has many outputs, make it a root function

```suggestion
    #[turbo_tasks::function(root)]
```

Code after:
    root: FileSystemPath,
) -> Result<Vc<OutputAssetsWithPaths>> {
    let entrypoint_groups = project.get_all_endpoint_groups(false).await?;

    let output_assets = entrypoint_groups
        .iter()
        .map(|(_, EndpointGroup { primary, .. })| {
            if let &[entry] = &primary.as_slice() {
                endpoint_outputs(*entry.endpoint)
            } else {
                let endpoints = Vc::cell(primary.iter().map(|entry| entry.endpoint).collect());
                endpoints_outputs(endpoints)
            }
        })
        .collect::<Vec<_>>();

    let output_assets = expand_output_assets(
        output_assets
            .iter()
            .try_join()
            .await?
            .into_iter()
            .flatten()
            .map(|asset| ExpandOutputAssetsInput::Asset(*asset)),
        true,
    )
    .await?;

    let mut output_assets = output_assets
        .into_iter()
        .map(async |asset| {
            if let Some(path) = root.get_path_to(&*asset.path().await?) {
                Ok(Some((asset, RcStr::from(path))))
            } else {
                Ok(None)
            }
        })
        .try_flat_join()
        .await?;

    // Shared JS assets aren't duplicated here, but we have some duplicate OutputAssets with the
    // same path, e.g. a static image which exists twice, once with the server and then also with
    // the client chunking context.
    output_assets.sort_unstable_by(|(_, a), (_, b)| a.cmp(b));
    output_assets.dedup_by(|(_, a), (_, b)| a == b);

    Ok(Vc::cell(output_assets))
}

#[turbo_tasks::value_impl]
impl Asset for AssetHashesManifestAsset {