Skip to content

Commit

Permalink
Turbopack: ensure output assets reference only output assets (#52832)
Browse files Browse the repository at this point in the history
### What?

refactoring see vercel/turborepo#5557

### Turbopack Changes

* vercel/turborepo#5506 <!-- Leah -
feat(turbopack-ecmascript): implement acyclic SCC graph for ESM imports
-->
* vercel/turborepo#5557 <!-- Tobias Koppers - Ensure
output assets reference only output assets -->
  • Loading branch information
sokra authored Jul 18, 2023
1 parent 87763d7 commit 0aeda3a
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 116 deletions.
70 changes: 35 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ swc_core = { version = "0.79.13" }
testing = { version = "0.33.20" }

# Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230718.2" }
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230718.3" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230718.2" }
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230718.3" }
# [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230718.2" }
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230718.3" }

# General Deps

Expand Down
29 changes: 7 additions & 22 deletions packages/next-swc/crates/next-build/src/next_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ use turbopack_binding::{
environment::ServerAddr,
issue::{IssueContextExt, IssueReporter, IssueSeverity},
output::{OutputAsset, OutputAssets},
reference::AssetReference,
virtual_fs::VirtualFileSystem,
},
dev::DevChunkingContext,
Expand Down Expand Up @@ -560,27 +559,13 @@ async fn all_assets_from_entries(entries: Vc<OutputAssets>) -> Result<Vc<OutputA
async fn get_referenced_assets(
asset: Vc<Box<dyn OutputAsset>>,
) -> Result<impl Iterator<Item = Vc<Box<dyn OutputAsset>>> + Send> {
Ok(
asset
.references()
.await?
.iter()
.map(|reference| async move {
let primary_assets = reference.resolve_reference().primary_assets().await?;
Ok(primary_assets.clone_value())
})
.try_join()
.await?
.into_iter()
.flatten()
.map(|asset| async move {
Ok(Vc::try_resolve_downcast::<Box<dyn OutputAsset>>(asset).await?)
})
.try_join()
.await?
.into_iter()
.flatten(),
)
Ok(asset
.references()
.await?
.iter()
.copied()
.collect::<Vec<_>>()
.into_iter())
}

/// Writes a manifest to disk. This consumes the manifest to ensure we don't
Expand Down
4 changes: 2 additions & 2 deletions packages/next-swc/crates/next-core/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"check": "tsc --noEmit"
},
"dependencies": {
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230718.2",
"@vercel/turbopack-node": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230718.2",
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230718.3",
"@vercel/turbopack-node": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230718.3",
"anser": "^2.1.1",
"css.escape": "^1.5.1",
"next": "*",
Expand Down
Loading

0 comments on commit 0aeda3a

Please sign in to comment.