next.js
a56aca75 - feat(turbopack): Merge single-pointer nodes in reverse direction (#72571)

Commit
1 year ago
feat(turbopack): Merge single-pointer nodes in reverse direction (#72571) ### What? Merge a dependency into the chunk if the current node is the only dependant of the dependency. i.e. Optimize for cases where only one **dependant** exists for a specific node. ### Why? If a node has a single incoming node (let's call it `source`), it means that it will always be included if the source node is included and not if the source node is not included. So the source and node act as a group, and this PR makes them a real group to reduce number of module fragments. Before: <img width="1039" alt="image" src="https://github.com/user-attachments/assets/24321064-fe34-45c6-bf02-81e482816741"> After: <img width="1039" alt="image" src="https://github.com/user-attachments/assets/4709a1f9-097c-4771-b554-043c01c980db"> ### benches/heavy-npm-deps - 14862 modules => 9263 modules - With tree shaking on canary: `144.13s user 14.13s system 910% cpu 17.373 total` - With tree shaking and this PR: `124.60s user 12.41s system 878% cpu 15.601 total` - Without tree shaking: `47.41s user 4.75s system 553% cpu 9.416 total` ### How? Closes PACK-3441
Author
Parents
Loading