Skip to content

Commit

Permalink
fix: skip module should skip async module (#1662)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinbao1001 authored Nov 7, 2024
1 parent 7434fe5 commit 6ddd711
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions crates/mako/src/plugins/tree_shaking/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ pub struct TreeShakeModule {
used_exports: UsedExports,
pub module_system: ModuleSystem,
pub all_exports: AllExports,
pub is_async: bool,
pub topo_order: usize,
pub updated_ast: Option<SwcModule>,
pub side_effect_dep_sources: HashSet<String>,
Expand Down Expand Up @@ -323,6 +324,7 @@ impl TreeShakeModule {
described_side_effects: module.info.as_ref().unwrap().described_side_effect(),
side_effects: module_system != ModuleSystem::ESModule,
side_effect_dep_sources: Default::default(),
is_async: module.info.as_ref().unwrap().is_async,
all_exports: match module_system {
ModuleSystem::ESModule => AllExports::Precise(Default::default()),
ModuleSystem::Custom | ModuleSystem::CommonJS => {
Expand Down
6 changes: 4 additions & 2 deletions crates/mako/src/plugins/tree_shaking/shake/skip_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,14 +491,16 @@ pub(super) fn skip_module_optimize(

for (module_id, replaces) in re_export_replace_map.iter() {
if module_graph.has_module(module_id) {
let mut tsm = tree_shake_modules_map.get(module_id).unwrap().borrow_mut();
if tsm.is_async {
continue;
}
// stmt_id is reversed order
for to_replace in replaces.iter() {
// println!("{} apply with {:?}", module_id.id, to_replace.1);
apply_replace(to_replace, module_id, module_graph, context);
}

let mut tsm = tree_shake_modules_map.get(module_id).unwrap().borrow_mut();

let swc_module = module_graph
.get_module(module_id)
.unwrap()
Expand Down

0 comments on commit 6ddd711

Please sign in to comment.