Proof of concept for removing ConstantResolver and using Zeitwerk for ConstantDiscovery #410
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.
What are you trying to accomplish?
I am interested in using Zeitwerk features such as collapsing directories however currently Packwerk doesn't support this.
Based on this comment in a related issue, this PR adds an implementation of
ConstantDiscovery
using Zeitwerk rather thanConstantResolver
as a proof of concept.What approach did you choose and why?
First I refactored to encapsulate
ConstantResolver
so it is easier for me to play with an alternateConstantDiscovery
implementation.Then I implemented a Zeitwerk based
ConstantDiscovery
and copied tests fromConstantDiscovery
and theConstantResolver
gem to make sure it worked ok. Private methods for matching constants from the map of paths was taken from ConstantResolver as well as many tests checking edge cases.Finally I replaced
ConstantDiscovery
with my version and removed the code related to the old implementation. A lot of test helpers needed to be updated here since nowConstantDiscovery
depends on Zeitwerk Loaders 😭What should reviewers focus on?
Type of Change
Checklist