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: do not import from @calcom/lib/server barrel file #19579

Merged
merged 2 commits into from
Feb 26, 2025

Conversation

hbjORbj
Copy link
Contributor

@hbjORbj hbjORbj commented Feb 26, 2025

What does this PR do?

Context: I loaded a route that had import { getServerErrorFromUnknown } from "@calcom/lib/server". This loaded getLuckyUser (which is exported from "@calcom/lib/server"), which was pulling in Calendar Manager, etc:

../../packages/lib/server/index.ts
../../packages/lib/server/getLuckyUser.ts
../../packages/core/CalendarManager.ts
../../packages/app-store/_utils/getCalendar.ts
../../packages/app-store/index.ts
../../packages/app-store/exchange***endar/index.ts
../../packages/app-store/exchange***endar/lib/index.ts
../../packages/app-store/exchange***endar/lib/CalendarService.ts
../../node_modules/@ewsjs/xhr/dist/index.js
../../node_modules/@ewsjs/ntlm-client/lib/index.js

This poses 2 problems: (1) it prevents us from using Edge config for running routes or apis because these unnecessarily pulled dependencies usually depend on other deps that run on Node only (2) unnecessary load of irrelevant packages

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 to test

Screenshot 2025-02-26 at 4 01 01 PM
  • No more imports from this barrel file
  1. Search for import { defaultHandler } from "@calcom/lib/server and you will see it's all from "@calcom/lib/server/defaultHandler
  2. Search for import { getRoutedUrl } from "@calcom/lib/server and you will see it's all from "@calcom/lib/server/getRoutedUrl
  3. Search for import { getLuckyUser } from "@calcom/lib/server and you will see it's all from "@calcom/lib/server/getLuckyUser
  4. Search for import { getServerErrorFromUnknown } from "@calcom/lib/server and you will see it's all from "@calcom/lib/server/getServerErrorFromUnknown
  5. Search for import { defaultResponder } from "@calcom/lib/server and you will see it's all from "@calcom/lib/server/defaultResponder
  6. Search for import { getTranslation } from "@calcom/lib/server and you will see it's all from "@calcom/lib/server/i18n
  7. Search for checkDurationLimits and checkDurationLimit, and you will see it's all from "@calcom/lib/server/checkDurationLimits
  8. Search for checkBookingLimits and checkBookingLimit, and you will see it's all from "@calcom/lib/server/checkBookingLimits

@hbjORbj hbjORbj requested review from a team as code owners February 26, 2025 15:55
@hbjORbj hbjORbj marked this pull request as draft February 26, 2025 15:55
@graphite-app graphite-app bot requested a review from a team February 26, 2025 15:55
@keithwillcode keithwillcode added consumer core area: core, team members only labels Feb 26, 2025
@hbjORbj hbjORbj changed the title perf: do not import from barrel perf: do not import from `@calcom/lib/server" barrel file Feb 26, 2025
@hbjORbj hbjORbj changed the title perf: do not import from `@calcom/lib/server" barrel file perf: do not import from @calcom/lib/server barrel file Feb 26, 2025
@dosubot dosubot bot added the performance area: performance, page load, slow, slow endpoints, loading screen, unresponsive label Feb 26, 2025
Copy link

vercel bot commented Feb 26, 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 Feb 26, 2025 8:18pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Feb 26, 2025 8:18pm

Copy link

graphite-app bot commented Feb 26, 2025

Graphite Automations

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

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

Copy link
Contributor

E2E results are ready!

@hbjORbj hbjORbj marked this pull request as ready for review February 26, 2025 21:05
@keithwillcode keithwillcode enabled auto-merge (squash) February 26, 2025 21:10
@keithwillcode keithwillcode merged commit d796002 into main Feb 26, 2025
42 checks passed
@keithwillcode keithwillcode deleted the perf/do-not-import-from-barrel branch February 26, 2025 21:10
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.

2 participants