module customization hooks
Functions you register with module.register() or module.registerHooks() to change how Node.js finds and loads modules.
In more detail
A resolve hook can rewrite where a specifier points, and a load hook can change a module's source before V8 compiles it, for example to transpile TypeScript or supply a mock. Hooks registered with module.register() run on a separate loader thread; the newer module.registerHooks() runs them synchronously on the main thread.
Related terms
- module resolution — How a runtime or tool turns the name in an import, such as ./util.js or express, into the exact file to load.
- transpiler — A tool that translates source code into another language at a similar level, such as TypeScript into plain JavaScript.
- ECMAScript modules — The standard JavaScript module system, written with import and export statements, used by browsers and modern tools.
Taught in
- Native Module Systems: ESM Loader Hooks vs CommonJS — Node.js Internals & Backend Services