fix: prevent process.env access from crashing browser builds - #812
fix: prevent process.env access from crashing browser builds#812Kanhaiyaarora wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe logging utility now guards access to ChangesDebug logging guard
Estimated code review effort: 2 (Simple) | ~5 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
lib/utils/log.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. 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 |
Summary
This PR prevents runtime errors in browser environments by safely checking for the existence of
processbefore accessingprocess.env.DRAGGABLE_DEBUG.Problem
The current implementation directly accesses
process.env.DRAGGABLE_DEBUG:In browser environments where
processis not defined (e.g., Vite without a process polyfill), this can lead to runtime errors and affect components that depend onreact-draggable.Solution
Added a guard to ensure
processexists before accessingprocess.env:This preserves the existing debug logging behavior while preventing errors in environments where
processis unavailable.Testing
DRAGGABLE_DEBUGis enabled.Summary by CodeRabbit
processobject.