路径:/node_modules/webapck/node_modules/tapable/lib/Hook.js
- 创建Hook类
- 创建createCompileDelegate函数
- 使用createCompileDelegate初始化Hook类的_call, _promise, _callAsync
- 暴露Hook类(仅在Tapable包内暴露,index.js文件没有对外暴露)
Tapable包没有对外暴露Hook类,查看markdown文件也可以看出Hook类是作为一个抽象类起作用的,它的compile方法也是直接抛出一个错误。
js文件
compile(options) {
throw new Error("Abstract: should be overriden");
}
markdown文件
interface Hook {
tap: (name: string | Tap, fn: (context?, ...args) => Result) => void,
tapAsync: (name: string | Tap, fn: (context?, ...args, callback: (err, result: Result) => void) => void) => void,
tapPromise: (name: string | Tap, fn: (context?, ...args) => Promise<Result>) => void,
intercept: (interceptor: HookInterceptor) => void
}