import { Camera } from '@mediapipe/camera_utils'
import { Hands } from '@mediapipe/hands'
import { Pose } from '@mediapipe/pose'
The problem is, when i run vite build command, in final index.js file generated e.g. /dist/index.030asdf.js, it references hands.Hands undefined variable instead of Hands, so when i execute in production mode, javascript console throws error: Uncaught TypeError: Cannot read properties of undefined (reading 'Hands'). Same thing happens with rest of @mediapipe imports.
That issue does not happen with another non-mediapipe deps, such as "@formkit/auto-animate": "1.0.0-beta.3", or "@tanstack/react-query": "^4.19.0",
That issue doesn't happen either if i run vite server. The problem is only with vite build and importing @mediapipe deps on my code.
[X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
[X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Describe the bug
Hi, i have several mediapipe dependencies on my react app:
Im using this imports in some place on my code:
The problem is, when i run
vite build
command, in final index.js file generated e.g. /dist/index.030asdf.js, it referenceshands.Hands
undefined variable instead ofHands
, so when i execute in production mode, javascript console throws error:Uncaught TypeError: Cannot read properties of undefined (reading 'Hands')
. Same thing happens with rest of @mediapipe imports.That issue does not happen with another non-mediapipe deps, such as
"@formkit/auto-animate": "1.0.0-beta.3",
or"@tanstack/react-query": "^4.19.0",
That issue doesn't happen either if i run
vite server
. The problem is only withvite build
and importing @mediapipe deps on my code.Here my
tsconfig.json
file:My vite.config.js:
Any ideas? Thanks!
Reproduction
https://stackblitz.com/edit/vitejs-vite-ajf9oa?file=mediapipe_hands.js
Steps to reproduce
Run
npm install
andnpm run build
. Download project from stackblitz and load dist/index.html into browserSystem Info
Used Package Manager
npm
Logs
Vite build logs:
Validations