diff --git a/WrappedPlugin/index.js b/WrappedPlugin/index.js index 64875f1..738907c 100644 --- a/WrappedPlugin/index.js +++ b/WrappedPlugin/index.js @@ -152,10 +152,24 @@ const wrapHooks = (orig, pluginName, smp, type) => { acc[method] = genProxy(method); return acc; }, {}); - - wrappedHooks.push({ orig: hooks, wrapped, pluginName }); - - return wrapped; + const wrappedProxy = new Proxy(wrapped, { + get: (target, property) => { + return Reflect.get(target, property); + }, + set: (target, property, value) => { + Reflect.set(hooks, property, value); + const wrappedHook = value; // genProxy(property); // unsure why, but genProxy on custom hooks hang the build + Reflect.set(target, property, wrappedHook); + return wrappedHook; + }, + deleteProperty: (target, property) => { + return Reflect.deleteProperty(target, property); + }, + }) + + wrappedHooks.push({ orig: hooks, wrapped: wrappedProxy, pluginName }); + + return wrappedProxy; }; const construcNamesToWrap = [