Skip to content

Remove @ethersproject/bytes and tinycolor2 runtime dependencies#36

Open
ripe0x wants to merge 1 commit into
ourzora:mainfrom
ripe0x:remove-runtime-deps
Open

Remove @ethersproject/bytes and tinycolor2 runtime dependencies#36
ripe0x wants to merge 1 commit into
ourzora:mainfrom
ripe0x:remove-runtime-deps

Conversation

@ripe0x
Copy link
Copy Markdown

@ripe0x ripe0x commented May 6, 2026

What

Drops both runtime dependencies (@ethersproject/bytes, tinycolor2, plus the related @types/tinycolor2). Both were single-call-site shims:

  • @ethersproject/bytes was used solely for arrayify() to parse a hex address into a Uint8Array — no keccak256, no signing, no blockchain primitives.
  • tinycolor2 was used solely for tinycolor({h, s, l}).toHslString() to format an HSL object into a CSS string.

Both are replaced with inline implementations in src/lib.ts. The hslString helper reproduces tinycolor's HSL → RGB → HSL round-trip and integer-rounding so output stays byte-for-byte identical.

The public API (<zora-zorb> custom element, gradientForAddress, zorbImageSVG, zorbImageDataURI) and the SVG template are unchanged. Svelte and the build setup are untouched — only the two runtime deps and the now-unused tinycolor reference in rollup.config.js are removed.

Why

  • Drops the dep tree (@ethersproject/bytes pulls @ethersproject/logger, @ethersproject/strings, etc.).
  • Bundle size: dist/main.js 57,027 → 8,839 bytes (−84.5%). dist/component.es.js 70,515 → 23,602 bytes (−66.5%).
  • Identical behavior, fewer install-time concerns for downstream consumers.

Verification

Built main and the patched branch side-by-side and ran both dist/main.js builds through a 2,315-input corpus in the same Node process: 10 edge addresses (zero, max, alternating bits), 5 famous addresses, 2,000 deterministic Mulberry32-seeded random addresses, and 100 addresses' worth of case variants (lower / upper / mixed).

Result: 2,315 / 2,315 outputs identical, both at the gradientForAddress array level and the full zorbImageDataURI base64 string level. Zero divergences.

This algorithm has also been independently re-implemented and production-tested as zero-deps-zorbs / github.com/ripe0x/zero-deps-zorbs, which has its own 4-layer parity suite running against @zoralabs/zorb in CI. The arrayify and hslString implementations in this PR are the same ones that pass that suite.

Risk

None. Same algorithm, same SVG template, same rounding, same custom element API. If the parity test is correct, output is interchangeable with the current published @zoralabs/zorb@0.1.0.

Housekeeping note for the maintainer

yarn.lock is left unchanged in this PR to keep the diff focused on the substantive change. After merge, running yarn install once in packages/zorb-web-component/ will prune the now-unused entries (@ethersproject/*, tinycolor2, etc.). I left it out of this PR because regenerating tends to also bump unrelated transitive entries to fresher versions, which would have ballooned the diff with noise.

Happy to follow up with a separate lockfile-only commit on this branch if preferred.

Both deps were single-call-site shims:
- @ethersproject/bytes: only used for `arrayify()` (hex string -> Uint8Array).
  No keccak / signing / blockchain primitives — just hex parsing.
- tinycolor2: only used for `tinycolor({h,s,l}).toHslString()` to format
  HSL into a CSS string.

Replaced both with inline implementations in src/lib.ts. The hslString
helper reproduces tinycolor's HSL -> RGB -> HSL roundtrip and
integer-rounding so output stays byte-for-byte identical.

Output verification: ran upstream main's built dist/main.js and the
patched dist/main.js side-by-side through a 2,315-address corpus (edge
cases, famous addresses, 2,000 deterministic Mulberry32-seeded random
addresses, and 100 addresses' worth of case variants). All gradient
arrays and zorbImageDataURI outputs matched byte-for-byte.

Bundle size impact (`dist/main.js`): 57,027 -> 8,839 bytes (-84.5%).
`dist/component.es.js`: 70,515 -> 23,602 bytes (-66.5%).

The public API (`<zora-zorb>` custom element, `gradientForAddress`,
`zorbImageSVG`, `zorbImageDataURI`) and the SVG template are unchanged.
Svelte build remains in place — only the two runtime deps and one
rollup-config tinycolor reference are removed.

Note: yarn.lock will need to be regenerated by running `yarn install`
locally after merge to drop the now-unused entries.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 6, 2026

@ripe0x is attempting to deploy a commit to the Zora Team on Vercel.

A member of the Team first needs to authorize it.

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