Is there a reason components are in `app` as opposed to `lib`?
I'm working on a UI library which will use ViewComponent::Form and Zeitwerk doesn't like the non-standard file structure.
There is an engine which configures autoload paths, but this doesn't work well when used in the context of another gem.
I've setup a 'hack' to auto load the app paths:
require "zeitwerk"
loader = Zeitwerk::Loader.for_gem
vcf_gem_dir = Gem::Specification.find_by_name("view_component-form").gem_dir
loader.push_dir File.join(vcf_gem_dir, "app", "components")
loader.push_dir File.join(vcf_gem_dir, "app", "components", "concerns")
loader.setup
I'm wondering if there's a reason it's setup this way which might not be immediately obvious?
That example ^ doesn't exactly work though, it works if you're not using Rails, but as soon as you add the gem to Rails it conflicts with the Zeitwerk loader added by the gem:
Zeitwerk::Loader
wants to manage directory /xyz, which is already managed by
Zeitwerk::GemLoader
Hi @joelzwarrington, no particular reason if I remember correctly. I think we can totally move the files to lib. Would that imply that when we want to override a ViewComponent::Form component locally, the file would need to be in lib as well, rather than app? In this case this would be a breaking change.