Ensure waiters are discovered even if multiple versions exist #388
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.
Currently, we rely heavily on the highlander logic to ensure that we can only ever have one version of
@ember/test-waiters
in the build outpu. The reason for this is so that when someone callshasPendingWaiters()
we can reliably ensure that ALL waiters that have been registered (regardless of version mismatches and whatnot) are found.Unfortunately, we cannot actually rely on the highlander logic to guarantee this "waiter map" uniqueness in Embroider builds (because the highlander logic is broken by the isolated nature of Embroiders compatibility layer).
This change migrates from a strict reliance on the highlander logic to guarantee the module scoped variable is shared globally to a mechanism of sharing the state on
globalThis
(with fallbacks for various other scenarios). Using this pattern allows us to avoid "caring" if the highlander code actually enforces a single version, while still ensuring thathasPendingWaiters
will always return the right value.It is likely that future changes will remove the usage of the highlander logic as of a certain version (that includes this change) and higher.