Open elia opened 3 years ago
I like this a lot!
It's not clear if the current change is backward compatible though. Do we need to change all stores/extensions to make it work once we merge/release this?
It supports both zeitwerk and classic and can be adapted to cover existing stores and extensions. That said, I think we should make it opt-in, like maybe a strong suggestion, but still a suggestion 😊
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This work is built on the awesome work by @fxn on zeitwerk for Rails and @aldesantis on prependers for Solidus
The code in this PR has been tried successfully on a couple of real-world projects with multi-year legacy. The basic principle is that we should only load the decorators for the base classes that are required for the current request, finally playing nice with Rails own autoloading/reloading mechanisms.
One thing that was very interesting is seeing classes autoloaded from initializers (which is an anti-pattern) and the ripple effect they create in terms of loading their dependencies, fixing that kind of stuff would make Solidus stores startup virtually as fast as a pristine Rails app.
As a side note this work will be also proposed for the Rails guides that currently suggest eagerly loading all the decorators, we think, for lack of a better alternative.
from the inline documentation