fix(client): move global ORPCError constructors registration to static block for better bundler compatibility#1574
Conversation
…c block for better bundler compatibility
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughConstructor registration logic for cross-dependency-graph ChangesError Constructor Static Initialization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request moves the registration of ORPCError in globalORPCErrorConstructors into a static initialization block inside the ORPCError class to prevent bundlers from tree-shaking it when "sideEffects": false is configured. The reviewer suggests keeping the initialization of globalORPCErrorConstructors as a module-level const instead of a mutable let variable, keeping the static block focused solely on registering the class.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR updates @orpc/client’s ORPCError global-constructor registration so it runs inside the ORPCError class definition (via a static {} initialization block) rather than as module-level side effects, improving compatibility with tree-shaking bundlers when "sideEffects": false.
Changes:
- Moved global WeakSet registration (via
Symbol.for+globalThis) intoORPCError’sstatic {}block. - Removed module-level registration statements and replaced them with a module-scoped
letassigned during class initialization.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — moves the global ORPCError constructor registration from module-level into a static {} block so that bundlers with "sideEffects": false cannot tree-shake the registration away.
- Move
WeakSetinit and.add(ORPCError)intostatic {}— the side-effect is now bound to the class definition, preventing tree-shaking while keeping identical runtime behavior.
DeepSeek Pro | 𝕏
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/client
@orpc/contract
@orpc/experimental-durable-iterator
@orpc/hey-api
@orpc/interop
@orpc/json-schema
@orpc/nest
@orpc/openapi
@orpc/openapi-client
@orpc/otel
@orpc/experimental-pino
@orpc/experimental-publisher
@orpc/experimental-publisher-durable-object
@orpc/experimental-ratelimit
@orpc/react
@orpc/react-query
@orpc/experimental-react-swr
@orpc/server
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-aws-lambda
@orpc/standard-server-fastify
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/standard-server-peer
@orpc/svelte-query
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |

Summary by CodeRabbit