Shopify / packwerk

Good things come in small packages.
MIT License
1.54k stars 111 forks source link

[Bug] resolve module namespaces #372

Closed xfifix closed 8 months ago

xfifix commented 9 months ago

Description I'm trying to do a ddd style in the packages. so i created the packages product and and created in the directory app application, domain, infrastructure and used the module application, the module domain and the module infrastructure. it can't load the module but when i remove these modules it works.

To Reproduce create a packages and create in the directory app, the directory application and a ruby class with module Application ..

Version Information

exterm commented 9 months ago

I think to resolve this problem we'll need a little more information. Ideally you would create a simple demo repository that lets people reproduce the problem you're seeing. But giving us a full listing of your folder structure (e.g. with tree -l2 app) would help too.

xfifix commented 9 months ago

yes i made a draft : https://github.com/xfifix/poc-ddd-rails

exterm commented 8 months ago

I'd recommend to look into how zeitwerk, Rails' autoloader, resolves constants. Your namespacing doesn't align with your folder structure. One of the problems is that app/*/ folders are root folders for autoloading so zeitwerk (and packwerk) expects that to be the root of the namespace too. The zeitwerk docs will tell you more.

If you're lucky, rake zeitwerk:check will point you to the problems on your application.

gmcgibbon commented 8 months ago

@exterm is correct, this is am autoloading issue with your application code. Please refer to the Rails guides for help. Closing.