@@ -722,8 +722,8 @@ namespace Js
722722 Recycler* recycler = GetScriptContext ()->GetRecycler ();
723723 this ->parentModuleList = RecyclerNew (recycler, ModuleRecordList, recycler);
724724 }
725- bool contains = this -> parentModuleList -> Contains (parentRecord);
726- if (!contains )
725+
726+ if (!this -> parentModuleList -> Contains (parentRecord) )
727727 {
728728 this ->parentModuleList ->Add (parentRecord);
729729 parentRecord->numPendingChildrenModule ++;
@@ -827,20 +827,15 @@ namespace Js
827827 SetWasDeclarationInitialized ();
828828 if (childrenModuleSet != nullptr )
829829 {
830- childrenModuleSet->Map ([](LPCOLESTR specifier, SourceTextModuleRecord* moduleRecord )
830+ childrenModuleSet->EachValue ([=]( SourceTextModuleRecord* childModuleRecord )
831831 {
832- Assert (moduleRecord->WasParsed ());
833- moduleRecord->shouldGenerateRootFunction =
834- moduleRecord->ModuleDeclarationInstantiation ();
832+ Assert (childModuleRecord->WasParsed ());
833+ childModuleRecord->ModuleDeclarationInstantiation ();
835834 });
836835
837- childrenModuleSet->Map ([](LPCOLESTR specifier, SourceTextModuleRecord* moduleRecord )
836+ childrenModuleSet->EachValue ([=]( SourceTextModuleRecord* childModuleRecord )
838837 {
839- if (moduleRecord->shouldGenerateRootFunction )
840- {
841- moduleRecord->shouldGenerateRootFunction = false ;
842- moduleRecord->GenerateRootFunction ();
843- }
838+ childModuleRecord->GenerateRootFunction ();
844839 });
845840 }
846841
@@ -866,6 +861,11 @@ namespace Js
866861
867862 void SourceTextModuleRecord::GenerateRootFunction ()
868863 {
864+ if (this ->rootFunction != nullptr )
865+ {
866+ return ;
867+ }
868+
869869 ScriptContext* scriptContext = GetScriptContext ();
870870 Js::AutoDynamicCodeReference dynamicFunctionReference (scriptContext);
871871 CompileScriptException se;
0 commit comments