Skip to content

Lazy-load only the necessary controllers #3

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

Closed
stof opened this issue Dec 3, 2020 · 1 comment · Fixed by #15
Closed

Lazy-load only the necessary controllers #3

stof opened this issue Dec 3, 2020 · 1 comment · Fixed by #15

Comments

@stof
Copy link
Member

stof commented Dec 3, 2020

Currently, the bridge generates a virtual module which uses import() with the webpackMode comment to make them eager or lazy.
But the way this @symfony/controllers module is consumed in the main entrypoint means that all the controllers are loaded on all pages to be registered. This makes the lazy-loading useless as you would load all chunks on all pages.

I discovered https://github.com/danieldiekmeier/stimulus-controller-resolver which allows to actually lazy-load some modules only if they are used in the page. It might make sense to use that.

@tgalopin
Copy link
Contributor

tgalopin commented Dec 5, 2020

I agree indeed. That's something that was discussed but not implemented before the release. We should have a deeper look, and probably ship a behaviour to easily leverage that from the assets/controllers.json file.

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

Successfully merging a pull request may close this issue.

2 participants