mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Extracted from https://github.com/vercel/next.js/pull/95468, tries to address @lubieowoce feedback. This should be a pure refactor with no publicly observable behavior changes. We want to simplify the state of how we're loading and tracking modules, and simplify signatures: - Extract a state machine into `LazyModule` that hides per-module state. You can kick it (`loadIfNeeded`), wait for completion with `waitUntilLoaded`, or peek-or-throw with `assertLoaded`. - Reading `.userland` while pending now throws with an invariant so we don't do it accidentally again. Should be unreachable from current callsites. - Remove the non-thunk overload from `userland` factory. Added tests to cover the cases that the refactor had a risk of breaking.