Remove @ethersproject/bytes and tinycolor2 runtime dependencies#36
Open
ripe0x wants to merge 1 commit into
Open
Remove @ethersproject/bytes and tinycolor2 runtime dependencies#36ripe0x wants to merge 1 commit into
ripe0x wants to merge 1 commit into
Conversation
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.
|
@ripe0x is attempting to deploy a commit to the Zora Team on Vercel. A member of the Team first needs to authorize it. |
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.
What
Drops both runtime dependencies (
@ethersproject/bytes,tinycolor2, plus the related@types/tinycolor2). Both were single-call-site shims:@ethersproject/byteswas used solely forarrayify()to parse a hex address into aUint8Array— nokeccak256, no signing, no blockchain primitives.tinycolor2was used solely fortinycolor({h, s, l}).toHslString()to format an HSL object into a CSS string.Both are replaced with inline implementations in
src/lib.ts. ThehslStringhelper reproduces tinycolor'sHSL → RGB → HSLround-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-unusedtinycolorreference inrollup.config.jsare removed.Why
@ethersproject/bytespulls@ethersproject/logger,@ethersproject/strings, etc.).dist/main.js57,027 → 8,839 bytes (−84.5%).dist/component.es.js70,515 → 23,602 bytes (−66.5%).Verification
Built
mainand the patched branch side-by-side and ran bothdist/main.jsbuilds 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
gradientForAddressarray level and the fullzorbImageDataURIbase64 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/zorbin CI. ThearrayifyandhslStringimplementations 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.lockis left unchanged in this PR to keep the diff focused on the substantive change. After merge, runningyarn installonce inpackages/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.