[Bug] Removing unnecessary Promise in object of controllers to be loaded #81
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.
Hi!
Subtle change. Previously, the webpack loader parsed
controllers.json
(which eventually becomes thesymfonyControllers
variable inindex.ts
) into something that exported an object where each key was a promise - something like:Then, in
startStimulusApp()
, we called used.then()
to wait for that promise to resolve then registered its resolved value:This is totally unnecessary and a relic of how this library was originally built. It also causes the UX controllers to be registered late. It's barely noticeable, but in practice, instead of the UX controllers being registered BEFORE the DOM is ready, they are registered after. This actually causes a problem with a new feature from LiveComponents.
The new parsed version of
controllers.json
from the loader looks much simpler:(I don't show it here, but lazy controllers have a similar simplification).
In short: it's a bug fix & an easy win. Controllers will load slightly earlier as a result.
Thanks!