Production Stubs
React Trace is a development-only tool. Every package ships conditional exports that resolve to zero-cost no-op stubs in production builds.
How it works
Each package's package.json uses the exports field with development, production, and default conditions:
- Development — full inspector implementation
- Production — all exports are no-ops (empty components, identity functions, constant values)
- Default — falls back to the full implementation for tools that don't resolve conditions
What gets stubbed
In production mode:
- The
Tracecomponent rendersnull - All hooks return static defaults (
null,false, empty functions) - All plugin factories return inert
TracePluginobjects - All utilities become identity functions or constants
The result is zero runtime overhead — no inspector UI, no event listeners, no source-map resolution. Tree-shaking removes the dead code entirely.
Adding stubs to new packages
When adding a new public export to any @react-trace/* package, you must mirror it in src/index.prod.ts:
- Components — export a function returning
null - Hooks — export a function returning the appropriate default
- Types — re-export with
export type - Constants — export the same constant value
This ensures production builds never pull in the development implementation.