Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Feb 28, 2025
1 parent 6c9b63f commit ba088e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{borrow::Cow, collections::BTreeMap, ops::ControlFlow};

use anyhow::Result;
use anyhow::{Context, Result};
use rustc_hash::FxHashSet;
use serde::{Deserialize, Serialize};
use swc_core::{
Expand Down
10 changes: 10 additions & 0 deletions turbopack/crates/turbopack/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ use turbopack_core::{
pub use turbopack_css as css;
pub use turbopack_ecmascript as ecmascript;
use turbopack_ecmascript::{
parse::ParseResult,
references::external_module::{CachedExternalModule, CachedExternalType},
tree_shake::asset::EcmascriptModulePartAsset,
};
Expand Down Expand Up @@ -157,6 +158,7 @@ async fn apply_module_type(
}
}

let parsed = module.parse();
let options = options.await?;
match options.tree_shaking_mode {
Some(TreeShakingMode::ModuleFragments) => {
Expand All @@ -172,6 +174,7 @@ async fn apply_module_type(
if *module.get_exports().needs_facade().await? {
Vc::upcast(EcmascriptModuleFacadeModule::new(
Vc::upcast(module),
parsed,
part,
))
} else {
Expand All @@ -189,17 +192,20 @@ async fn apply_module_type(
Vc::upcast(
EcmascriptModuleFacadeModule::new(
Vc::upcast(module),
parsed,
ModulePart::exports(),
)
.resolve()
.await?,
),
parsed,
part,
side_effect_free_packages,
)
} else {
apply_reexport_tree_shaking(
Vc::upcast(module.resolve().await?),
parsed,
part,
side_effect_free_packages,
)
Expand All @@ -214,6 +220,7 @@ async fn apply_module_type(
} else if *module.get_exports().needs_facade().await? {
Vc::upcast(EcmascriptModuleFacadeModule::new(
Vc::upcast(module),
parsed,
ModulePart::facade(),
))
} else {
Expand Down Expand Up @@ -276,6 +283,7 @@ async fn apply_module_type(
#[turbo_tasks::function]
async fn apply_reexport_tree_shaking(
module: Vc<Box<dyn EcmascriptChunkPlaceable>>,
parsed: Vc<ParseResult>,
part: ModulePart,
side_effect_free_packages: Vc<Glob>,
) -> Result<Vc<Box<dyn Module>>> {
Expand All @@ -291,12 +299,14 @@ async fn apply_reexport_tree_shaking(
} else {
Vc::upcast(EcmascriptModuleFacadeModule::new(
**final_module,
parsed,
ModulePart::renamed_export(new_export.clone(), export.clone()),
))
}
} else {
Vc::upcast(EcmascriptModuleFacadeModule::new(
**final_module,
parsed,
ModulePart::renamed_namespace(export.clone()),
))
};
Expand Down

0 comments on commit ba088e4

Please sign in to comment.