function to require a module with optional handling in case it's not found or fail to require
path to module to require
options or message to log when module not found
function to log message, default to use console.log, you can replace this with
another function.
resolve the module's full path
Options for calling optionalRequire
The value to return if error was MODULE_NOT_FOUND but notFound is not provided.
fail is a function. If error from require was something other than MODULE_NOT_FOUND,
for example, the module contains syntax error, then:
fail if it's providedfunction to log the module not found message, default log function uses console.log
Tell optional require to log a message if the module is not found.
This field can have these values:
true - log with default messagenotFound is a function. If error from require was MODULE_NOT_FOUND, then:
notFound if it's provideddefault value.require is the node.js require function from caller's context.
If not provided, then use the one received when creating the optional require function
If true, then do an optional require.resolve and return the full path
A default optionalRequire function using require from optional-require's context.
An optionalRequire function using require from CWD context
Make an optional require function, using the require from caller's context.
require from caller's context
function to log if module is not found
required module
try to require a module with optional handling in case it's not found or fail to require
require from caller context
path to module to require
options or message to log in case of exceptions
require result
try to resolve a module with optional handling in case it's not found or fail to require
require from caller context
path to module to require
options or message to log in case of exceptions
resolve result
Generated using TypeDoc
function to log in case require module was not found
message - message to log
path - path of the module that user tried to require