Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new(geo, vendor): add d3-geo@3 to visx-vendor, support geoPath.digits(n) #1767

Merged
merged 8 commits into from
Nov 13, 2023

Conversation

kachkaev
Copy link
Contributor

@kachkaev kachkaev commented Nov 9, 2023

🚀 Enhancements

Closes #1761

  • update d3-geo to 3.0.8 to support geoPath.digits(n)
  • move d3-geo dep to @visx/vendor because the new version is ESM-only

Demo

digits={5}

Screenshot 2023-11-09 at 22 38 54

digits={0}

Screenshot 2023-11-09 at 22 39 10

no digits prop (defaults to 3)

Screenshot 2023-11-09 at 22 39 35

@@ -115,6 +115,7 @@
"ts-node": "9.1.1",
"typescript": "^3.8.3"
},
"packageManager": "[email protected]",
Copy link
Contributor Author

@kachkaev kachkaev Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using corepack on my computer, which comes with the latest Yarn by default (v4). Specifying packageManager helps corepack pick the right version and run yarn install without errors.

// @see https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/67363
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
if (digits !== undefined) path.digits(digits);
if (pointRadius !== undefined) path.pointRadius(pointRadius);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change is fine (even though 0 shouldn't be a valid input)

Copy link
Collaborator

@williaster williaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kachkaev this looks great to me overall! No issues from my end except with the one visx/demo typescript change I mention (it does look like CI is failing on that so I would try reverting the change and seeing if that fixes it)

@@ -14,11 +14,12 @@
"moduleResolution": "node",
"composite": true,
"outDir": "lib",
"resolveJsonModule": false,
"resolveJsonModule": true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I think there's an issue where next forces this when running the demo app locally, but I think it fails the TS generation in CI. let's see if it passes with this change, else I'd have you revert it for merging (and separately need to fix the issue)

Copy link
Contributor Author

@kachkaev kachkaev Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted this accidental change in f7dddef. Yeah the file was updated by Next when I ran these commands:

cd packages/visx-demo
NODE_OPTIONS=--openssl-legacy-provider yarn dev

(I had to use NODE_OPTIONS to avoid Error: error:0308010C:digital envelope routines::unsupported in Node 18.18.2)

It would be nice to update packages/visx-demo/tsconfig.json but I guess we can do this in a separate DX-focused PR.

packages/visx-geo/src/projections/Projection.tsx Outdated Show resolved Hide resolved
// @see https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/67363
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
if (digits !== undefined) path.digits(digits);
if (pointRadius !== undefined) path.pointRadius(pointRadius);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change is fine (even though 0 shouldn't be a valid input)

packages/visx-geo/src/projections/Projection.tsx Outdated Show resolved Hide resolved
@@ -44,6 +44,6 @@ module.exports = {
verbose: false,
testPathIgnorePatterns: ['<rootDir>/packages/visx-demo'],
transformIgnorePatterns: [
'node_modules/(?!(d3-(array|color|format|interpolate|scale|time|time-format)|delaunator|internmap|robust-predicates)/)',
'node_modules/(?!(d3-(array|color|format|geo|interpolate|scale|time|time-format)|delaunator|internmap|robust-predicates)/)',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for finding this – sorry I missed it in my instructions! this isn't ideal to have to do for each ESM-only package, will think on ways to streamline it.

@kachkaev
Copy link
Contributor Author

kachkaev commented Nov 10, 2023

Thanks for your feedback @williaster! I updated the diff, hope the CI will pass this time 🤞

I guess what’s left is PR description, unless you have other suggestions on the diff. If you can help me with triaging the changes by type (breaking change, feature, etc.), that’d be great. I can look at other PRs for examples, but there is quite a lot going on in this small PR at once (major bump of d3-geo, moving it to the vendor package, adding a new prop). So I might find it hard to find a good match and you’ll likely need to correct my description anyway. I guess it goes directly to CHANGELOG by the looks of it.

@williaster williaster changed the title Update d3-geo, add it to visx-vendor, support geoPath.digits(n) new(geo, vendor): add d3-geo@3 to visx-vendor, support geoPath.digits(n) Nov 10, 2023
@williaster
Copy link
Collaborator

Thanks @kachkaev 🙌 I took a pass at updating the PR title + description. Feel free to tweak if you like, only the title is added to the change log (the PR labels determine what it is labeled as there. I think this is just a minor version bump / new feature since it shouldn't be a breaking change for consumers – even though the d3-geo dep is changing behind the scenes it should only enable net-new functionality)

@williaster
Copy link
Collaborator

CI passed and Happo diffs look fine!
image

You can't really see diffs by eye, but it's picking up on some (as expected going from random digits to the new default of 3)
image

@williaster williaster marked this pull request as ready for review November 10, 2023 22:57
@williaster
Copy link
Collaborator

I think unless you have any other things you want to add, this is probably good to go. Will wait to hear from you before merging/releasing, tho!

@kachkaev
Copy link
Contributor Author

kachkaev commented Nov 10, 2023

Oh great! Thanks for helping! If the diff and the description look acceptable, let’s get this PR in!

Visx is a great lib! I’m glad I’ve been able to pay back with this small contribution! 🙌

@kachkaev
Copy link
Contributor Author

kachkaev commented Nov 12, 2023

I guess we can wait for DefinitelyTyped/DefinitelyTyped#67384 and remove #1767 (comment)

UPD: Done in a3f86cb

Copy link
Collaborator

@williaster williaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is great, thanks for landing the type change as well!! 🎉

really appreciate the contribution and hard work. glad to hear you are enjoying visx overall :)

@williaster williaster merged commit 1ee0374 into airbnb:master Nov 13, 2023
2 checks passed
Copy link

🎉 This PR is included in version v3.5.0 of the packages modified 🎉

@kachkaev kachkaev deleted the visx-geo-digits branch November 13, 2023 20:50
Onxi95 pushed a commit to Onxi95/visx that referenced this pull request Nov 21, 2023
…igits(n)` (airbnb#1767)

* Update `d3-geo`, add it to `visx-vendor`, support `Projection#digits`

* Link to issue

* Reduce diff

* tsconfigs

* Update packages/visx-geo/src/projections/Projection.tsx

Co-authored-by: Chris Williams <[email protected]>

* Reduce diff

* Update `@types/d3-geo` to `3.1.0`

* Dedupe `d3-array`

---------

Co-authored-by: Chris Williams <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support geoPath.digits(n) in geo projection components
2 participants