Fix Vite config plugin imports and add resolveId hook filter - #6959
Open
masenf wants to merge 2 commits into
Open
Fix Vite config plugin imports and add resolveId hook filter#6959masenf wants to merge 2 commits into
masenf wants to merge 2 commits into
Conversation
…extension The generated vite.config.js registered `alwaysUseReactDomServerNode` as an enforce: "pre" plugin with an unfiltered resolveId hook, so rolldown called into JS for every import in the module graph (15865 calls on the docs build) just to redirect a single specifier. Declaring the documented hook filter lets rolldown skip the call entirely unless the specifier contains "react-dom/server". Also give the local safari cachebust plugin import a file extension: Vite's native config loader cannot resolve extensionless relative imports and warns about it today. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PXbBjFDmFjqYQPHdPjk4zp
Contributor
Greptile SummaryThe PR updates the generated Vite configuration to use an explicit JavaScript extension for the local Safari plugin and a filtered object-form
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/reflex-base/src/reflex_base/compiler/templates.py | Updates the generated Vite plugin import and converts the React DOM resolver to a filtered hook while retaining the importer guard. |
| tests/units/utils/test_utils.py | Adds assertions covering the explicit plugin extension and filtered resolve hook output. |
| news/6959.performance.md | Documents the generated-config compatibility and performance improvements. |
| packages/reflex-base/news/6959.performance.md | Records the package-level Vite configuration changes and their performance rationale. |
Reviews (2): Last reviewed commit: "Drop the expository comment from the gen..." | Re-trigger Greptile
Merging this PR will not alter performance
Comparing Footnotes
|
…ents Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PXbBjFDmFjqYQPHdPjk4zp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
Changes To Core Features
Description
This PR fixes two issues in the Vite configuration template:
Plugin import extension: Changed the local plugin import from
"./vite-plugin-safari-cachebust"to"./vite-plugin-safari-cachebust.js"to include the file extension. Vite's native config loader (planned to become the default) cannot resolve extensionless relative imports and warns about them.resolveId hook optimization: Refactored the
alwaysUseReactDomServerNodeplugin'sresolveIdhook to use Vite's hook filter API. The hook now declaresfilter: { id: /react-dom\/server/ }to prevent the hook from being called for every import in the module graph. Without this filter, rolldown calls the hook for tens of thousands of imports, which dominates build time on large applications. The redundantsource.includes("react-dom/server")check was removed since the filter now ensures only matching imports reach the handler.Test Plan
Added two new unit tests in
tests/units/utils/test_utils.py:test_vite_config_template_imports_plugin_with_extension(): Verifies the plugin import includes the.jsextensiontest_vite_config_template_filters_react_dom_server_resolve_hook(): Verifies the resolveId hook declares the filter and handlerBoth tests call
vite_config_template()and assert the expected strings are present in the generated config.https://claude.ai/code/session_01PXbBjFDmFjqYQPHdPjk4zp