Lazy require all packages from your package.json
Inspired by: https://github.com/viktor-ku/auto-require/
const $ = require('fast-require')({
only: ['gulp', 'gulp-stylus', 'gulp-plumber']
})
// $.gulp, $.stylus, $.plumber
const $ = require('fast-require')({
without: ['gulp']
})
// $.stylus, $.plumber, but $.gulp is undefined
const $ = require('fast-require')({
search: ['src/my-folder/'],
})
// packages from src/my-folder/package.json available as $.[moduleName]
require('fast-require')({
only: ['gulp', 'gulp-notify'],
global: true
})
// gulp, gulpNotify or global.gulp, global.gulpNotify
const $ = require('fast-require')({
only: ['gulp', 'gulp-notify'],
as: {gulp: 'g', 'gulp-notify': gn}
})
// $.g $.gn
const $ = require('fast-require')({
only: ['request'],
toRoot: ['request']
})
// $.get, $.post, $.head (all function from request).
//$.request is undefined
const $ = require('fast-require')({install: false})
const $ = require('fast-require')({require: ['fs']})
//$.fs
const $ = require('fast-require')({lazy: false})
// All modules loaded at once
const $ = require('fast-require')()
$.gulp //gulp required
$.gulpNotify //gulp-notify required
const $ = fastRequire({patch: {
chai: x => {
x.patchedMethod = () => 'patched return'
return x
},
fs: require('thenifyAll')
}})