How to import Babylon such that mocking is possible?

Hi, sorry if this is a dumb question.

When using Babylon I’ve often been in the practice of overriding various methods, in order to fix bugs or change performance. But now that Babylon is all ES6, this seems to be impossible, since ES6 modules get imported in such a way that the module objects are non-configurable.

Does anyone know a way to import Babylon (into a webpack project) in such a way that it’s possible to override things, for testing or mocking purposes?


var Maths = require('@babylonjs/core/Maths')
Maths.Angle = function () { /* my custom logic */ }

The code above throws an error, since the Maths object is exported as a ES6 module object, which has getters instead of properties, and isn’t configurable. I don’t know if that’s due to something about typescript, something about wepback, or something else.

Has anyone worked around issues like this?

Pinging @sebavan

It is unfortunately not possible with ES6 modules. You could nevertheless still rely on the none ES6 version for this ? (while losing the tree shaking abilities)