Skip to content

Commit 95926ac

Browse files
committed
fix: module prepared state error, when modUpdatePreparedState invoke more than once on 1 async require proccess
1 parent 66c05cd commit 95926ac

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/esl.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -673,20 +673,24 @@ var esl;
673673
* @param {string} id 模块id
674674
*/
675675
function modUpdatePreparedState(id) {
676-
var updatingModules = {};
676+
var moduleUpdatingState = {};
677677
update(id);
678678

679679
function update(id) {
680680
modPrepare(id);
681+
681682
if (!modIs(id, MODULE_ANALYZED)) {
682683
return false;
683684
}
684685

685-
if (modIs(id, MODULE_PREPARED) || updatingModules[id]) {
686-
return true;
686+
switch (moduleUpdatingState[id]) {
687+
case 1:
688+
return true;
689+
case 2:
690+
return modIs(id, MODULE_PREPARED);
687691
}
688692

689-
updatingModules[id] = 1;
693+
moduleUpdatingState[id] = 1;
690694
var mod = modModules[id];
691695
var prepared = true;
692696

@@ -711,8 +715,9 @@ var esl;
711715

712716
if (prepared) {
713717
modSetState(id, MODULE_PREPARED);
714-
updatingModules[id] = 0;
715718
}
719+
720+
moduleUpdatingState[id] = 2;
716721
return prepared;
717722
}
718723
}

0 commit comments

Comments
 (0)