mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-20 15:22:18 +00:00
💡(frontend) warn in vite config on MediaPipe asset/track-processor drift
Add a build-time warning in the Vite config that fires when the MediaPipe assets copied by `vite-plugin-static-copy` fall out of sync with the version used by `@livekit/track-processors`. This catches at build time the kind of drift that would otherwise only surface at runtime as broken virtual backgrounds.
This commit is contained in:
@@ -5,16 +5,26 @@ import { visualizer } from 'rollup-plugin-visualizer'
|
||||
import svgr from 'vite-plugin-svgr'
|
||||
import { viteStaticCopy } from 'vite-plugin-static-copy'
|
||||
|
||||
const mediapipeVersion: string = JSON.parse(
|
||||
readFileSync(
|
||||
new URL(
|
||||
'./node_modules/@mediapipe/tasks-vision/package.json',
|
||||
import.meta.url
|
||||
),
|
||||
'utf-8'
|
||||
)
|
||||
const readPackageJson = (path: string) =>
|
||||
JSON.parse(readFileSync(new URL(path, import.meta.url), 'utf-8'))
|
||||
|
||||
const mediapipeVersion: string = readPackageJson(
|
||||
'./node_modules/@mediapipe/tasks-vision/package.json'
|
||||
).version
|
||||
|
||||
const livekitMediapipeVersion: string = readPackageJson(
|
||||
'./node_modules/@livekit/track-processors/package.json'
|
||||
).dependencies['@mediapipe/tasks-vision']
|
||||
|
||||
if (mediapipeVersion !== livekitMediapipeVersion) {
|
||||
throw new Error(
|
||||
`@mediapipe/tasks-vision@${mediapipeVersion} is installed, but ` +
|
||||
`@livekit/track-processors declares "${livekitMediapipeVersion}". ` +
|
||||
`The two must stay in sync: pin "@mediapipe/tasks-vision" to ` +
|
||||
`"${livekitMediapipeVersion}" in package.json.`
|
||||
)
|
||||
}
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd())
|
||||
|
||||
Reference in New Issue
Block a user