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
feat(server): lazy routers #5489
base: next
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
Diagnostics ComparisonNumbers
Timings and averages
unstable timingsUnstable
|
import { lazy } from '@trpc/server/unstable-core-do-not-import'; | ||
import { router } from './trpc.js'; | ||
|
||
const user = lazy(() => | ||
import('./routers/user.js').then((m) => { | ||
console.log('π€ lazy loaded user router'); | ||
return m.userRouter; | ||
}), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @zomars here's an example on how to use it
I've started my migration, may take a bit to get through, but I'll give an update once I'm back to testing the lazy loading |
Managed to bump tRPC to My current code changes from 308 to the tmp branch: |
Really excited to try this for supastarter. Is this supposed to work on edge functions too? |
Big apologies @KATT , I tried this again after rebasing on my main branch, and it seems to have been something on my end that was broken. It's working now, no issues from my entire application. Good job! ππ |
Does it make a difference for the cold starts? |
# Conflicts: # .github/workflows/release-tmp.yml # pnpm-lock.yaml
# Conflicts: # pnpm-lock.yaml
β¦issues/4129-lazy-routers
Closes #4129
π― Changes
You can test this by installing
@trpc/server@tmp
/@trpc/client@tmp
/ .. etcβ Checklist