Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add evaluatables to chunk list ident #5785

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/turbopack-dev/src/chunking_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,14 @@ impl DevChunkingContext {
fn generate_chunk_list_register_chunk(
self: Vc<Self>,
entry_chunk: Vc<Box<dyn Chunk>>,
evaluatable_assets: Vc<EvaluatableAssets>,
other_chunks: Vc<OutputAssets>,
source: Value<EcmascriptDevChunkListSource>,
) -> Vc<Box<dyn OutputAsset>> {
Vc::upcast(EcmascriptDevChunkList::new(
self,
entry_chunk,
evaluatable_assets,
other_chunks,
source,
))
Expand Down Expand Up @@ -324,6 +326,7 @@ impl ChunkingContext for DevChunkingContext {

assets.push(self.generate_chunk_list_register_chunk(
entry_chunk,
EvaluatableAssets::empty(),
Vc::cell(assets.clone()),
Value::new(EcmascriptDevChunkListSource::Dynamic),
));
Expand Down Expand Up @@ -370,6 +373,7 @@ impl ChunkingContext for DevChunkingContext {

assets.push(self.generate_chunk_list_register_chunk(
entry_chunk,
evaluatable_assets,
other_assets,
Value::new(EcmascriptDevChunkListSource::Entry),
));
Expand Down
9 changes: 8 additions & 1 deletion crates/turbopack-dev/src/ecmascript/list/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use serde::Serialize;
use turbo_tasks::{Value, ValueToString, Vc};
use turbopack_core::{
asset::{Asset, AssetContent},
chunk::{Chunk, ChunkingContext},
chunk::{Chunk, ChunkingContext, EvaluatableAssets},
ident::AssetIdent,
module::Module,
output::{OutputAsset, OutputAssets},
version::VersionedContent,
};
Expand All @@ -27,6 +28,7 @@ use crate::DevChunkingContext;
pub(crate) struct EcmascriptDevChunkList {
pub(super) chunking_context: Vc<DevChunkingContext>,
pub(super) entry_chunk: Vc<Box<dyn Chunk>>,
pub(super) evaluatable_assets: Vc<EvaluatableAssets>,
pub(super) chunks: Vc<OutputAssets>,
pub(super) source: EcmascriptDevChunkListSource,
}
Expand All @@ -38,12 +40,14 @@ impl EcmascriptDevChunkList {
pub fn new(
chunking_context: Vc<DevChunkingContext>,
entry_chunk: Vc<Box<dyn Chunk>>,
evaluatable_assets: Vc<EvaluatableAssets>,
chunks: Vc<OutputAssets>,
source: Value<EcmascriptDevChunkListSource>,
) -> Vc<Self> {
EcmascriptDevChunkList {
chunking_context,
entry_chunk,
evaluatable_assets,
chunks,
source: source.into_value(),
}
Expand Down Expand Up @@ -79,6 +83,9 @@ impl OutputAsset for EcmascriptDevChunkList {
#[turbo_tasks::function]
async fn ident(&self) -> Result<Vc<AssetIdent>> {
let mut ident = self.entry_chunk.ident().await?.clone_value();
for evaluatable_asset in self.evaluatable_assets.await?.iter() {
ident.add_asset(Vc::<String>::empty(), evaluatable_asset.ident());
}

ident.add_modifier(modifier());

Expand Down
Loading