Load engines properly in both Zeitwerk and Classic modes #1389
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.
Motivation
Until now, our engine loading in Classic mode has been super sketchy, and even our engine loading in Zeitwerk mode was missing some functionality.
This PR improves engine loading so that it:
By running engine initializers, we are able to finally fix #557. However, the fact that we run initializers means that some engines could raise exceptions during load time depending on the existence of certain conditions. For example, Active Storage raises an exception when
ActiveStorage::Blob
is loaded if it is not configured. This means that applications that have not configured AS will only get abridged RBI file, since we won't be able to load anything pastActiveStorage::Blob
.This is not a problem, though, since if the application has not configured Active Storage, it means they are not really using it anyway, so it should not matter. For an application that has a proper configuration of AS, they would get the full RBI file generated.
Implementation
Mimic the behaviour of running initializers and eager loading of engines in classic mode and in zeitwerk mode
Tests
Made the Zeitwerk mode test explicit and added a Classic mode test.