From 01cad9eacac1e1559b06076239793304845b415c Mon Sep 17 00:00:00 2001 From: Janka Uryga Date: Fri, 19 Sep 2025 21:12:37 +0200 Subject: [PATCH] [Flight] Support Async Modules in Turbopack Server References (#34531) Seems like this was missed in https://github.com/facebook/react/pull/31313 --- .../ReactFlightClientConfigBundlerTurbopack.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopack.js b/packages/react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopack.js index ba1c220fa4..f061fa9816 100644 --- a/packages/react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopack.js +++ b/packages/react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopack.js @@ -132,7 +132,19 @@ export function resolveServerReference( ); } } - // TODO: This needs to return async: true if it's an async module. + if (resolvedModuleData.async) { + // If the module is marked as async in a Client Reference, we don't actually care. + // What matters is whether the consumer wants to unwrap it or not. + // For Server References, it is different because the consumer is completely internal + // to the bundler. So instead of passing it to each reference we can mark it in the + // manifest. + return [ + resolvedModuleData.id, + resolvedModuleData.chunks, + name, + 1 /* async */, + ]; + } return [resolvedModuleData.id, resolvedModuleData.chunks, name]; }