Sandbox dev server no longer works from documented command after Vite/tree-shaking changes

The contribution docs say to run:

npm run serve -w @tools/sandbox

But on a fresh/current checkout, the sandbox can fail because the Vite config aliases dev packages to dist and the dist artifacts may not be generated. I hit missing shader imports such as core/dist/Shaders/lod3D.fragment.js.

After generating dist, the page can still fail because the sandbox entry does not import required side-effect modules for LoadingScreen and Inspector v2:

  • LoadingScreen needs to be imported before…
  • Cannot read properties of undefined (reading ‘show’) when opening Inspector

Locally, adding these to packages/tools/sandbox/src/main.ts fixes the runtime side-effect issues:

import “core/Loading/loadingScreen”;
import “inspector/legacy/legacy”;

And adding this alias to packages/tools/sandbox/vite.config.ts is required for the inspector import:

inspector: path.resolve(“../../dev/inspector-v2/dist”),

The docs may also need to mention running build:assets/build:source before serve, or the serve script should ensure required dist artifacts exist.

Just to check:
Did you run only npm run serve -w @tools/sandbox?

I believe there should be other 2 terminals running:

npm run watch:dev (If you want to make changes to the dev packages. Otherwise run npm run build:dev)
and
npm run serve -w @tools/babylon-server

Did you start all three of them?

I’ve run all of them.
Error message:


I feel it might be related to the recent tree shaking process, and it has caused some side effects.

cc @RaananW

A PR was submitted yesterday to fix this. it should be good already

I fetched the latest code from Babylon.js. Although the sandbox’s initial page no longer throws an error, an error still occurs when I drag a GLB containing a DRAO into it.

Additionally, when I input a glb file without “draco” included, it can be previewed normally. However, when I click the inspector panel, an error still occurs and the inspector panel fails to pop up.


Cc @RaananW

on it