Node Require Hooks
In browser's world we have webpack
and many great loaders let us require everything not only .js
file, on the contrary you only can require .js
in Node.
Usage
// include in main file
Examples
Without require hooks
// react-tab.js // this will get exception in Node test environment ... moduleexport = Tab
// test.spec.js
Includes require hooks to fix this
{ }
API
requireHooks({ext, raw, mod, requirePath})
If doesn't have any return
it will uses original require function
ext
get filename extensionmod
export as modulerequirePath
get relative require pathrawPath
get full raw path