-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
chore: consolidate Node releases data #5365
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
chore: consolidate Node releases data #5365
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
d76f205
to
315d4e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that you're recreating a few things here.
Let's please simply update the existing file https://github.com/nodejs/nodejs.org/blob/main/scripts/next-data/getNodeVersionData.mjs to do this logic.
You can also remove all the route logic from there.
This also means you can remove this https://github.com/nodejs/nodejs.org/blob/main/next.data.mjs#L18 and https://github.com/nodejs/nodejs.org/blob/main/next.data.mjs#L21, as the nodeReleaseData will not be part of each page context. And call the function...
And call it around here https://github.com/nodejs/nodejs.org/blob/main/next.data.mjs#L7
You also need not update package.json with an extra script/step.
This also means you should probably remove the usages of https://github.com/search?q=repo%3Anodejs%2Fnodejs.org%20nodeVersionData&type=code that comes from the App context.
Yes, this change would effectively also change/affect the current website (not just website-redesign).
So honestly speaking, all these changes should be done directly targeting the main
branch.
You can
Thank you for the inputs! Let me summarise to verify that I understood correctly.
Initially I was hesitant because I wanted to maintain clear separation (not touching existing things). |
315d4e0
to
6315de2
Compare
It will be added back later
@ovflowd I've updated the branch with latest main as well... Can we let it bake for a while? |
Sure, @HinataKah0 I'm going to run the deployment and then you can start testing it :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (just another approval) but just wanted to reiterate the stellar work you've done here!!
I've done some sanity checks, looks good so far :) |
@HinataKah0 do you know if the And a recording of the issue (with a throttled network/simulated network condition just to show the racing-condition) Screen.Recording.2023-06-15.at.00.17.37.mov |
I think it's expected because: "Download" -> because the default OS is
Just curious, are you putting timeout or there's convenient way? |
I've used the DevTools to create a "metered network condition" of "slow 3g"
That honestly makes sense. Since useDetectOS is independent of the NodeReleaseProvider. I think that even with the NodeReleaseData being pre-renderer we would still have this "issue" on the current layout. Luckily the new design (https://nodejs.dev/en/) doesn't has such pitfall, since the Download Section (OS selection) is aggregated together with the Download buttons, making the render already be conditional once both Release Data + UserOS got defined. So not something we need to worry about as it is more an UX issue that is already going to be solved by the new design. |
@nodejs/website I'll let this bake for some time and please help for another approval... Thanks! |
@Harkunwar if you could give a review here that'd be awesome! |
@HinataKah0 the new rules got accepted so if you want you can merge this PR :) But if you want to wait for another review, feel free. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - nice work
Going to proceed with merging this for now :) if we need to make amends, let me know. |
🚀 It has been merged, and it has been a long ride! I really appreciate all the helps in making this done! |
Design
nodevu
's outputs which will greatly reduced the generated JSON file size).In Client side, fetch the generated static JSON file usinguseSWR
hook, do formatting & time sensitive logic (e.g. computing the release status).WithNodeRelease
component which acts as a guard (not to render a component if can't find a specific Node release, e.g. LTS or Current).Legacy
useNodeData
hook will be removed and legacy usages in nodejs.org will be updated.Update (27/06/2023):
#5443
This PR includes Node releases data in the bundle. Fetching the data in Client side harms the UX badly in slow 3G network.
TODO
WithNodeRelease
in the Download Components Migration issue.Related to: #5350
(WIP) Guide on Node Releases Data
Provider
useNodeReleases
If you need all the past Node Releases, here's how to use this hook:
Example:
DownloadReleasesTable.tsx
If you need only a single Node Release (usually the latest LTS/Current), you can use
WithNodeRelease
to wrap your component (see below for details).WithNodeRelease
There are many cases requiring us to provide a Component with a single
NodeRelease
object. Usually it is the latest Node release with either LTS or Current status (e.g. this, and this). You can get the desiredNodeRelease
object usingWithNodeRelease
"Provider", see below for how to use it.It is not encouraged to create a new Props type if it contains only a single
NodeRelease
object, instead you can useNodeRelease
as the Props type itself.Example:
Parent
Child (MyComponent)
Parent
Child (MyComponent)
-> more flexible variationIn case you need other Props, here's how you can pass additional Props.
How to Mock (for Tests)?
WIP
Refer to this comment for the time being