alloc / cush

WIP module bundler 🎁
MIT License
0 stars 0 forks source link

Left hooks and right hooks 🥊 #14

Closed aleclarson closed 6 years ago

aleclarson commented 6 years ago

Currently, the hook API for plugins is very minimal. Hook functions are pushed to the end of the associated array. We'll probably keep this.hook the same in that regard, but we should figure out a way to prepend a hook function (and maybe even a priority system is warranted?).

// Run after all existing "config" hooks (except right hooks).
this.hook('config', () => {});

// Run before all existing "config" hooks.
this.hookLeft('config', () => {});

// Run after all existing "config" hooks.
this.hookRight('config', () => {});

Using hookLeft guarantees your function will run before any hook and hookRight functions.

Using hookRight guarantees your function will run after any hook and hookLeft functions.

aleclarson commented 6 years ago

We need to figure out how to accomplish this with hookModules and hookPackages.

aleclarson commented 6 years ago

Added in 7a6d87e37bc84adf9e5edd39a02d0c951de079de (v0.1.0)

For the module hook, you can do:

this.hookLeft('module.js', () => {});

For the package hook, you can do:

this.hookLeft('package', () => {});