-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
@vitejs/plugin-react - Inconsistent vendor reference #5608
Comments
Issue #5642 describing similar problem mentions updating to |
I'm getting |
Even with newer |
No it would not! I'm trying anything that comes in my mind, ranged from upgrading material-ui-picker library to using rollup or commonJs options to transform the code, or suppress the issue. So far nothing worked. |
It worked at last!! 2- then I added an alias for
3- then added 4- and finally added globals to build => rollupOptions => output => globals :
and the error is gone! |
I've updated the sample repo |
Confirmed same issue ("React is not defined") for @material-ui/pickers using plugin-react 1.1.0 in production builds. |
@nabc's solution worked for me! What worked here was the 2nd step |
Can confirm that the issue still persists on edit: we can also just pass vite/packages/plugin-react/src/index.ts Lines 24 to 28 in 8bdb184
|
I tried the But as most people here resolved their problem with one of the provided solutions and I replaced the |
Describe the bug
When using @vitejs/react-plugin with
react-custom-scrollbars-2
(but other packages have similar issues - can be found here: alloc/vite-react-jsx#10), reference to react is not transformed in all locations the same way.react-custom-scrollbars-2
imports react utility functions:import { Component, createElement, cloneElement } from 'react';
https://github.com/RobPethick/react-custom-scrollbars-2/blob/master/src/Scrollbars/index.js#L3
In the library output, it looks like this (emphasis on the
_react.
:But after vite build it is changed to:
Every occurence but one is using the
_react3
variable, onlyReact.createElement
is remaining - which leads toUncaught ReferenceError: React is not defined
.Reproduction
yarn
yarn run build
yarn run serve
This does not happen in dev mode. The test repo is using manual chunks, but I have not found any important difference when using them differently/not using them at all.
System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: