-
Notifications
You must be signed in to change notification settings - Fork 1.6k
expose exp hmr and sourcemap #5906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
CodSpeed Performance ReportMerging #5906 will create unknown performance changesComparing Summary
Footnotes
|
There was a problem hiding this 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 exposes two new Vite configuration options through environment variables:
VITE_EXPERIMENTAL_HMR(defaults toTrue): enables Rolldown's experimental hot module replacementVITE_SOURCEMAP(defaults toFalse): controls sourcemap generation with support for boolean and string literal values (False,True,"inline","hidden")
The implementation includes:
- New Literal type interpretation logic in the environment variable system to support union types with mixed bool/string literals
- Updated Vite config template to output the experimental HMR and sourcemap settings
- Proper type hints and documentation throughout
Confidence Score: 5/5
- This PR is safe to merge with no issues found
- The changes are well-structured and properly implemented. The Literal type interpretation logic correctly handles all value types (string, bool, int). The template correctly converts Python values to JavaScript syntax. All changes are additive with sensible defaults that maintain backward compatibility.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| reflex/compiler/templates.py | 5/5 | Added two new parameters to vite_config_template function (experimental_hmr, sourcemap) with proper type hints and documentation. Template correctly outputs JavaScript boolean and string values. |
| reflex/environment.py | 5/5 | Added Literal type interpretation support and two new environment variables (VITE_EXPERIMENTAL_HMR, VITE_SOURCEMAP). The Literal handler correctly processes string, bool, and int literal values. |
| reflex/utils/frontend_skeleton.py | 5/5 | Updated _compile_vite_config to pass the two new environment variables (experimental_hmr, sourcemap) to the vite_config_template function. |
Sequence Diagram
sequenceDiagram
participant User
participant EnvironmentVariables
participant frontend_skeleton
participant templates
participant ViteConfig
User->>EnvironmentVariables: Set VITE_EXPERIMENTAL_HMR (default: True)
User->>EnvironmentVariables: Set VITE_SOURCEMAP (default: False)
frontend_skeleton->>EnvironmentVariables: VITE_EXPERIMENTAL_HMR.get()
EnvironmentVariables-->>frontend_skeleton: bool value
frontend_skeleton->>EnvironmentVariables: VITE_SOURCEMAP.get()
EnvironmentVariables-->>frontend_skeleton: Literal[False, True, "inline", "hidden"]
frontend_skeleton->>templates: vite_config_template(experimental_hmr, sourcemap)
templates->>templates: Convert Python values to JS format
Note over templates: True/False → true/false<br/>"inline"/"hidden" → 'inline'/'hidden'
templates-->>ViteConfig: Generate vite.config.js content
ViteConfig-->>User: Apply experimental HMR and sourcemap settings
3 files reviewed, no comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
experimental hmr seems to have trouble when rx.moment is added to an app
- create a blank app
- load it in the browser
- add
rx.moment()to theindexpage TypeError: Failed to fetch dynamically imported module: http://localhost:3000/node_modules/.vite/deps/react-moment.js?v=ff45da65
No description provided.