Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Nov 21, 2024
1 parent aaad2a1 commit d62d560
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions turbopack/crates/turbopack-ecmascript/src/tree_shake/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,34 @@ impl EcmascriptModulePartAsset {
/// of a pointer to the full module and the [ModulePart] pointing the part
/// of the module.
#[turbo_tasks::function]
pub fn new(
pub async fn new(
module: ResolvedVc<EcmascriptModuleAsset>,
part: ResolvedVc<ModulePart>,
) -> Vc<Self> {
EcmascriptModulePartAsset {
) -> Result<Vc<Self>> {
if matches!(
&*part.await?,
ModulePart::Internal(..)
| ModulePart::InternalEvaluation(..)
| ModulePart::Facade
| ModulePart::Exports
| ModulePart::Evaluation
) {
return Ok(EcmascriptModulePartAsset {
full_module: module,
part,
}
.cell());
}

// This is a workaround to avoid creating duplicate assets for internal parts.
let split_result = split_module(*module).await?;
let part_id = get_part_id(&split_result, *part).await?;

Ok(EcmascriptModulePartAsset {
full_module: module,
part,
part: ModulePart::internal(part_id).to_resolved().await?,
}
.cell()
.cell())
}

#[turbo_tasks::function]
Expand Down

0 comments on commit d62d560

Please sign in to comment.