-
Notifications
You must be signed in to change notification settings - Fork 5
Uncaught ReferenceError: React is not defined
in production build
#10
Comments
Yes I am experiencing the same issue exactly with |
I created the following issue as well, because I am not certain who is causing it. mui/material-ui#27473 |
Can you see if this issue is fixed by using |
Unfortunately the issue persists there too. |
Everything seems to be transpiled correctly when processing the vendor-bundle, except the React.Fragment reference. Final code:
|
I have the same issue using
In the output generated it creates variable |
@Pernick
I tried any solution ways in other similar issue(in material-ui vite rollup vitejs/plugin-react ....) but it not work. then... I find a suspicious point in the plugin
this RegE can not match the I try this vite config(resolve.alias):
to replace Maybe your problems could use the same way like this. Just pay attention to the vitejs/plugin-react(if you use...) |
I get this same issue, but in my dev build... |
Im having this issue as well... |
I ran into the same issue. Like others, I suspect the culprit package is @material-ui/pickers. I was able to fix this by choosing the "classic" option for the jsxRuntime in the react plugin definition. I'll probably upgrade to material v5 at some point. That seems to fix other issues I have been having. The fix
My deps for reference:
|
Hi guys, we also ran into this issue with @chakra-ui and chakra-ui-steps. the failing example is here. if anyone can provide some guidance would be great. edit after couple of hours of playing with it, found config that actually works, but would love to no why is @vitejs/react-plugin not needed for production build. Also how to identify library that is not supported by vite.
|
I had the same problem, after migrating from CRA to Vite, still unable to solved: tsconfig.json {
"compilerOptions": {
"baseUrl": ".",
"target": "ESNext",
"lib": ["dom", "dom.iterable", "esnext"],
"types": ["vite/client"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src", "vite.config.ts"]
}
vite.config.ts import { defineConfig } from 'vite';
import { resolve } from 'path';
import react from '@vitejs/plugin-react';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
build: {
outDir: 'build'
},
plugins: [react()],
resolve: {
alias: [
{
// This template is using src/ imports, so we changed it
find: 'src',
replacement: resolve(__dirname, 'src')
}
]
}
})); package.json {
"name": "react-admin-dashboard",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build:container": "cross-env NODE_OPTIONS=--max_old_space_size=10000 tsc && vite build",
"serve": "vite preview",
"lint": "eslint .",
"lint:fix": "eslint --fix",
"format": "prettier --write \"./**/*.{ts,tsx,js,jsx,json}\" --config ./.prettierrc",
"clean": "rimraf ./build"
},
"dependencies": {
"@auth0/auth0-spa-js": "1.19.2",
"@emotion/react": "11.6.0",
"@emotion/styled": "11.6.0",
"@fullcalendar/core": "5.10.1",
"@fullcalendar/daygrid": "5.10.1",
"@fullcalendar/interaction": "5.10.1",
"@fullcalendar/list": "5.10.1",
"@fullcalendar/react": "5.10.1",
"@fullcalendar/timegrid": "5.10.1",
"@mui/core": "^5.0.0-alpha.54",
"@mui/icons-material": "5.1.1",
"@mui/lab": "5.0.0-alpha.55",
"@mui/material": "5.1.1",
"@mui/styles": "5.1.1",
"@reduxjs/toolkit": "1.6.2",
"@types/jsonwebtoken": "8.5.5",
"@types/nprogress": "0.2.0",
"@types/numeral": "2.0.2",
"@types/react": "17.0.29",
"@types/react-beautiful-dnd": "13.1.2",
"@types/react-dom": "17.0.9",
"@types/react-gauge-chart": "0.3.1",
"@types/react-redux": "7.1.19",
"@types/react-router-dom": "5.3.1",
"@types/react-simple-maps": "1.0.6",
"@types/uuid": "8.3.1",
"apexcharts": "3.30.0",
"aws-amplify": "4.3.7",
"axios": "0.24.0",
"axios-mock-adapter": "1.20.0",
"chart.js": "2.9.4",
"clsx": "1.1.1",
"country-flag-icons": "1.4.14",
"date-fns": "2.25.0",
"firebase": "9.4.1",
"formik": "2.2.9",
"formik-mui": "^4.0.0-alpha.3",
"formik-mui-lab": "^1.0.0-alpha.3",
"history": "5.1.0",
"i18next": "21.5.2",
"i18next-browser-languagedetector": "6.1.2",
"jsonwebtoken": "8.5.1",
"notistack": "2.0.3",
"nprogress": "0.2.0",
"numeral": "2.0.6",
"prop-types": "15.7.2",
"react": "^17.0.2",
"react-apexcharts": "1.3.9",
"react-beautiful-dnd": "13.1.0",
"react-chartjs-2": "2.11.1",
"react-circular-progressbar": "2.0.4",
"react-countup": "6.1.0",
"react-custom-scrollbars-2": "4.4.0",
"react-dom": "^17.0.2",
"react-dropzone": "11.4.2",
"react-gauge-chart": "0.4.0",
"react-helmet-async": "1.1.2",
"react-i18next": "11.14.2",
"react-quill": "2.0.0-beta.4",
"react-redux": "7.2.6",
"react-router": "6.0.0-beta.0",
"react-router-dom": "6.0.0-beta.0",
"react-simple-maps": "2.3.0",
"react-sparklines": "^1.7.0",
"react-syntax-highlighter": "15.4.5",
"redux": "4.1.2",
"redux-devtools-extension": "2.13.9",
"redux-thunk": "2.4.0",
"stylis": "4.0.10",
"stylis-plugin-rtl": "2.1.1",
"swiper": "6.8.4",
"uuid": "8.3.2",
"web-vitals": "2.1.2",
"yup": "0.32.11"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"@vitejs/plugin-react": "^1.3.1",
"cross-env": "^7.0.3",
"eslint": "^7.11.0",
"eslint-config-airbnb-typescript": "^16.0.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.27.1",
"eslint-plugin-react-hooks": "^4.3.0",
"prettier": "^2.5.0",
"typescript": "4.4.4",
"vite": "^2.9.5"
}
}
|
I am experiencing the same issue on version |
Same issue here, with react 17, mui 4.12.3 , @material-ui/pickers 3.3.10 The fix from #issuecomment-1034120883 ( |
Same issue
This helped me somehow:
If didn't helped you, then remove Probably related to: |
Did anyone find a workaround for this issue? |
Fix by change vite config Make us able to deploy our application as website alloc/vite-react-jsx#10 (comment)
I get an
Uncaught ReferenceError: React is not defined
error, when rendering the DateTimePicker component from @material-ui/pickers. This error happens only in production build and not in the dev server.The text was updated successfully, but these errors were encountered: