Port Dagre 0.8.5 to Go - #1
Merged
Merged
Conversation
alixander
marked this pull request as ready for review
August 8, 2026 18:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
D2 currently embeds Dagre 0.8.5 as JavaScript and executes it through Goja. Dagro provides a behavior-compatible native Go implementation so D2 can remove that runtime and bundled asset without changing layout output.
Compatibility is intentionally measured against Dagre 0.8.5, the version embedded by D2. Later Dagre versions retain the same broad pipeline but contain behavior-changing ordering, positioning, compound-layout, API, and dependency changes.
Impact
This repository introduces the Go module
github.com/d2lang/dagro. It has no third-party Go runtime dependencies. The public API includes the graph operations used by Dagre and D2 plus the layout entry point.Dagro is MIT-licensed. Its
LICENSEretains the Dagre/Graphlib copyright notice and also covers the new Dagro contributions;NOTICErecords the exact upstream versions and commits used by the port.Validation
DAGRO_DAGRE_JS=/absolute/path/to/dagre-0.8.5.js go test ./... -count=1go test -race ./... -count=1go vet ./...The dependent integration is d2lang/d2#2819.