Throwing errors is appropriate for Object methods like Object.defineProperty when run in strict mode code. However, Reflect.defineProperty should return false without throwing an error. The proxy traps need to be constructed in a way to handle this. To solve this in esm I did two things.
Since we own the secure realm though we can monkey-patch Reflect to avoid throwing and return booleans.
Throwing errors is appropriate for
Objectmethods likeObject.definePropertywhen run in strict mode code. However,Reflect.definePropertyshould returnfalsewithout throwing an error. The proxy traps need to be constructed in a way to handle this. To solve this inesmI did two things.ReflectAPI to catch errors thrown in their methods and return booleansError.prepareStackTraceAPI to walk the the stack and detect strict mode code. That's a bit involved and requires punching a sloppy-mode hole into the webpack bundle to get it right.Since we own the secure realm though we can monkey-patch
Reflectto avoid throwing and return booleans.