Skip to content

Replace Rough.js sketch runtime with rough-go - #2821

Merged
alixander merged 3 commits into
masterfrom
agent/use-rough-go
Aug 9, 2026
Merged

Replace Rough.js sketch runtime with rough-go#2821
alixander merged 3 commits into
masterfrom
agent/use-rough-go

Conversation

@alixander

@alixander alixander commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • replace D2 sketch rendering's embedded Rough.js/Goja execution with the native github.com/d2lang/rough-go port
  • preserve the existing D2 sketch preparation, SVG theming, overlays, arrowheads, and six-decimal path normalization
  • remove d2renderers/d2sketch/rough.js, setup.js, their embedded loader, and the sketch-path JSRunner
  • run the same native Go renderer in CLI and WASM builds
  • ship the Rough.js/rough-go MIT notice in D2's root and npm third-party notices

Uses d2lang/rough-go#1, merged and tagged v0.1.0.

Compatibility

The dependency is pinned to:

github.com/d2lang/rough-go v0.1.0

There is no local replace.

All 38 focused sketch SVG fixtures remain byte-for-byte unchanged, and the full D2 E2E suite passes with its existing board and SVG goldens. The Rough sketch path no longer loads or evaluates JavaScript in native or WASM builds; unrelated JavaScript consumers elsewhere in D2 are unchanged.

The branch is reconciled with current master, including the native elk-go migration, and the combined ELK + Rough E2E corpus passes.

Tests

  • GOWORK=off go test -race ./d2renderers/d2sketch ./d2renderers/d2svg -count=1
  • GOWORK=off go test ./d2layouts/d2elklayout -count=1
  • GOWORK=off go test ./e2etests -run '^TestE2E$' -count=1
  • GOWORK=off go vet ./d2renderers/d2sketch ./d2renderers/d2svg ./d2layouts/d2elklayout ./d2plugin
  • GOWORK=off GOOS=js GOARCH=wasm go build ./d2js
  • Node-hosted WASM sketch compile
  • d2js unit and Node CJS/ESM integration suites

A repository-wide go test ./... run passes all relevant packages but still reports the two environment-dependent GIF conversion failures one-layer-gif and how_to_solve_problems_gif; both reproduce unchanged on current master.

@alixander
alixander marked this pull request as ready for review August 9, 2026 05:05
@alixander
alixander merged commit 5666d93 into master Aug 9, 2026
6 checks passed
@alixander
alixander deleted the agent/use-rough-go branch August 9, 2026 05:10
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