Understanding Packwerk and its Role in Ruby Ecosystem - TLDR Explanation Needed

This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.

Message originally sent by slack user U71WGNVGAQG

Hi there! I’ve been working with Ruby since about 2004, used plugins first and engines and gems later to break up and create components and dependency structures in Rails apps.

I switched to product management in 2018 so I haven’t really been looped in the Ruby ecosystem but I’ve seen packwert mentioned in a few places including @stephan cbra.org

I am trying to watch a 1h preso by Shopify but it sounds like it’s a packwerk check is kinda like a rubocop .Can anyone give me a TLDR of packwert as opposed to gems/engines

Many thanks!

I wrote a blog post that contains a TLDR and comparison of gems/engines: https://medium.com/gusto-engineering/laying-the-cultural-and-technical-foundation-for-big-rails-6b5ab78349ed

ctrl+f: Packwerk tl;dr

Message originally sent by slack user U71WGNVGAQG

@AlexEvanczuk thanks, very clear!

Great! Let me know if you have any more questions or anything :smile:

Message originally sent by slack user U71WGNVGAQG

I might, so let’s say we have two folders:

/billing
/booking

each with its package.yml

Is it safe to assume all the ruby files in billing will be in a Billing namespace and in booking in a Booking namespace?

Message originally sent by slack user U71WGNVGAQG

as a step 0 of the “gradual modularity”

Not necessarily — any ruby file in any package can be in any arbitrary namespace. In rubocop-packs , we actually have a cop to enforce the pattern you’re describing.

Conforming files in a pack to be under a common namespace is definitely a great tactic in gradual modularity to help create boundaries! I published another blog post that is an opinionated guide about what steps to take in what order: https://medium.com/gusto-engineering/a-how-to-guide-to-ruby-packs-gustos-gem-ecosystem-for-modularizing-ruby-applications-e236126b8c2c

Message originally sent by slack user U71WGNVGAQG

I see that’s interesting, I like how… it’s a very low effort to introduce packs.

I think if we had to do that step 0 with an engine/gem… you could technically achieve the same if you ignored testing the gem in isolation. Couldn’t you?

Message originally sent by slack user U71WGNVGAQG

I think the advantage I see (from the 30m I’ve been looking in to packwert) is you can have a paced transition to components and be specific on the warnings you want to address.

Potentially, yes, although I’m not sure what will break down. I know autoloading would work a bit different. You could turn on zeitwerk for your gem, although I’m not sure if packwerk will know how to find constants in gems that have a different zeitwerk configuration than the main app.

Hi Enrico! Long time no see :slightly_smiling_face:

Message originally sent by slack user U71WGNVGAQG

hey buddy!

Message originally sent by slack user U71WGNVGAQG

I was cbra.info redirect and here I am :smiley: