Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Sep 20, 2024
1 parent 8387f33 commit c9ea259
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
4 changes: 2 additions & 2 deletions turbopack/crates/turbopack-core/src/resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2924,7 +2924,7 @@ impl ModulePart {
ModulePart::Exports.cell()
}
#[turbo_tasks::function]
pub fn reexports() -> Vc<Self> {
pub fn star_reexports() -> Vc<Self> {
ModulePart::StarReexports.cell()
}
#[turbo_tasks::function]
Expand Down Expand Up @@ -2954,7 +2954,7 @@ impl ValueToString for ModulePart {
ModulePart::Internal(id) => format!("internal part {}", id).into(),
ModulePart::Locals => "locals".into(),
ModulePart::Exports => "exports".into(),
ModulePart::StarReexports => "reexports".into(),
ModulePart::StarReexports => "star reexports".into(),
ModulePart::Facade => "facade".into(),
}))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,24 @@ struct AllExportNamesResult {
async fn get_all_export_names(
module: Vc<Box<dyn EcmascriptChunkPlaceable>>,
) -> Result<Vc<AllExportNamesResult>> {
dbg!(1);
let exports = module.get_exports().await?;
dbg!(2);
let EcmascriptExports::EsmExports(exports) = &*exports else {
dbg!(3);
return Ok(AllExportNamesResult {
esm_exports: IndexMap::new(),
dynamic_exporting_modules: vec![module],
}
.cell());
};

dbg!(4);
let exports = exports.await?;
dbg!(5);
let mut esm_exports = IndexMap::new();
let mut dynamic_exporting_modules = Vec::new();
esm_exports.extend(exports.exports.keys().cloned().map(|n| (n, module)));
dbg!(6);
let star_export_names = exports
.star_exports
.iter()
Expand All @@ -301,8 +306,10 @@ async fn get_all_export_names(
})
.try_flat_join()
.await?;
dbg!(7);
for star_export_names in star_export_names {
let star_export_names = star_export_names.await?;
dbg!(8);
esm_exports.extend(
star_export_names
.esm_exports
Expand All @@ -312,7 +319,7 @@ async fn get_all_export_names(
dynamic_exporting_modules
.extend(star_export_names.dynamic_exporting_modules.iter().copied());
}

dbg!(9);
Ok(AllExportNamesResult {
esm_exports,
dynamic_exporting_modules,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,24 @@ impl Module for EcmascriptModuleFacadeModule {
)));
references.push(Vc::upcast(EcmascriptModulePartReference::new_part(
self.module,
ModulePart::reexports(),
ModulePart::star_reexports(),
)));
references
}
ModulePart::StarReexports { .. } => {
vec![]
let Some(module) =
Vc::try_resolve_sidecast::<Box<dyn EcmascriptAnalyzable>>(self.module).await?
else {
bail!(
"Expected EcmascriptModuleAsset for a EcmascriptModuleFacadeModule with \
ModulePart::Evaluation"
);
};

let result = module.analyze().await?;
let references = result.reexport_references;

references

Check failure on line 126 in turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs

View workflow job for this annotation

GitHub Actions / stable - x86_64-unknown-linux-gnu - node@16

`match` arms have incompatible types
}
ModulePart::Facade => {
vec![
Expand Down Expand Up @@ -157,7 +169,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule {
let mut star_exports = Vec::new();

match &*self.ty.await? {
ModulePart::Exports | ModulePart::StarReexports => {
ModulePart::Exports => {
let EcmascriptExports::EsmExports(esm_exports) = *self.module.get_exports().await?
else {
bail!(
Expand Down Expand Up @@ -201,6 +213,17 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule {
}
star_exports.extend(esm_exports.star_exports.iter().copied());
}
ModulePart::StarReexports => {
let EcmascriptExports::EsmExports(esm_exports) = *self.module.get_exports().await?
else {
bail!(
"EcmascriptModuleFacadeModule must only be used on modules with EsmExports"
);
};
let esm_exports = esm_exports.await?;

star_exports.extend(esm_exports.star_exports.iter().copied());
}
ModulePart::Facade => {
// Reexport everything from the reexports module
// (including default export if any)
Expand Down
4 changes: 2 additions & 2 deletions turbopack/crates/turbopack-ecmascript/src/tree_shake/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl Module for EcmascriptModulePartAsset {
let reference = Vc::upcast(SingleModuleReference::new(
Vc::upcast(EcmascriptModulePartAsset::new(
self.full_module,
ModulePart::reexports(),
ModulePart::star_reexports(),
)),
Vc::cell("reexport".into()),
));
Expand Down Expand Up @@ -238,7 +238,7 @@ impl Module for EcmascriptModulePartAsset {
match part_id {
PartId::Internal(part_id) => ModulePart::internal(*part_id),
PartId::Export(name) => ModulePart::export(name.clone()),
PartId::StarReexports => ModulePart::reexports(),
PartId::StarReexports => ModulePart::star_reexports(),
_ => unreachable!(
"PartId other than Internal and Export should not be used here"
),
Expand Down

0 comments on commit c9ea259

Please sign in to comment.