For this week, I have been reading unbuild source code and found few packages that I have never seen before or used. I wanted to share some interesting packages that are used in these OSS projects so we can learn a thing or two ;)
Hookable is a package built by authors at Unjs. Unjs provides JS tools, libraries and has about 63 npm packages and 421m downloads per month. Sheesh, that’s a lot.
// Method A:import { createHooks } from 'hookable'// Create a hookable instanceconst hooks = createHooks()// Hook on 'hello'hooks.hook('hello', () => { console.log('Hello World' )})// Call 'hello' hookhooks.callHook('hello')
Basically, you create a hook with a callback and call these hooks somewhere else in your codebase to trigger this callback. Let’s what sort of hooks are found in unbuild source code.
Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.