[LITE] const enums and verbatimeModuleSyntax

Hi folks! As I dig into lite physics, I’m running afoul of TS error 2748:

Cannot access ambient const enums when ‘verbatimModuleSyntax’ is enabled.

Physics has constants of this style:

export declare const enum PhysicsShapeType {
    SPHERE = 0,
    CAPSULE = 1,
    CYLINDER = 2,
    BOX = 3,
    CONVEX_HULL = 4,
    CONTAINER = 5,
    MESH = 6,
    HEIGHTFIELD = 7
}

A functionally equivalent declaration could be:

export const PhysicsShapeType = {
    SPHERE: 0,
    CAPSULE: 1,
    CYLINDER: 2,
    BOX: 3,
    CONVEX_HULL: 4,
    CONTAINER: 5,
    MESH: 6,
    HEIGHTFIELD: 7,
} as const;

export type PhysicsShapeType = (typeof PhysicsShapeType)[keyof typeof PhysicsShapeType];

I’ve confirmed this works as a drop-in substitute in my code. However, I wasn’t able to easily verify the performance impact of such a change, as running pnpm test on my machine results in several failures, even on an unmodified clone of the master branch :eight_spoked_asterisk:.

So, my question is: Have you already considered this issue? I’ve been using verbatimModuleSyntax without issue for about 18 months. With some light searching, it seems that there’s different opinions on this flag, although it seems that Vite (which I use) has better build performance when it is set.

Thanks for your insight!

:eight_spoked_asterisk: Any tips for getting reliable results out of pnpm test? I have a pretty high end laptop that’s about a year old.

Thanks for catching this — it was a Lite declaration compatibility bug. I replaced all root-exported const enums with as const objects plus matching union types and added a consumer test with verbatimModuleSyntax enabled: fix: support verbatimModuleSyntax for public enums by ryantrem · Pull Request #665 · BabylonJS/Babylon-Lite · GitHub

For local checks, pnpm test runs the full bundle and GPU parity suite. For this kind of change, use pnpm test:unit and pnpm test:build. For rendering changes, set REUSE_BROWSER=1, build only the affected scenes, and run their specific Playwright specs. If master still fails, please share the failing test names/output so we can distinguish a setup/GPU issue from a test regression.