Fix cannot find module error with runtimes in multiple bundles #9646
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #9196
This fixes a cannot find module error that occurs when you have an HTML page with two script tags, each with an async import. It occurs because runtimes are processed in reverse order, so the bundle manifest gets put in the second script tag rather than the first, even though the first also has a dependency on it.
This behavior was introduced in #8837 and subsequently updated in #8981. I believe the intent was to place parallel runtime bundles before the bundles that used them, but it inadvertently also changed the order of other runtimes as well. The fix is to handle parallel runtimes separately, by inserting them at the beginning of the list of connections instead of the end, while treating other runtimes normally.
Added test and existing tests pass, but would be good to verify in applications.