worker-dom
worker-dom copied to clipboard
Debug: Warn on unsupported properties with Proxy
For debug mode only, it might be nice to add a JS proxy that warns when setting unsupported properties. E.g. with a short-link to new issue template for worker-dom
.
Thinking about the easiest way to integrate this. If we go with the separate debugging module fetched at runtime, we'd need one for the worker and one for the main-thread. Maybe another output variant is justified? 🤔
We've implemented the extra output option that enables more debugging knowledge and capabilities. Howeverm this feature will take time to complete, do you think we should prioritize it or drop the idea for now?
Low priority but let's keep it open. Using unsupported properties may cause non-obvious downstream bugs e.g. undefined
being passed around and causing something else to break.
bumping this given todays standup discussion
Is a development build the best path forward?
If Proxy implementation for this is small enough, might be sufficient to have a runtime check (e.g. enabled via hash param on window location) rather than compile-time via separate binary.
new Proxy(thingWeWrap, {
get(thingWeWrap, prop, receiver) {
if (!(prop in thingWeWrap) {
// warn
}
return Reflect.get(thingWeWrap, prop, receiver);
}
});
It becomes more complicated if you need to recursively wrap, but since we control all the initial values, probably not necessary.
And if we need to trap delete
, and getOwnPropertyDescriptor
.
In general having a development
version of amp-script
would allow us to provide more detail and useful error messaging than including debugging capabilities in the same binary.
I'd vote for using this as the starting place to introduce a development binary with the same set of browser support as the main binary.