Refactored module IDs optimization (#68846)
### What?
Refactored module ID strategies implementation to walk modules graph individually for each endpoint.
Based on feedback from [next.js#68408](https://github.com/vercel/next.js/pull/68408) and [turbo#8912](https://github.com/vercel/turbo/pull/8912).
Comments marked with `NOTE(LichuAcu)` are intended to make reviewing easier and will be removed before merging.