Skip to content

Commit

Permalink
Make follow_exports does not go into fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Oct 21, 2024
1 parent f819397 commit eec70a4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions turbopack/crates/turbopack-ecmascript/src/references/esm/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ use turbopack_core::{
issue::{analyze::AnalyzeIssue, IssueExt, IssueSeverity, StyledString},
module::Module,
reference::ModuleReference,
resolve::ModulePart,
};

use super::base::ReferencedAsset;
use crate::{
chunk::{EcmascriptChunkPlaceable, EcmascriptExports},
code_gen::{CodeGenerateable, CodeGeneration, CodeGenerationHoistedStmt},
magic_identifier,
tree_shake::asset::EcmascriptModulePartAsset,
};

#[derive(Clone, Hash, Debug, PartialEq, Eq, Serialize, Deserialize, TraceRawVcs)]
Expand Down Expand Up @@ -139,6 +141,23 @@ pub async fn follow_reexports(
let mut module = module;
let mut export_name = export_name;
loop {
// Do not go into `internal` fragments. Those modules are private to a single module.
if let Some(fragment) =
Vc::try_resolve_downcast_type::<EcmascriptModulePartAsset>(module).await?
{
let part = fragment.await?.part.await?;

if let ModulePart::Export(export) = *part {
if *export.await? == export_name {
return Ok(FollowExportsResult::cell(FollowExportsResult {
module,
export_name: Some(export_name),
ty: FoundExportType::Found,
}));
}
}
}

let exports = module.get_exports().await?;
let EcmascriptExports::EsmExports(exports) = &*exports else {
return Ok(FollowExportsResult::cell(FollowExportsResult {
Expand Down

0 comments on commit eec70a4

Please # to comment.