Introduce application.lazyLoadingControllers
config
#687
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.
This configuration is used to indicate if the Stimulus application is lazy loading its Stimulus controllers or if the controllers are being eager loaded.
Ideally this configuration wouldn't be necessary in the first place, but since the logic for handling lazy/eager loading Stimulus controllers with Importmaps is handled in
stimulus-loading.js
instimulus-rails
we can't really control/check the current setting.This pull request allows the functions in
stimulus-loading.js
to setapplication.lazyLoadingControllers = true
so the actual Stimulus application knows the loading approach. With that we can control behavior like showing "unregistered controller warnings" based on this setting (see #413 and #653).Since Stimulus is autoloading controllers in the lazy loading mode we can't really know if/when we should show an unregistered controller warning since they are being fetched on-the-fly. Down the road we probably want to integrate the lazy loading approaches directly into
@hotwired/stimulus
itself se we have more control over this behavior.Note: for now
application.lazyLoadingControllers
is considered "private", we don't expect developers to set that config in their applications.