-
-
Notifications
You must be signed in to change notification settings - Fork 237
fix(plugin-react): resolve base-prefixed refresh runtime in bundledDev #1121
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,5 @@ | ||||||||
| import path from 'node:path' | ||||||||
| import { runtimePublicPath } from '@vitejs/react-common' | ||||||||
| import { type Plugin, rolldown } from 'rolldown' | ||||||||
| import { expect, test } from 'vitest' | ||||||||
| import pluginReact, { type Options } from '../src/index.ts' | ||||||||
|
|
@@ -21,6 +22,34 @@ test('HMR related code should not be included when using rolldown with babel plu | |||||||
| expect(output[0].code).not.toContain('import.meta.hot') | ||||||||
| }) | ||||||||
|
|
||||||||
| test('resolves base-prefixed refresh runtime id in bundledDev mode', () => { | ||||||||
| const plugins = pluginReact() | ||||||||
|
|
||||||||
| const reactBabelPlugin = plugins.find( | ||||||||
| (plugin) => plugin.name === 'vite:react-babel', | ||||||||
| ) | ||||||||
|
||||||||
| ) | |
| ) | |
| expect(reactBabelPlugin).toBeDefined() |
Copilot
AI
Feb 25, 2026
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.
The test hardcodes '/ui' instead of deriving it from the base value set on line 32. For better maintainability, consider constructing the test input consistently: either use '/ui/'.slice(0, -1) + runtimePublicPath or store the base in a variable and reuse it. This ensures the test remains correct if the base value is changed.
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.
The resolve runtime plugin should be conditionally included only when
isRolldownViteis true, similar to how other bundledDev-specific plugins are included on lines 555-557. While the plugin has internal guards that prevent it from running in non-rolldown contexts, it's more consistent and efficient to only include it when it can actually be used. Consider moving this line inside the conditional spread on line 556.