Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce application.lazyLoadingControllers config #687

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marcoroth
Copy link
Member

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 in stimulus-rails we can't really control/check the current setting.

This pull request allows the functions in stimulus-loading.js to set application.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.

This configuration is used to indicate if the Stimulus application is lazy loading its Stimulus controllers or if the controllers are being eager loaded.
@dhh
Copy link
Member

dhh commented Jun 18, 2023

Like where this is going, but would prefer to treat it as a complete solution. If that means pulling the loading strategies into Stimulus, let's do that.

@marcoroth
Copy link
Member Author

I'll have a look how that might look like if we'd want to move everything into Stimulus itself.

@AndersGM
Copy link

I've given it a shot here: #690 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants