File tree 1 file changed +20
-1
lines changed
packages/react-server-dom-webpack/src/client
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,13 @@ export function resolveClientReference<T>(
86
86
}
87
87
name = metadata [ NAME ] ;
88
88
}
89
+ // Note that resolvedModuleData.async may be set if this is an Async Module.
90
+ // For Client References we don't actually care because what matters is whether
91
+ // the consumer expects an unwrapped async module or just a raw Promise so it
92
+ // has to already know which one it wants.
93
+ // We could error if this is an Async Import but it's not an Async Module.
94
+ // However, we also support plain CJS exporting a top level Promise which is not
95
+ // an Async Module according to the bundle graph but is effectively the same.
89
96
if ( isAsyncImport ( metadata ) ) {
90
97
return [
91
98
resolvedModuleData . id ,
@@ -128,7 +135,19 @@ export function resolveServerReference<T>(
128
135
) ;
129
136
}
130
137
}
131
- // TODO: This needs to return async: true if it's an async module.
138
+ if ( resolvedModuleData . async ) {
139
+ // If the module is marked as async in a Client Reference, we don't actually care.
140
+ // What matters is whether the consumer wants to unwrap it or not.
141
+ // For Server References, it is different because the consumer is completely internal
142
+ // to the bundler. So instead of passing it to each reference we can mark it in the
143
+ // manifest.
144
+ return [
145
+ resolvedModuleData . id ,
146
+ resolvedModuleData . chunks ,
147
+ name ,
148
+ 1 /* async */ ,
149
+ ] ;
150
+ }
132
151
return [ resolvedModuleData . id , resolvedModuleData . chunks , name ] ;
133
152
}
134
153
You can’t perform that action at this time.
0 commit comments