Skip to content

add option to disable hmr#5745

Merged
adhami3310 merged 4 commits into
mainfrom
add-option-to-disable-hmr
Aug 28, 2025
Merged

add option to disable hmr#5745
adhami3310 merged 4 commits into
mainfrom
add-option-to-disable-hmr

Conversation

@adhami3310

Copy link
Copy Markdown
Member

No description provided.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Greptile Summary

This PR adds the ability to disable Hot Module Replacement (HMR) in Vite through a new environment variable VITE_HMR. The changes span three files to implement this feature:

  1. Environment Configuration (reflex/environment.py): Adds a new boolean environment variable VITE_HMR that defaults to True, maintaining backward compatibility while allowing users to disable HMR by setting VITE_HMR=false.

  2. Frontend Skeleton (reflex/utils/frontend_skeleton.py): Updates the _compile_vite_config function to read the VITE_HMR environment variable and pass it to the Vite configuration template.

  3. Template System (reflex/compiler/templates.py): Modifies the vite_config_template function to accept an hmr boolean parameter and outputs the appropriate JavaScript boolean value in the generated vite.config.js file.

This change follows Reflex's established pattern of using environment variables for development-time configuration. It integrates cleanly with the existing template system and allows developers to control HMR behavior without code modifications. The feature is particularly useful for debugging scenarios, performance testing, or when working with libraries that don't support HMR (such as WebAssembly modules).

Confidence score: 4/5

  • This PR is safe to merge with low risk as it's a simple configuration addition
  • Score reflects straightforward implementation following established patterns with minimal surface area for bugs
  • Pay close attention to the template rendering logic in reflex/compiler/templates.py to ensure proper JavaScript boolean output

3 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

Comment thread reflex/compiler/templates.py Outdated
}},
}},
}},
hmr: {"true" if hmr else "false"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

logic: The hmr field placement in the Vite config structure seems incorrect. In Vite, HMR is typically configured under server.hmr, not as a top-level property.

@codspeed-hq

codspeed-hq Bot commented Aug 28, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #5745 will not alter performance

Comparing add-option-to-disable-hmr (5cf2517) with main (817b8b4)

Summary

✅ 8 untouched benchmarks

reactRouter(),
safariCacheBustPlugin(),
],
].concat({"[fullReload()]" if force_full_reload else "[]"}),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why concat and not just {"fullReload()" if force_full_reload else ""} in the plugins list?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

not a strong reason i just wanted it to be at least in theory extendable but it's not different either way

@adhami3310 adhami3310 merged commit 76457c4 into main Aug 28, 2025
41 checks passed
@adhami3310 adhami3310 deleted the add-option-to-disable-hmr branch August 28, 2025 22:35
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