-
Notifications
You must be signed in to change notification settings - Fork 29k
[backport]: Upgrade builtin babel packages on NextJS 14 #81120
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
base: 14-2-1
Are you sure you want to change the base?
Conversation
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
1 similar comment
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
Failing test suitesCommit: 55f7662
Expand output● prerender native module › should render index correctly
● prerender native module › should render /blog/first correctly
● prerender native module › should render /blog/second correctly
● prerender native module › should output traces
● Test suite failed to run
Read more about building and testing Next.js in contributing.md. |
rsc: createDeferredRsc() as unknown as React.ReactNode, | ||
head: isLeafSegment | ||
? (createDeferredRsc() as unknown as React.ReactNode) |
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.
Type assertions are breaking the designed contract where rsc
and head
fields should accept promise-like objects, not just React nodes.
View Details
Analysis
The code adds type assertions as unknown as React.ReactNode
to force createDeferredRsc()
(which returns PendingDeferredRsc
) into the React.ReactNode
type. However, this breaks the intended design where the rsc
and head
fields should accept both React nodes AND promise-like objects.
The downstream consumption code in layout-router.tsx
specifically expects and handles this:
// Lines 390-393 comment: "`rsc` is either a React node or a promise for a React node..."
const resolvedRsc: React.ReactNode =
typeof rsc === 'object' && rsc !== null && typeof rsc.then === 'function'
? use(rsc) // Unwraps promises
: rsc
The type assertions mask what should be a legitimate type compatibility issue. The proper solution would be to update the CacheNode
type definition to reflect that rsc
and head
can be either React.ReactNode
OR promise-like objects, rather than using type assertions to lie to the type system.
This could lead to issues if other parts of the codebase assume these fields are always plain ReactNodes when they can actually be promises.
Recommendation
Instead of using type assertions, update the CacheNode
type definition in packages/next/src/shared/lib/app-router-context.shared-runtime.ts
to properly reflect that the rsc
and head
fields can accept both React.ReactNode
and promise-like objects (specifically DeferredRsc
types). Then remove the type assertions and let TypeScript verify the proper type compatibility.
What
@babel/plugin-proposal-class-properties
->@babel/plugin-transform-class-properties
@babel/plugin-proposal-export-namespace-from
->@babel/plugin-transform-export-namespace-from
@babel/plugin-proposal-numeric-separator
->@babel/plugin-transform-numeric-separator
@babel/plugin-proposal-object-rest-spread
->@babel/plugin-transform-object-rest-spread
Why
The main reason to upgrade is to upgrade the @babel/runtime to new new version to address the security vulnerability GHSA-968p-4wvh-cqc8
test-dev passed
test-start passed
Fixes #77879
Discussion #79976