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

[metadata] Change the array head to single node in flight data #74299

Draft
wants to merge 2 commits into
base: huozhi/12-23-_move_metadata_render
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next/src/client/components/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export function createEmptyCacheNode(): CacheNode {
lazyData: null,
rsc: null,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
parallelRoutes: new Map(),
loading: null,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/client/components/layout-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ export default function OuterLayoutRouter({
lazyData: null,
rsc: null,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
parallelRoutes: new Map(),
loading: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function fillNewTreeWithOnlyLoadingSegments(
// copy the layout but null the page segment as that's not meant to be used
rsc: segmentForParallelRoute.includes(PAGE_SEGMENT_KEY) ? null : rsc,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
parallelRoutes: new Map(),
loading,
Expand All @@ -184,7 +184,7 @@ function fillNewTreeWithOnlyLoadingSegments(
lazyData: null,
rsc: null,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
parallelRoutes: new Map(),
loading: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('clearCacheNodeDataForSegmentPath', () => {
lazyData: null,
rsc: null,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
parallelRoutes: new Map(),
loading: null,
Expand All @@ -25,7 +25,7 @@ describe('clearCacheNodeDataForSegmentPath', () => {
lazyData: null,
rsc: <>Root layout</>,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map([
Expand All @@ -38,7 +38,7 @@ describe('clearCacheNodeDataForSegmentPath', () => {
lazyData: null,
rsc: <>Linking</>,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map([
Expand All @@ -51,7 +51,7 @@ describe('clearCacheNodeDataForSegmentPath', () => {
lazyData: null,
rsc: <>Page</>,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
parallelRoutes: new Map(),
loading: null,
Expand All @@ -71,28 +71,19 @@ describe('clearCacheNodeDataForSegmentPath', () => {

expect(cache).toMatchInlineSnapshot(`
{
"head": [
null,
null,
],
"head": null,
"lazyData": null,
"loading": null,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
"head": [
null,
null,
],
"head": null,
"lazyData": null,
"loading": null,
"parallelRoutes": Map {
"children" => Map {
"" => {
"head": [
null,
null,
],
"head": null,
"lazyData": null,
"loading": null,
"parallelRoutes": Map {},
Expand All @@ -111,10 +102,7 @@ describe('clearCacheNodeDataForSegmentPath', () => {
</React.Fragment>,
},
"dashboard" => {
"head": [
null,
null,
],
"head": null,
"lazyData": null,
"loading": null,
"parallelRoutes": Map {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function clearCacheNodeDataForSegmentPath(
lazyData: null,
rsc: null,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
parallelRoutes: new Map(),
loading: null,
Expand All @@ -56,7 +56,7 @@ export function clearCacheNodeDataForSegmentPath(
lazyData: null,
rsc: null,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
parallelRoutes: new Map(),
loading: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ describe('createInitialRouterState', () => {
const initialParallelRoutes: CacheNode['parallelRoutes'] = new Map()

const state = createInitialRouterState({
initialFlightData: [
[initialTree, ['', children, {}, null], <title>Test</title>],
],
initialFlightData: [[initialTree, ['', children, {}, null]]],
initialCanonicalUrlParts: initialCanonicalUrl.split('/'),
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
Expand All @@ -44,9 +42,7 @@ describe('createInitialRouterState', () => {
})

const state2 = createInitialRouterState({
initialFlightData: [
[initialTree, ['', children, {}, null], <title>Test</title>],
],
initialFlightData: [[initialTree, ['', children, {}, null]]],
initialCanonicalUrlParts: initialCanonicalUrl.split('/'),
initialParallelRoutes,
location: new URL('/linking', 'https://localhost') as any,
Expand All @@ -59,7 +55,7 @@ describe('createInitialRouterState', () => {
lazyData: null,
rsc: children,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map([
Expand All @@ -81,7 +77,7 @@ describe('createInitialRouterState', () => {
prefetchRsc: null,
parallelRoutes: new Map(),
loading: null,
head: [null, <title>Test</title>],
head: null,
prefetchHead: null,
},
],
Expand All @@ -91,7 +87,7 @@ describe('createInitialRouterState', () => {
lazyData: null,
rsc: null,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function createInitialRouterState({
lazyData: null,
rsc,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
// The cache gets seeded during the first render. `initialParallelRoutes` ensures the cache from the first render is there during the second render.
parallelRoutes: isServer ? new Map() : initialParallelRoutes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const getFlightData = (): NormalizedFlightData[] => {
segment: 'about',
tree: ['about', { children: ['', {}] }],
seedData: ['about', <h1>SubTreeData Injected!</h1>, {}, null, false],
head: [null, '<title>Head Injected!</title>'],
head: null,
isHeadPartial: false,
isRootRender: false,
},
Expand All @@ -23,7 +23,7 @@ describe('fillCacheWithNewSubtreeData', () => {
lazyData: null,
rsc: null,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map(),
Expand All @@ -32,7 +32,7 @@ describe('fillCacheWithNewSubtreeData', () => {
lazyData: null,
rsc: <>Root layout</>,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map([
Expand All @@ -45,7 +45,7 @@ describe('fillCacheWithNewSubtreeData', () => {
lazyData: null,
rsc: <>Linking</>,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map([
Expand All @@ -58,7 +58,7 @@ describe('fillCacheWithNewSubtreeData', () => {
lazyData: null,
rsc: <>Page</>,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map(),
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('fillCacheWithNewSubtreeData', () => {
lazyData: null,
rsc: null,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map([
Expand All @@ -102,7 +102,7 @@ describe('fillCacheWithNewSubtreeData', () => {
lazyData: null,
rsc: <>Linking</>,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map([
Expand All @@ -116,7 +116,7 @@ describe('fillCacheWithNewSubtreeData', () => {
lazyData: null,
rsc: <>Page</>,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map(),
Expand All @@ -126,7 +126,7 @@ describe('fillCacheWithNewSubtreeData', () => {
'about',
{
lazyData: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map([
Expand All @@ -142,12 +142,7 @@ describe('fillCacheWithNewSubtreeData', () => {
parallelRoutes: new Map(),
prefetchHead: null,
loading: null,
head: [
null,
<>
<title>Head Injected!</title>
</>,
],
head: null,
},
],
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function fillCacheHelper(
rsc:
fillLazyItems || incomingSegment !== PAGE_SEGMENT_KEY ? rsc : null,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading,
parallelRoutes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
lazyData: null,
rsc: null,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
parallelRoutes: new Map(),
loading: null,
Expand All @@ -48,7 +48,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
lazyData: null,
rsc: <>Root layout</>,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map([
Expand All @@ -61,7 +61,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
lazyData: null,
rsc: <>Linking</>,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map([
Expand All @@ -74,7 +74,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
lazyData: null,
rsc: <>Page</>,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map(),
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
lazyData: null,
rsc: null,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map([
Expand All @@ -127,7 +127,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
lazyData: null,
rsc: null,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map([
Expand All @@ -152,20 +152,15 @@ describe('fillLazyItemsTillLeafWithHead', () => {
prefetchHead: null,
loading: null,
parallelRoutes: new Map(),
head: [
null,
<>
<title>About page!</title>
</>,
],
head: null,
},
],
]),
],
]),
rsc: null,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
},
],
Expand All @@ -175,7 +170,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
lazyData: null,
rsc: <>Page</>,
prefetchRsc: null,
head: [null, null],
head: null,
prefetchHead: null,
loading: null,
parallelRoutes: new Map(),
Expand Down
Loading
Loading