Skip to content

suppress eval warnings#5847

Merged
adhami3310 merged 1 commit intomainfrom
suppress-eval-warnings
Oct 2, 2025
Merged

suppress eval warnings#5847
adhami3310 merged 1 commit intomainfrom
suppress-eval-warnings

Conversation

@adhami3310
Copy link
Member

No description provided.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Summary

This PR adds a targeted warning suppression mechanism to silence EVAL warnings that originate from Reflex's state management system. The change modifies the Vite build configuration in `templates.py` to add an `onwarn` handler that specifically ignores EVAL warnings when they come from files ending with 'state.js'.

Reflex's state management system intentionally uses eval for legitimate framework functionality including dynamic React component evaluation (evalReactComponent), custom script execution (_call_script), and function calls (_call_function). These are architectural design decisions that enable Reflex's dynamic component rendering and client-side code execution capabilities. However, build tools like Vite/Rollup emit warnings about eval usage due to general security concerns, creating noise in the build output for developers.

This change integrates well with the existing build system by extending the Rollup configuration options in the Vite template. The suppression is surgical - it only affects warnings from state.js files while preserving all other build warnings, maintaining the overall integrity of the build feedback system. This allows Reflex to continue using eval where architecturally necessary while providing clean build output to framework users.

Important Files Changed

Changed Files
Filename Score Overview
reflex/compiler/templates.py 5/5 Added targeted EVAL warning suppression for state.js files in Vite build configuration

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it only suppresses specific build warnings without affecting functionality
  • Score reflects a well-targeted solution that addresses legitimate eval usage while preserving other important warnings
  • No files require special attention as the change is simple and surgical

Sequence Diagram

sequenceDiagram
    participant User
    participant Compiler
    participant Vite
    participant Templates
    participant RollupWarnings

    User->>Compiler: Initiates build process
    Compiler->>Templates: Generate vite_config_template()
    Templates->>Templates: Configure rollupOptions with onwarn handler
    Note over Templates: Adds EVAL warning suppression for state.js files
    Templates-->>Compiler: Return vite config with warning suppression
    Compiler->>Vite: Pass configuration to build system
    Vite->>RollupWarnings: Process files during build
    alt EVAL warning in state.js file
        RollupWarnings->>RollupWarnings: Check warning.code === "EVAL" && warning.id.endsWith("state.js")
        RollupWarnings->>RollupWarnings: Suppress warning (return early)
    else Other warnings
        RollupWarnings->>User: Display warning via warn(warning)
    end
    Vite-->>User: Complete build process
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 2, 2025

CodSpeed Performance Report

Merging #5847 will not alter performance

Comparing suppress-eval-warnings (71c7d4b) with main (eb2667e)

Summary

✅ 8 untouched

@adhami3310 adhami3310 merged commit d381252 into main Oct 2, 2025
40 of 41 checks passed
@adhami3310 adhami3310 deleted the suppress-eval-warnings branch October 2, 2025 21:21
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