automatic_namespaces icon indicating copy to clipboard operation
automatic_namespaces copied to clipboard

Any paths inside a pack which contain `app` are added to autoload paths

Open stevegeek opened this issue 1 year ago • 1 comments

Hey all! Love the idea of this gem.

Ive been trying it out but it seems like any pack which uses automatic_pack_namespace will add any paths containing app/ in them to autoload, due to the glob https://github.com/gap777/automatic_namespaces/blob/main/lib/automatic_namespaces/autoloader.rb#L26

Just wondering if this is intentional?

A typical pack setup might include a test/ or spec/ directory which then might contain a app directory nested under it, eg test/app/models/foo_test.rb (since the test file is likely to start with require 'test_helper' this will then blow up at eager load time for example).

I assume the work around is to use the directory exclusions but it seems like the glob is pulling in too much.

Thanks for any thoughts!

stevegeek avatar Feb 13 '24 16:02 stevegeek

@stevegeek If you want to tighten up the glob pattern, I'm not opposed to a PR.

gap777 avatar Nov 13 '24 20:11 gap777

@stevegeek Should I close this, or do you have a suggestion on how to change the gem?

gap777 avatar Jul 18 '25 01:07 gap777

@gap777 Hey, since I raised this I have been using my own local modified copy of the gem, which is: https://gist.github.com/stevegeek/ec1efe6358f08d61c81f47270e436457 . Unfortunately I can't remember what else I might have changed. The glob was changed to #{pack_root_dir}/app/* instead of #{pack_root_dir}/**/app/* . Happy to continue using my copy so feel free to close!

stevegeek avatar Jul 18 '25 08:07 stevegeek