-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix client chunk loading encoding for dynamic route (#57960)
We had added encoding the client component assets loaded from RSC manifest that we need to encode them to make sure when they're loaded on server and sent to client, the client will receive the encoded one. But the override of the webpack chunk loading method could be loaded later than react related chunks, that when client component is loaded first (e.g. `next/script`) and it triggers react loaded ealier than the overriding. Then the chunk could be encoded incorrectly. Discussed with @gnoff and put this out as the 1st step solution to ensure the order. in the future we can try to get rid of the encoding by providing safer url Fixes #57829
- Loading branch information
Showing
6 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
8 changes: 8 additions & 0 deletions
8
test/e2e/app-dir/navigation/app/router/dynamic-gsp/[slug]/error.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Add error.js to let this file be added to the flight manifest, | ||
// and get url encoded, and load through react RSC renderer. | ||
|
||
'use client' | ||
|
||
export default function Error() { | ||
return <div>My Error</div> | ||
} |
7 changes: 7 additions & 0 deletions
7
test/e2e/app-dir/navigation/app/router/dynamic-gsp/[slug]/page.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Page({ params }) { | ||
return <div id="dynamic-gsp-content">{'slug:' + params.slug}</div> | ||
} | ||
|
||
export function generateStaticParams() { | ||
return [{ slug: '1' }, { slug: '2' }, { slug: '3' }] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use client' | ||
|
||
import Script from 'next/script' | ||
import { useRouter } from 'next/navigation' | ||
|
||
export default function Page() { | ||
const router = useRouter() | ||
return ( | ||
<div> | ||
<button | ||
id="dynamic-link" | ||
onClick={() => router.push('/router/dynamic-gsp/1/')} | ||
> | ||
Test routing | ||
</button> | ||
{/* adding a script here to make sure app internals might execute earlier */} | ||
<Script | ||
src="https://connect.facebook.net/en_US/sdk.js" | ||
strategy="beforeInteractive" | ||
/> | ||
</div> | ||
) | ||
} |
This file contains 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