Actually, unless there something with the Visitor api that I don't understand, I can't see that happening anywhere. The only references to the promises array lies within the ReplacerMap. The Replacer constructors joins promises with its own promise (this.promise), which lies in a static place in the promises array. The indexes of the promises seems to be irrelevant, since all the relevant references to the promises happens by fetching the Replacer and then the promise of that replacer. The whenAll method does not seem to care about the indexes either, since it only reads the length of the array. What we did before was actually the same as pushing, since the id used to be the same as the length of the array. I could not use the id anymore for that since the first set of ids refers to external modules, so I just did the same as it used to do, by pushing instead of adding after the last index. Can you describe the use-case for me where it would not work? I feel that I might be missing something.

I noticed though that I accidentally removed the if statement at the top of the function. Why it still works I have no idea, but I will put that back.