next.js
d5276f04 - Make TurbopackResult payloads disjoint (#98575)

Commit
2 days ago
Make TurbopackResult payloads disjoint (#98575) ### What? Refactors the JavaScript-facing `TurbopackResult<T>` into a stable wrapper whose payload lives under `value` and whose issues remain top-level. Native API consumers, entrypoint conversion, development-server paths, HMR handling, and direct API tests now follow the disjoint shape. Two event subscriptions that had inaccurate wrapper declarations now expose their existing plain runtime payloads explicitly: update-info events remain `UpdateMessage`, and compilation events remain `CompilationEvent`. Nullable native entrypoint payloads are also declared accurately and normalized at the JavaScript API boundary. ### Why? The previous intersection-based representation merged payload fields with result metadata. That allowed fields such as `issues` to overwrite one another and caused non-object payloads to be discarded, making the result shape depend on `T`. A dedicated payload property avoids those collisions and preserves every payload type, including `null`. Keeping plain event streams distinct from result wrappers also ensures `TurbopackResult<T>` consistently means the native API actually provides wrapper metadata. ### How? The N-API serializer now always creates a fresh wrapper rather than mutating an object payload. The shared TypeScript type models that wrapper directly and requires an explicit payload type. Conversion layers replace only the nested payload while explicitly preserving wrapper issues. Call sites continue to process wrapper issues while reading domain data through `value`. The update-info and compilation-event declarations were aligned with their native callback types instead of introducing new runtime wrappers for streams that do not collect issues. Rust `Option<NapiEntrypoints>` payloads are declared as nullable, then normalized to the existing empty-entrypoints representation after a null-safe route check. ### Verification - `pnpm build-all` - `pnpm --filter=next types` - `pnpm swc-build-native` - `cargo check -p next-napi-bindings` - `cargo fmt --all -- --check` - ESLint and Prettier on changed files - `pnpm test-dev-experimental-turbo test/development/app-aspath/app-aspath.test.ts` - `pnpm test-dev-turbo test/development/basic/next-rs-api.test.ts` — 26 passed, 1 skipped, 15 snapshots; Jest reported lingering open handles after the green summary - `pnpm test-dev-turbo test/development/app-dir/concurrent-install/concurrent-install.test.ts` - `pnpm test-dev-experimental-turbo test/development/app-dir/concurrent-install/concurrent-install.test.ts` <!-- NEXT_JS_LLM --> <!-- fleet 74688340-f99a-462e-8f75-88d12c88000a --> --------- Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by: Will Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
Author
Parents
Loading