-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Use Zeitwerk for autoload/eager load paths (including plugins) #434
Conversation
Your Render PR Server URL is https://bridgetown-beta-pr-434.onrender.com. Follow its progress at https://dashboard.render.com/static/srv-c60o5dvh8vl92avun5kg. |
Your Render PR Server URL is https://bridgetown-api-pr-434.onrender.com. Follow its progress at https://dashboard.render.com/static/srv-c60o5enh8vl92avun5sg. |
I ended up "leaking" a bit of a refactor of how project-specific subclasses of |
ACK! Somehow I messed up the plugins Markdown and replaced all mention of "gem" with "plugin" which makes no sense. Eeek! Will revert. |
This is awesome @jaredcwhite. I'd just like to discuss the code organization within the plugins folder though. As it currently stands with this PR, if I want a class in the top level namespace, I have to place it directly in the This is the
I wouldn't mind namespacing I wonder if we should provide a slightly more opinionated directory structure out of the box? Also, it'd be great to have a config option to treat certain directories as top level. So for eg, I could set a config option so everything in Or we could just keep things super simple and treat all direct subdirectories of Does that make sense? What do you think? |
@ayushn21 That definitely all makes sense. I ended up moving models in one of my projects out of autoload_collapse:
- "plugins/helpers"
- "something/*/else" |
Yeah that sounds good. I think it might be worth adding an empty Also, maybe we could call the option |
I'll mull over the |
(I realized in Zeitwerk-speak they're called "loaders", not "autoloaders", so going with |
- top_level/* | ||
``` | ||
|
||
Thus no files directly in `top_level` as well as any of its subfolders will be namespaced (that is, no `TopLevel` module will be implied). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth adding the word "direct" just to make it a bit more clear that deeper subfolders will be namespaced.
Thus no files directly in `top_level` as well as any of its subfolders will be namespaced (that is, no `TopLevel` module will be implied). | |
Thus no files directly in `top_level` as well as any of its direct subfolders will be namespaced (that is, no `TopLevel` module will be implied). |
I would argue the the Bridgetown config file lives outside the context of Zeitwerk and we've got a config item called It's a small thing though and the docs are pretty clear so 🤷♂️ |
Closes #417