[backport] [turbopack] Raise registration calls in hoisted modules to the top (#97308)
Backports #96697 ("[turbopack] Raise registration calls in hoisted
modules to the top") to `next-16-3`.
Fixes #96648: when a scope-hoisting group enters a second group that
depends back on the first, the
re-entry happened before the first group's module registrations had run.
Non-scope-hoisted modules
with cycles already raise the registration call to the top of the
factory; this restores that for
scope-hoisted modules.
Cherry-picked from 40680b95 with no
conflicts. All 16 files are
byte-identical to canary.
### Verification on this branch
- `cargo check`, `cargo clippy --all-targets`, `cargo fmt --check` on
`turbopack-ecmascript` — clean
- `cargo test -p turbopack-tests --test execution` — 255 passed, 0
failed, including the new
`scope_hoisting__reentrant_group` fixture
- `cargo test -p turbopack-tests --test snapshot` — 113 passed, 0
failed; the working tree stays
clean afterwards, so the 5 updated snapshots match the generated output
exactly
- `pnpm build-all` — 18/18 tasks
- `test/e2e/app-dir/app/index.test.ts` (Turbopack, production) — 116
passed, 5 skipped
The snapshot updates are the intended effect of the change:
`__turbopack_context__.s([...])` now
precedes the merged-module bodies instead of following them.
<!-- NEXT_JS_LLM -->
Co-authored-by:
Sam Poder <sampoder@berkeley.edu>
Showing
Please
register
or
sign in
to comment