Skip to content

chore: Remove d3-dsv, d3-geo-polygon and d3-sankey dependencies - #1010

Open
techniq wants to merge 3 commits into
mainfrom
techniq/d3-dsv
Open

techniq wants to merge 3 commits into
mainfrom
techniq/d3-dsv

Conversation

@techniq

@techniq techniq commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Removes three dependencies that each covered one small piece of code, dropping 12 packages (~2.9 MB) from a layerchart install (production dependency tree goes from 71 to 59 packages).

Removed Replaced with Packages dropped
d3-dsv Inline newline/comma split in sankeyGraphFromCsv() d3-dsv, iconv-lite, safer-buffer, rw (command-line-only deps)
d3-geo-polygon Local copy of geoGrayFullerRaw (public domain, ~60 lines), used only by GeoBin's sphere grid d3-geo-polygon, d3-geo-projection, commander
d3-sankey Local TypeScript port of the layout (BSD-3 header kept), unchanged since its last release in 2019 d3-sankey plus older duplicate d3-array@2, internmap@1, d3-shape@1, d3-path@1

Bundles barely change, since bundlers already dropped most of this: the Sankey layout is ~330 B gzipped smaller (no fluent API, shares the app's d3-array v3).

Behavior

  • sankeyGraphFromCsv() no longer handles quoted fields ("A, Inc",B,1). Otherwise its output is identical, checked against d3-dsv on varied inputs (line endings, blank lines, padded values, extra columns).
  • Gray-Fuller projection output is identical, checked forward and inverse on 20,000 random points.
  • Sankey layout output is identical: 14,400 random layouts across every alignment and nodeSort/linkSort mode (unset, null, comparator), with d3-sankey running on its own d3-array v2. The circular-link and missing-node errors match too.

Types

  • SankeyNode, SankeyLink and SankeyGraph are now layerchart's own types, exported from layerchart, and structurally compatible with @types/d3-sankey. They add layer, which d3-sankey always sets but @types/d3-sankey omitted, so two docs examples drop a now-unneeded @ts-expect-error.
  • The Sankey children snippet's links was typed as nodes; it's now SankeyLink[].
  • Two @ts-expect-errors are gone from Sankey.svelte and one from GeoBin.sphere.ts.

Testing

  • New unit tests: sankey.test.ts (CSV parsing) and sankeyLayout.test.ts (layout pinned to d3-sankey's output for each alignment, fixedValue, error cases).
  • pnpm check in the package: 0 errors. Docs svelte-check reports the same errors as before this branch, none of them new.
  • All 5 docs Sankey examples render in the browser with no NaN values or console errors, and node-select still drills down when you click a node.

🤖 Generated with Claude Code

techniq and others added 3 commits November 17, 2026 22:56
…hFromCsv

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: febb7c4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
layerchart Patch
@layerchart/webgl Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Nov 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/layerchart@1010
npm i https://pkg.pr.new/@layerchart/webgl@1010

commit: febb7c4

@github-actions

Copy link
Copy Markdown
Contributor

Preview deployment

https://pr-1010-layerchart.techniq.workers.dev

Built from febb7c4.

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Use-Case Scenarios

Graph / network (1 changed)
Scenario Current New Change
🟡 sankey 361.59 KB
84.87 gz
359.72 KB
84.53 gz
-1.87 KB (-0.5%)
-0.33 gz (-0.4%)
Components (1 changed)
Scenario Current New Change
🟢 Sankey 9.65 KB
2.94 gz
8.29 KB
2.69 gz
-1.35 KB (-14.0%)
-0.25 gz (-8.6%)
Worst case (1 changed)
Scenario Current New Change
🟡 all 1108.18 KB
263.55 gz
1103.01 KB
262.12 gz
-5.17 KB (-0.5%)
-1.42 gz (-0.5%)

Understanding this report
  • Use-case scenarios measure the bundle cost of common chart configurations (e.g. a line chart with axes)
  • Individual components measure each component imported in isolation
  • Svelte runtime is excluded; sizes reflect layerchart + its dependencies (d3, etc.)
  • When multiple components share dependencies (e.g. d3-scale), the real-world cost is lower than the sum of individual sizes
  • Changes smaller than 10 bytes or 0.1% are considered insignificant

This branch has not been deployed

No deployments
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