Turbopack: next/dynamic layout segment optimization (#70708)
Closes PACK-3274
This deduplicates work by only searching for `next/dynamic` once per
layout segment.
- `collect_next_dynamic_imports` is a turbotask now, executed once per
layout segment
- `collect_next_dynamic_imports` also takes a list of visited modules,
to prevent revisiting
Before
<img width="1722" alt="Bildschirmfoto 2024-10-01 um 15 28 34"
src="https://github.com/user-attachments/assets/0db86796-289e-4d8a-95b9-4164bcaabc71">
After
<img width="1728" alt="Bildschirmfoto 2024-10-02 um 15 17 10"
src="https://github.com/user-attachments/assets/bfb99b03-26d8-4c0f-b97e-f9e437f7fc4c">