Exception thrown loading babylonjs more than once

When loading the babylonjs bundle more than once, an exception is thrown out of legacy.ts:

TypeError: Cannot set property Debug of #<Object> which has only a getter

Pretty simple repo:

<!DOCTYPE html>
        <script src="https://cdn.babylonjs.com/babylon.max.js"></script>
        <script src="https://cdn.babylonjs.com/babylon.max.js"></script>
        <p>Hello, world!</p>

This used to work. Looks like it was a change from 4.x to 5.x. If you change the script to this, it works:

<script src="https://unpkg.com/babylonjs@4.2.2/babylon.max.js"></script>

Here’s where the exception is thrown:

I get that the workaround is “simple” in this minimum repo, but in my team’s situation it is not as simple. This used to work :frowning:

cc @RaananW

Hi @pjramirez-ms,

This PR will solve the issue - Make sure legacy support doesn’t throw exceptions by RaananW · Pull Request #12744 · BabylonJS/Babylon.js (github.com)
It will be available after merged in the next version (probably 5.15.0, released in the night)


Thanks for the quick turnaround @RaananW !

1 Like