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: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

`2024-09-05`

* perf: group chunks with post order dfs by [@xusd320](https://github.com/xusd320) in [#1554](https://github.com/umijs/mako/pull/1554)
* perf: group chunks with right first dfs by [@xusd320](https://github.com/xusd320) in [#1554](https://github.com/umijs/mako/pull/1554)
Copy link
Contributor

Choose a reason for hiding this comment

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

changelog 为啥要改?right first 不是之前的实现吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

之前的实现就是 right first, pr 时候描述错了,post order dfs 不是这样的

* refactor: unify base64 utils by [@xusd320](https://github.com/xusd320) in [#1557](https://github.com/umijs/mako/pull/1557)
* Revert "refactor: Unify the static server in bundler-mako and devServer" by [@stormslowly](https://github.com/stormslowly) in [#1556](https://github.com/umijs/mako/pull/1556)
* fix: define env by [@xusd320](https://github.com/xusd320) in [#1551](https://github.com/umijs/mako/pull/1551)
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

`2024-09-05`

* 优化 group chunks 的性能,基于 post order dfs by [@xusd320](https://github.com/xusd320) in [#1554](https://github.com/umijs/mako/pull/1554)
* 优化 group chunks 的性能,基于 right first dfs by [@xusd320](https://github.com/xusd320) in [#1554](https://github.com/umijs/mako/pull/1554)
* 重构 base64 utils by [@xusd320](https://github.com/xusd320) in [#1557](https://github.com/umijs/mako/pull/1557)
* 回滚 "refactor: Unify the static server in bundler-mako and devServer" by [@stormslowly](https://github.com/stormslowly) in [#1556](https://github.com/umijs/mako/pull/1556)
* 修复 define env by [@xusd320](https://github.com/xusd320) in [#1551](https://github.com/umijs/mako/pull/1551)
Expand Down
16 changes: 8 additions & 8 deletions crates/mako/src/generate/group_chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ impl Compiler {
}

/*
* Visit dependencies by post order DFS. The reason for this is that
* Visit dependencies by right first DFS. The reason for this is that
* the rightmost and deepest css dependence should have the highest priority.
* For example, the dependencies graph is:
*
Expand All @@ -499,19 +499,19 @@ impl Compiler {
* the final dependencies orders in chunk should be:
*
* ----------
* a.css
* c.css
* b.css
* index.css
* b.css
* c.css
* a.css
* ----------
* note that c.css, b.css, c.css before a.css will be deduplicated.
* note that c.css, b.css, c.css after a.css will be deduplicated.
*/
fn visit_modules<F, T>(mut queue: Vec<T>, visited: Option<HashSet<T>>, mut callback: F) -> Vec<T>
where
F: FnMut(&T) -> Vec<T>,
T: Hash + Eq + Clone,
{
let mut post_order_dfs_ret: Vec<T> = Vec::new();
let mut right_firtst_dfs_ret: Vec<T> = Vec::new();

let mut visited = visited.unwrap_or_default();

Expand All @@ -520,12 +520,12 @@ where
continue;
}

post_order_dfs_ret.push(id.clone());
right_firtst_dfs_ret.push(id.clone());

visited.insert(id.clone());

queue.extend(callback(&id));
}

post_order_dfs_ret
right_firtst_dfs_ret
}