Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrap hooks object so that plugins can add custom hooks #169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
wrap hooks so that plugins can add custom hooks, this fixes some incr…
…emental builds
  • Loading branch information
davidparkagoda committed Apr 15, 2021
commit 0eafa251ae8c53ac0fd5b30cd313a43fddd1ab6d
22 changes: 18 additions & 4 deletions WrappedPlugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down