obj[prop] = 'foo'
where prop is user input or similar. You could technically compile them away if you replaced all property set/gets with code like set(obj, prop, "foo")
get(obj, prop)
with a babel step, but the performance impact of this (both in runtime and compile-time) would be enormous.EDIT: there are various blog posts around talking about optimisation: https://v8.dev/blog/optimizing-proxies
For instance, if you were to receive a random string over some network call and set that on a proxified object, how would you pre-compile the Proxy away such that its runtime behavior is preserved when accessing what could be any arbitrary string?
You'd need infinite space to represent the space of all possible string inputs in order to optimize that away at compile time, which is obviously not feasible.
JIT compilation still involves a runtime performance penalty of the JIT compilation step itself, that has to be traded off against the runtime performance penalty of just running the Proxy logic without any runtime compilation step.
That's a nuanced tradeoff that has to be weighed on a case by case basis by various heuristics, and can reduce the runtime cost of proxies when applied to the right cases (and at the same time, could increase runtime cost if applied to the wrong ones: think overly aggressive inlining and its effects on memory usage), but either way it doesn't result in the Proxy abstraction becoming "compiled away" into something that has 0 runtime cost.