Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Use direct process.env.NODE_ENV and process.env.LOG_LEVEL access instead of dynamic process.env[key]
  • Fixes client-side debug logs appearing in production (webpack couldn't inline the dynamic access)

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 21, 2026 5:59pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 21, 2026

Greptile Summary

Replaced dynamic process.env[key] pattern with direct property access (process.env.NODE_ENV and process.env.LOG_LEVEL) to enable webpack's dead code elimination during bundling.

  • Changed getEnvVar(key) helper to separate getNodeEnv() and getLogLevel() functions with direct env access
  • Removed generic environment variable accessor that prevented webpack from inlining values
  • Webpack can now properly eliminate debug logs in production client bundles
  • Removed redundant comments that simply described code behavior

Confidence Score: 5/5

  • Safe to merge - focused bug fix with correct implementation
  • The changes correctly address the webpack inlining issue by replacing dynamic property access with static property access. The refactoring maintains identical runtime behavior while enabling build-time optimizations. No breaking changes or edge cases introduced.
  • No files require special attention

Important Files Changed

Filename Overview
packages/logger/src/index.ts Replaced dynamic process.env[key] access with direct process.env.NODE_ENV and process.env.LOG_LEVEL access to enable webpack dead code elimination

Sequence Diagram

sequenceDiagram
    participant App as Application Code
    participant Logger as Logger Class
    participant EnvFuncs as Environment Functions
    participant ProcessEnv as process.env
    participant Webpack as Webpack/Bundler

    Note over App,Webpack: Build Time
    Webpack->>ProcessEnv: Check process.env.NODE_ENV (direct access)
    ProcessEnv-->>Webpack: "production"
    Webpack->>Webpack: Inline value & eliminate dead code
    Note over Webpack: Removes debug logs in production build

    Note over App,Webpack: Runtime
    App->>Logger: createLogger("MyModule")
    Logger->>EnvFuncs: getNodeEnv()
    EnvFuncs->>ProcessEnv: process.env.NODE_ENV (direct access)
    ProcessEnv-->>EnvFuncs: "production"
    EnvFuncs-->>Logger: "production"
    
    Logger->>EnvFuncs: getLogLevel()
    EnvFuncs->>ProcessEnv: process.env.LOG_LEVEL (direct access)
    ProcessEnv-->>EnvFuncs: undefined
    EnvFuncs-->>Logger: undefined
    
    Logger->>Logger: getMinLogLevel() -> ERROR
    Logger->>Logger: shouldLog(DEBUG) -> false (client-side)
    Note over Logger: Production client logs blocked
Loading

@waleedlatif1 waleedlatif1 merged commit ea49640 into staging Jan 21, 2026
11 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/xustand branch January 21, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants