Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Transitive Dependencies #259

Closed
shioyama opened this issue Nov 11, 2022 · 0 comments
Closed

Transitive Dependencies #259

shioyama opened this issue Nov 11, 2022 · 0 comments

Comments

@shioyama
Copy link
Member

If you have three packages (based on the ones in the Packwerk intro video):

# app/models/building/package.yml
enforce_depencencies: true
dependencies:
- app/models/vehicle
# app/models/building/house.rb
module Building
  class House
    def initialize(blocks:, vehicle:)
      @blocks = blocks
      @vehicle = Vehicle::Truck.new(
        engine: Parts::TruckEngine.new
      )
    end
  end
end
# app/models/vehicle/package.yml
enforce_dependencies: true
dependencies:
- app/models/parts
# app/models/vehicle/truck.rb
module Vehicle
  class Truck
    def initialize(engine: Parts::Engine.new)
      @engine = engine
    end
  end
end
# app/models/parts/package.yml
enforce_dependencies: true
dependencies:
# app/models/parts/engine.rb
module Parts
  class Engine
  end
end

# app/models/parts/truck_engine.rb
module Parts
  class TruckEngine
  end
end

Based on the common understanding of "dependency", you would expect that referencing Parts::TruckEngine from inside Building::House would be allowed since building depends on vehicle, which depends on parts, which contains Parts::TruckEngine. But this would in fact fail since Packwerk does not consider dependencies transitively, so you would have to change the app/models/building package like so:

 # app/models/building/package.yml
 enforce_depencencies: true
 dependencies:
 - app/models/vehicle
+- app/models/parts

This is fine for three packages like this, but the problem scales badly with number of packages. We now have nearly 100 packages in our core monolith and the number of times dependencies are duplicated in package.yml files is getting out of hand.

I'd like to propose that Packwerk consider dependencies transitively, such that the change to app/models/building/package.yml would not be necessary. This seems like it shouldn't be hard to do.

Any thoughts?

@Shopify Shopify locked and limited conversation to collaborators Nov 11, 2022
@rafaelfranca rafaelfranca converted this issue into discussion #260 Nov 11, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant