Skip to content

Commit

Permalink
feat: ✨ use optimized module graph in generate phase
Browse files Browse the repository at this point in the history
  • Loading branch information
stormslowly committed Dec 12, 2024
1 parent 3fe7af2 commit 48f7460
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion crates/mako/src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,17 @@ impl Compiler {

let async_dep_map = self.mark_async();

{
let m = self.context.module_graph.read().unwrap();
*self.context.optimized_module_graph.write().unwrap() = m.clone();
};

// Disable tree shaking in watch mode temporarily
// ref: https://github.com/umijs/mako/issues/396
if !self.context.args.watch {
match self.context.config._tree_shaking {
Some(TreeShakingStrategy::Basic) => {
let mut module_graph = self.context.module_graph.write().unwrap();
let mut module_graph = self.context.optimized_module_graph.write().unwrap();

crate::mako_profile_scope!("tree shake");
self.context
Expand Down
3 changes: 2 additions & 1 deletion crates/mako/src/generate/group_chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Compiler {

let mut visited = HashSet::new();
let mut edges = vec![];
let module_graph = self.context.module_graph.read().unwrap();
let module_graph = self.context.optimized_module_graph.read().unwrap();
let mut chunk_graph = self.context.chunk_graph.write().unwrap();
chunk_graph.clear();

Expand Down Expand Up @@ -282,6 +282,7 @@ impl Compiler {
self.hot_update_module_chunks(first_modified_module, &mut chunk_graph);

// collect added async chunks modules from module_graph
// FIXME: it should be optimized module graph
let module_graph = self.context.module_graph.read().unwrap();
let async_chunk_modules = update_result
.added
Expand Down

0 comments on commit 48f7460

Please sign in to comment.