Skip to content

Commit 7cfd4c7

Browse files
committed
Pass is_async to registerClientReference
1 parent 39368ce commit 7cfd4c7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

crates/next-core/src/next_client_reference/ecmascript_client_reference/ecmascript_client_reference_proxy_module.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ impl EcmascriptClientReferenceProxyModule {
6767

6868
let server_module_path = &*self.server_module_ident.path().to_string().await?;
6969

70+
let is_async = self.client_module.get_async_module().await?.is_some();
71+
let async_op = if is_async { "async" } else { "" };
72+
7073
// Adapted from https://github.com/facebook/react/blob/c5b9375767e2c4102d7e5559d383523736f1c902/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js#L323-L354
7174
if let EcmascriptExports::EsmExports(exports) = &*self.client_module.get_exports().await? {
7275
let exports = exports.expand_exports().await?;
@@ -91,6 +94,7 @@ impl EcmascriptClientReferenceProxyModule {
9194
function() {{ throw new Error({call_err}); }},
9295
{server_module_path},
9396
"default",
97+
{is_async},
9498
);
9599
"#,
96100
call_err = StringifyJs(&format!(
@@ -100,6 +104,7 @@ impl EcmascriptClientReferenceProxyModule {
100104
Component or passed to props of a Client Component."
101105
)),
102106
server_module_path = StringifyJs(server_module_path),
107+
is_async = is_async,
103108
)?;
104109
} else {
105110
writedoc!(
@@ -109,6 +114,7 @@ impl EcmascriptClientReferenceProxyModule {
109114
function() {{ throw new Error({call_err}); }},
110115
{server_module_path},
111116
{export_name_str},
117+
{is_async},
112118
);
113119
"#,
114120
export_name = export_name,
@@ -120,6 +126,7 @@ impl EcmascriptClientReferenceProxyModule {
120126
)),
121127
server_module_path = StringifyJs(server_module_path),
122128
export_name_str = StringifyJs(export_name),
129+
is_async = is_async,
123130
)?;
124131
}
125132
}
@@ -129,9 +136,10 @@ impl EcmascriptClientReferenceProxyModule {
129136
r#"
130137
const {{ createClientModuleProxy }} = require("react-server-dom-turbopack/server.edge");
131138
132-
__turbopack_export_namespace__(createClientModuleProxy({server_module_path}));
139+
__turbopack_export_namespace__({async_op} createClientModuleProxy({server_module_path}));
133140
"#,
134-
server_module_path = StringifyJs(server_module_path)
141+
async_op = async_op,
142+
server_module_path = StringifyJs(server_module_path),
135143
)?;
136144
};
137145

0 commit comments

Comments
 (0)