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

match next.js client side routing (buildManifest rewrites & devPagesManifest HMR) #3701

Merged
merged 8 commits into from Feb 9, 2023

Conversation

ForsakenHarmony
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Feb 8, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
examples-basic-web 🔄 Building (Inspect) Feb 9, 2023 at 9:15PM (UTC)
9 Ignored Deployments
Name Status Preview Comments Updated
examples-cra-web ⬜️ Ignored (Inspect) Feb 9, 2023 at 9:15PM (UTC)
examples-designsystem-docs ⬜️ Ignored (Inspect) Feb 9, 2023 at 9:15PM (UTC)
examples-kitchensink-blog ⬜️ Ignored (Inspect) Feb 9, 2023 at 9:15PM (UTC)
examples-native-web ⬜️ Ignored (Inspect) Feb 9, 2023 at 9:15PM (UTC)
examples-nonmonorepo ⬜️ Ignored (Inspect) Feb 9, 2023 at 9:15PM (UTC)
examples-svelte-web ⬜️ Ignored (Inspect) Feb 9, 2023 at 9:15PM (UTC)
examples-tailwind-web ⬜️ Ignored (Inspect) Feb 9, 2023 at 9:15PM (UTC)
examples-vite-web ⬜️ Ignored (Inspect) Feb 9, 2023 at 9:15PM (UTC)
turbo-site ⬜️ Ignored (Inspect) Visit Preview Feb 9, 2023 at 9:15PM (UTC)

@ForsakenHarmony
Copy link
Member Author

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@ForsakenHarmony ForsakenHarmony changed the title add rewrites to buildManifest & serve it separately match next.js client side routing (buildManifest rewrites & devPagesManifest HMR) Feb 8, 2023
@ForsakenHarmony ForsakenHarmony marked this pull request as ready for review February 8, 2023 21:26
@ForsakenHarmony ForsakenHarmony requested a review from a team as a code owner February 8, 2023 21:26
@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2023

⚠️ CI failed ⚠️

The following steps have failed in CI:

  • Turbopack Rust tests (mac/win, non-blocking)

See workflow summary for details

@@ -13,6 +14,12 @@ const loadNextConfig = async (silent) => {

nextConfig.generateBuildId = await nextConfig.generateBuildId?.();

const customRoutes = await loadCustomRoutes(nextConfig);
Copy link
Member

Choose a reason for hiding this comment

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

We should be creating this on the Next.js side so that we don't have to call loadCustomRoutes twice x-ref: https://github.com/vercel/next.js/blob/7654d7bc2d95c8b3dc18cf5e94695375c733e74c/packages/next/src/server/lib/route-resolver.ts#L28

Copy link
Member Author

Choose a reason for hiding this comment

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

We load the whole config a second time to call the route resolver right now unfortunately

Copy link
Member Author

Choose a reason for hiding this comment

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

@ijjk is there any chance we could get something implemented on the next.js side that would allow the whole config to be serialized to JSON (after loading custom routes probably)?

crates/next-core/js/src/entry/config/next.js Show resolved Hide resolved

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TraceRawVcs)]
#[serde(rename_all = "camelCase")]
pub struct Redirect {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to implement all of these if we only care about Rewrite?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably not 🤷‍♀️
But maybe we can pass the serialized version to the next.js router

crates/next-core/src/manifest.rs Outdated Show resolved Hide resolved
@ForsakenHarmony ForsakenHarmony force-pushed the hrmny/web-515-match-nexts-client-side-routing branch from ba9e259 to e9294f2 Compare February 9, 2023 19:44
@vercel vercel deleted a comment from github-actions bot Feb 9, 2023
@vercel vercel deleted a comment from github-actions bot Feb 9, 2023
@vercel vercel deleted a comment from github-actions bot Feb 9, 2023
CatchAll,
}

impl From<&str> for PageSortKey {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can bound the lifetime of PageSortKey by the &str, so we don't need to clone into a String?

Suggested change
impl From<&str> for PageSortKey {
impl<'a> From<&'a str> for PageSortKey<'a> {

Copy link
Member Author

Choose a reason for hiding this comment

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

I was assuming the &str wouldn't survive after returning out of the sort_by_cached_key lambda function, but let me check

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah

error: lifetime may not live long enough
  --> crates\next-core\src\manifest.rs:77:39
   |
77 |         routes.sort_by_cached_key(|s| s.split('/').map(PageSortKey::from).collect::<Vec<_>>());
   |                                    -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2`
   |                                    ||
   |                                    |return type of closure is Vec<PageSortKey<'2>>
   |                                    has type `&'1 std::string::String`

@ForsakenHarmony ForsakenHarmony merged commit 66eb2e5 into main Feb 9, 2023
@ForsakenHarmony ForsakenHarmony deleted the hrmny/web-515-match-nexts-client-side-routing branch February 9, 2023 21:37
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2023

Benchmark for 6eab4b9

Test Base PR % Significant %
bench_hmr_to_eval/Turbopack CSR/1000 modules 8331.80µs ± 148.11µs 7613.59µs ± 61.85µs -8.62% -3.71%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9116.41µs ± 66.70µs 8867.10µs ± 111.66µs -2.73%
bench_hmr_to_commit/Turbopack RCC/1000 modules 8949.22µs ± 106.82µs 8846.13µs ± 77.98µs -1.15%
bench_hmr_to_commit/Turbopack RSC/1000 modules 476.45ms ± 3.16ms 480.75ms ± 1.79ms +0.90%
bench_hmr_to_commit/Turbopack SSR/1000 modules 9182.11µs ± 109.27µs 9275.15µs ± 107.49µs +1.01%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8331.80µs ± 148.11µs 7613.59µs ± 61.85µs -8.62% -3.71%
bench_hmr_to_eval/Turbopack RCC/1000 modules 8198.90µs ± 81.04µs 8143.37µs ± 112.42µs -0.68%
bench_hmr_to_eval/Turbopack SSR/1000 modules 8137.28µs ± 74.75µs 8048.96µs ± 101.24µs -1.09%
bench_hydration/Turbopack RCC/1000 modules 4129.36ms ± 9.47ms 4126.94ms ± 15.17ms -0.06%
bench_hydration/Turbopack RSC/1000 modules 3690.71ms ± 14.10ms 3731.69ms ± 11.81ms +1.11%
bench_hydration/Turbopack SSR/1000 modules 3608.69ms ± 20.71ms 3582.47ms ± 24.17ms -0.73%
bench_startup/Turbopack CSR/1000 modules 2727.43ms ± 10.09ms 2718.64ms ± 11.29ms -0.32%
bench_startup/Turbopack RCC/1000 modules 2494.30ms ± 9.20ms 2508.95ms ± 7.55ms +0.59%
bench_startup/Turbopack RSC/1000 modules 2374.27ms ± 7.19ms 2387.57ms ± 10.90ms +0.56%
bench_startup/Turbopack SSR/1000 modules 2064.53ms ± 2.35ms 2070.69ms ± 1.70ms +0.30%

jridgewell pushed a commit to vercel/next.js that referenced this pull request Mar 10, 2023
sokra pushed a commit to vercel/next.js that referenced this pull request Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants