d2elk: replace embedded ELK.js with native elk-go - #2820
Merged
Merged
Conversation
|
Great stuff, does this mean the rendering speed of ELK will increase? In my case it’s sometimes around 60sec for a single SVG… |
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
--elk-algorithmOutput compatibility
The port targets the exact ELK.js 0.8.2 behavior previously embedded by D2.
TestE2E: pass93.4990005493164becoming93.5(about 0.001 px)Screenshots are not useful for this autolayout change because the output is visually identical at that sub-pixel delta.
JavaScript removal
There is no runtime ELK JavaScript, ELK loader, ELK setup script, ELK Goja call, or embedded ELK asset in this path anymore. D2 still uses Goja elsewhere for unrelated LaTeX/sketch rendering.
The only JavaScript in the elk-go repository is an opt-in test oracle used to compare the Go implementation with the pinned ELK.js bundle.
Validation
All commands below were run with the real pushed elk-go pseudo-version and
GOWORK=off:go test ./d2layouts/d2elklayoutgo vet ./d2layouts/d2elklayout ./d2pluginGOOS=js GOARCH=wasm go build ./d2jsgo test ./e2etests -run TestE2E -count=1compile("x -> y", {layout: "elk"})smoke testA repository-wide local
go test ./...passes all packages except the same two GIF CLI conversion cases that fail on the untouched baseline in this environment.Size impact
Moving the runtime into Go increases the raw WASM binary by 22.1% and its Brotli output by 16.3%. The packed npm artifacts grow about 9.1%; native CLI binaries grow 0.8–1.3%. The separate ELK JavaScript/runtime assets are removed.
Merge sequencing
d2lang/elk-go#1 is merged and published as
v0.1.0. This PR pins that released version with no localreplace.