When using Vite as the build and development tool, the inspector seems to have problems loading. I’ve created a repository to demo the issue:
The error occurs at the time of import. In my example, I am simply doing import('@babylonjs/inspector') and it fails at that point. The error also seems to vary depending on whether BabylonJS modules are listed in Vite’s config optimizeDeps.exclude or not. When not excluded, this error appears:
init_thinInstanceMesh is not a function
When excluded, this error appears:
The requested module ‘/node_modules/react/index.js?v=5e6cea53’ does not provide an export named ‘Fragment’
The latter seems to be related to JSX, but even specifying "jsx": "react-jsx" in tsconfig.json doesn’t seem to do anything. Amusingly, it seems to work properly when using build mode, but that’s likely because Vite’s toolchain is different in dev mode vs in build mode.
Has this been encountered by anyone else? Is there something I am missing in my configuration to allow inspector v2 to work in dev mode when using Vite?
(There was a similar issue that was causing build problems related to incorrect import definitions not too long ago, but this was fixed in #18230.)