-
-
Notifications
You must be signed in to change notification settings - Fork 234
Description
Related plugins
Describe the bug
Switching from the normal @vitejs/plugin-react in vite.config.ts to the @vitejs/plugin-react-oxc plugin and not changing anything else makes the code in dev/watch mode crash with Uncaught ReferenceError: $RefreshReg$ is not defined if you're using modules from a different context than the main frame (e.g. a Worker). If I look at the code that triggered it, it's usually something like this:
export const MODULE_TYPE_TO_DOMAIN = {
something: "SomethingElse",
// ...
};
export const MODULE_DOMAIN_TO_TYPE = swapKeysAndValues(MODULE_TYPE_TO_DOMAIN);
_c = MODULE_DOMAIN_TO_TYPE;
// ...
var _c;
$RefreshReg$(_c, "MODULE_DOMAIN_TO_TYPE");So that $RefreshReg$ is not available inside a Worker. Which makes sense. What doesn't make sense is that the plugin is trying to consider the MODULE_DOMAIN_TO_TYPE value a component.
Reproduction
N/A
Steps to reproduce
I tried to create a reproduction on StackBlitz but it didn't work to set up the oxc versions of Vite+Rolldown+vite-plugin-react with overrides for Vite.
The repro would be to import a shared library module from a Worker.
System Info
System:
OS: macOS 15.5
CPU: (16) arm64 Apple M3 Max
Memory: 2.49 GB / 128.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.2.0 - /opt/homebrew/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 11.3.0 - /opt/homebrew/bin/npm
bun: 1.2.5 - ~/.bun/bin/bun
Browsers:
Chrome: 137.0.7151.119
Safari: 18.5Used Package Manager
bun
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.