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

Update Zeitwerk setup #202

Merged
merged 2 commits into from
Feb 15, 2024
Merged

Update Zeitwerk setup #202

merged 2 commits into from
Feb 15, 2024

Conversation

fxn
Copy link
Contributor

@fxn fxn commented Jan 24, 2024

What? Why?

There are three proposed changes.

The main motivation for this patch is that thanks to fxn/zeitwerk#282 and fxn/zeitwerk#284 I have learned __dir__ is not a good path prefix for setting loaders up, because it is a real path, while __FILE__ is not. This detail shows up when using symlinks, as it is the case in the project those tickets were about. The proposed code uses File.dirname(__FILE__) instead, for cosistency in the involved paths.

Gruf probably copied a snippet from the README that unrolled what for_gem does and used __dir__, that snippet has been recently updated (fxn/zeitwerk@7daca61). However, that snippet is only there for illustration purposes, it is more simple and idiomatic to setup the loader with for_gem. So we simplify things a bit with for_gem.

Finally, since I was on it, Zeitwerk is a top-level constant, there is no reason to use a leading :: in the top-level of the script.

How was it tested?

Using demo apps locally, both auto and eager loading.

@splittingred
Copy link
Member

Hi @fxn - can you rebase from latest here?

@fxn
Copy link
Contributor Author

fxn commented Feb 15, 2024

@splittingred done!

Copy link
Member

@splittingred splittingred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@splittingred splittingred merged commit 1cd0700 into bigcommerce:main Feb 15, 2024
17 checks passed
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.

2 participants