@@ -202,7 +202,7 @@ namespace Js
202
202
203
203
if (this ->promise != nullptr )
204
204
{
205
- SourceTextModuleRecord::ResolveOrRejectDynamicImportPromise (false , this ->errorObject , this ->scriptContext , this );
205
+ SourceTextModuleRecord::ResolveOrRejectDynamicImportPromise (false , this ->errorObject , this ->scriptContext , this , false );
206
206
}
207
207
208
208
// Notify host if current module is dynamically-loaded module, or is root module and the host hasn't been notified
@@ -307,7 +307,7 @@ namespace Js
307
307
{
308
308
// Cleanup in case of error.
309
309
this ->ReleaseParserResources ();
310
- SourceTextModuleRecord::ResolveOrRejectDynamicImportPromise (false , this ->errorObject , scriptContext, this );
310
+ SourceTextModuleRecord::ResolveOrRejectDynamicImportPromise (false , this ->errorObject , scriptContext, this , false );
311
311
}
312
312
else
313
313
{
@@ -342,7 +342,7 @@ namespace Js
342
342
}
343
343
}
344
344
345
- return this ->promise ;
345
+ return JavascriptPromise::CreatePassThroughPromise ( this ->promise , scriptContext) ;
346
346
}
347
347
348
348
HRESULT SourceTextModuleRecord::PrepareForModuleDeclarationInitialization ()
@@ -401,7 +401,7 @@ namespace Js
401
401
402
402
if (this ->promise != nullptr )
403
403
{
404
- SourceTextModuleRecord::ResolveOrRejectDynamicImportPromise (false , this ->errorObject , this ->scriptContext , this );
404
+ SourceTextModuleRecord::ResolveOrRejectDynamicImportPromise (false , this ->errorObject , this ->scriptContext , this , false );
405
405
}
406
406
407
407
if (this ->promise != nullptr || (isRootModule && !hadNotifyHostReady))
@@ -967,7 +967,7 @@ namespace Js
967
967
968
968
if (this ->promise != nullptr )
969
969
{
970
- SourceTextModuleRecord::ResolveOrRejectDynamicImportPromise (false , this ->errorObject , this ->scriptContext , this );
970
+ SourceTextModuleRecord::ResolveOrRejectDynamicImportPromise (false , this ->errorObject , this ->scriptContext , this , false );
971
971
return scriptContext->GetLibrary ()->GetUndefined ();
972
972
}
973
973
else
@@ -1029,7 +1029,7 @@ namespace Js
1029
1029
this ->errorObject = errorObject;
1030
1030
if (this ->promise != nullptr )
1031
1031
{
1032
- ResolveOrRejectDynamicImportPromise (false , errorObject, scriptContext, this );
1032
+ ResolveOrRejectDynamicImportPromise (false , errorObject, scriptContext, this , false );
1033
1033
return scriptContext->GetLibrary ()->GetUndefined ();
1034
1034
}
1035
1035
}
@@ -1041,7 +1041,7 @@ namespace Js
1041
1041
1042
1042
if (this ->promise != nullptr )
1043
1043
{
1044
- SourceTextModuleRecord::ResolveOrRejectDynamicImportPromise (true , this ->GetNamespace (), this ->GetScriptContext (), this );
1044
+ SourceTextModuleRecord::ResolveOrRejectDynamicImportPromise (true , this ->GetNamespace (), this ->GetScriptContext (), this , false );
1045
1045
}
1046
1046
1047
1047
return ret;
@@ -1268,7 +1268,7 @@ namespace Js
1268
1268
}
1269
1269
1270
1270
// static
1271
- Var SourceTextModuleRecord::ResolveOrRejectDynamicImportPromise (bool isResolve, Var value, ScriptContext *scriptContext, SourceTextModuleRecord *moduleRecord)
1271
+ Var SourceTextModuleRecord::ResolveOrRejectDynamicImportPromise (bool isResolve, Var value, ScriptContext *scriptContext, SourceTextModuleRecord *moduleRecord, bool useReturn )
1272
1272
{
1273
1273
bool isScriptActive = scriptContext->GetThreadContext ()->IsScriptActive ();
1274
1274
JavascriptPromise *promise = nullptr ;
@@ -1297,8 +1297,11 @@ namespace Js
1297
1297
if (moduleRecord != nullptr )
1298
1298
{
1299
1299
moduleRecord->SetPromise (nullptr );
1300
+ if (useReturn)
1301
+ {
1302
+ return JavascriptPromise::CreatePassThroughPromise (promise, scriptContext);
1303
+ }
1300
1304
}
1301
-
1302
1305
return promise;
1303
1306
}
1304
1307
}
0 commit comments