Skip to content

Comments

Implement "layer" pack style#1158

Open
ecraig12345 wants to merge 1 commit intomainfrom
ecraig/boring-pancakes
Open

Implement "layer" pack style#1158
ecraig12345 wants to merge 1 commit intomainfrom
ecraig/boring-pancakes

Conversation

@ecraig12345
Copy link
Member

@ecraig12345 ecraig12345 commented Feb 18, 2026

(Same as #1157, but boring/clearer naming 🚫 🥞 😭)

When packing packages to a path, it turns out it may be useful or necessary to group layers of the tree together rather than using sequential ordering.

This PR adds a new option packStyle: 'sequential' | 'layer'. The new option refers to packages from each layer of the graph that can be published in parallel. The first layer will be the leaf packages with no dependencies, and the last will be the root packages that depend on all others. The layers go in numbered subfolders under packToPath.

The layering uses Kahn's algorithm for BFS to extract the layers in O(V+E). (Apparently LLMs are good at choosing and writing algorithms thanks to the many code examples online...)

If possible, layers are computed based on only the set of published packages. This should be safe with beachball's default behaviors of bumping dependents, but layers will be computed over the full graph under any of the following conditions which might cause missing edges. (Not 100% sure this is necessary, but not sure how to disprove it either...)

  • bumpDeps is false
  • scope is set
  • There are newPackages
  • Any change has dependentChangeType set to "none"

In either case, devDependencies are ignored when computing the graph since they can't break published packages. This should improve improve efficiency and potentially condense the resulting layers slightly.

I also replaced usage of the toposort package with the new layer logic, since they effectively do the same thing (exact ordering may vary, but the topological relationships are handled either way).

Currently, there's only VERY basic cycle handling: all cycles are grouped together on a final layer, regardless of any interdependencies. This should be fine since the toposort package previously used by beachball doesn't handle cycles at all, which implies that repos publishing with beachball don't have cycles. (Tarjan's strongly connected components algorithm could be added at the end to break cycles into more layers if needed in the future, but it's a lot of extra complexity.)

@ecraig12345 ecraig12345 force-pushed the ecraig/boring-pancakes branch from bb1c32e to 48bc2a6 Compare February 18, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant