Skip to content

Fix Vite config plugin imports and add resolveId hook filter - #6959

Open
masenf wants to merge 2 commits into
mainfrom
claude/reflex-docs-macos-timeout-d3ucaj
Open

Fix Vite config plugin imports and add resolveId hook filter#6959
masenf wants to merge 2 commits into
mainfrom
claude/reflex-docs-macos-timeout-d3ucaj

Conversation

@masenf

@masenf masenf commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Changes To Core Features

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?

Description

This PR fixes two issues in the Vite configuration template:

  1. 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.

  2. resolveId hook optimization: Refactored the alwaysUseReactDomServerNode plugin's resolveId hook to use Vite's hook filter API. The hook now declares filter: { 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 redundant source.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 .js extension
  • test_vite_config_template_filters_react_dom_server_resolve_hook(): Verifies the resolveId hook declares the filter and handler

Both tests call vite_config_template() and assert the expected strings are present in the generated config.

https://claude.ai/code/session_01PXbBjFDmFjqYQPHdPjk4zp

Review in cubic

…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
@masenf
masenf requested a review from a team as a code owner August 27, 2026 20:24
@greptile-apps

greptile-apps Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR updates the generated Vite configuration to use an explicit JavaScript extension for the local Safari plugin and a filtered object-form resolveId hook.

  • Adds the .js extension required by Vite’s native config loader.
  • Narrows React DOM server resolution to matching module identifiers.
  • Adds regression tests and performance news fragments.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

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

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 2 files

Re-trigger cubic

@codspeed-hq

codspeed-hq Bot commented Aug 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 27 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing claude/reflex-docs-macos-timeout-d3ucaj (67ffa40) with main (a4d99be)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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.

1 participant