Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

覆盖率掉了。

}
// 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