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

perf: layout persistence and reduced bundle size #18889

Merged
merged 8 commits into from
Jan 27, 2025

Conversation

hbjORbj
Copy link
Contributor

@hbjORbj hbjORbj commented Jan 25, 2025

What does this PR do?

  • Affected routes: /event-types, /bookings/[status], /availability
  • Creates a route group, (main-nav), and layout.tsx file inside with Shell
  • Previously, each route was wrapping itself with Shell individually in its client component
  • Thanks to the newly added layout file, we now render layout once, and it gets cached / reused across these routes (hence better speed)
  • Bundle size also gets smaller:
    e.g.,
Before:
/event-types (100KB) = Route code (70KB) + Shell (30KB)  
/bookings (110KB) = Route code (80KB) + Shell (30KB)

After:
layout.js (30KB) - Shared
/event-types (70KB) = Route code only
/bookings (80KB) = Route code only
  • We need to move other main-nav pages to this route group (in separate PRs)

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • N/A - I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Please use the latest Vercel preview and test please 🙏.

@graphite-app graphite-app bot requested a review from a team January 25, 2025 15:38
Copy link

vercel bot commented Jan 25, 2025

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

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Jan 27, 2025 10:46am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Jan 27, 2025 10:46am

@keithwillcode keithwillcode added consumer core area: core, team members only labels Jan 25, 2025
@dosubot dosubot bot added the performance area: performance, page load, slow, slow endpoints, loading screen, unresponsive label Jan 25, 2025
Copy link

graphite-app bot commented Jan 25, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (01/25/25)

1 reviewer was added to this PR based on Keith Williams's automation.

{props.afterHeading && <>{props.afterHeading}</>}

<div className={classNames(props.flexChildrenContainer && "flex flex-1 flex-col")}>
{props.children}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

children is here

: "pwa:bottom-[max(7rem,_calc(5rem_+_env(safe-area-inset-bottom)))] fixed bottom-20 z-40 ltr:right-4 rtl:left-4 md:z-auto md:ltr:right-0 md:rtl:left-0",
"flex-shrink-0 [-webkit-app-region:no-drag] md:relative md:bottom-auto md:right-auto"
)}>
{props.CTA}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CTA


// Copied from `ShellMain` but with a different `ShellMainAppDirBackButton` import
// for client/server component separation
export function ShellMainAppDir(props: LayoutProps) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copied from ShellMain component inside Shell.tsx.
I was able to turn this into RSC by extracting the back button into a separate client component ShellMainAppDirBackButton.tsx.

Comment on lines +33 to +34
heading={t("availability")}
subtitle={t("configure_availability")}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fyi, title or description are not needed. They are passed to Shell.tsx for SEO purposes, but they aren't used anywhere in ShellMain. Also, we turn withoutSeo={true} anyways since App Router handles Metadata already

@@ -942,8 +941,36 @@ const InfiniteScrollMain = ({
);
};

export const EventTypesCTA = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

extracted from CTA={...} in Main Page below

@@ -195,14 +194,11 @@ type PageProps = {
currentOrg?: Awaited<ReturnType<typeof OrganizationRepository.findCurrentOrg>> | null;
};

export default function AvailabilityPage({ currentOrg }: PageProps) {
export const AvailabilityCTA = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted from CTA={...} from Main page below

@@ -19,14 +20,23 @@ export const generateMetadata = async () =>

const Page = async ({ params, searchParams }: PageProps) => {
const context = buildLegacyCtx(headers(), cookies(), params, searchParams);
const session = await getServerSessionForAppDir();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this makes initial RSC fetch so slow, check https://app.campsite.com/cal/posts/58hm2drix99s

Copy link
Contributor

github-actions bot commented Jan 25, 2025

E2E results are ready!

PeerRich
PeerRich previously approved these changes Jan 25, 2025
Copy link
Contributor

@Udit-takkar Udit-takkar left a comment

Choose a reason for hiding this comment

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

Unit tests failing and merge conflicts

@hbjORbj hbjORbj merged commit ee31633 into main Jan 27, 2025
38 checks passed
@hbjORbj hbjORbj deleted the perf/layout-persistence-and-reduced-bundle-size branch January 27, 2025 11:08
MuhammadAimanSulaiman pushed a commit to hit-pay/cal.com that referenced this pull request Feb 25, 2025
* create /(main-nav)/layout.tsx file that uses Shell

* Add ShellMainAppDir that clones ShellMain but with client/server separation

* event-types, availability, bookings

* update pagesAndRewritePaths logic

* fix

---------

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consumer core area: core, team members only performance area: performance, page load, slow, slow endpoints, loading screen, unresponsive ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants