{"bin":{"enhanced-require":"bin/enhanced-require.js","enhanced-require-hot-watch":"bin/hot-watch.js"},"dist":{"shasum":"f4477b59a500e0073f4eb4819beb49b0a27187ca","tarball":"https://registry.npmjs.org/enhanced-require/-/enhanced-require-0.4.0.tgz","integrity":"sha512-PHGAGOquqapcBukX1VdpPODLLieeXNHULwcNRYOq2HiHs/4ySwJBGOEHT21Frtn0vFBswrcE3WSn+EN9IbaaNg==","signatures":[{"sig":"MEYCIQCApQFqCPsJkDSN+RJRZjrKviVui675M0L1pTU8LSq1dwIhAM58DBhvUtgeAInfTkGySxqhQdapJhfxtmIIesTDaf2y","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/require","name":"enhanced-require","author":{"name":"Tobias Koppers @sokra"},"readme":"# enhanced-require\r\n\r\nMore features for node.js require.\r\n\r\n* [loader support](https://github.com/sokra/modules-webpack/wiki/Loader-Specification)\r\n* `require.ensure`\r\n* AMD `require`, `define` (from require.js)\r\n* `require.context`\r\n* [Hot Code Replacement](https://github.com/webpack/enhanced-require/wiki/HCR-Spec)\r\n* module substitutions for mocking\r\n\r\nAsynchron require functions are **really** async. They do not use the sync node.js require, but use a async resolving and async readFile.\r\n\r\n## Create a enhanced require function\r\n\r\n``` javascript\r\nvar myRequire = require(\"enhanced-require\")(module, {\r\n\t// options\r\n\trecursive: true // enable for all modules recursivly\r\n\t// This replaces the original require function in loaded modules\r\n});\r\n\r\n// startup your application\r\nmyRequire(\"./startup\");\r\n```\r\n\r\n## Usage\r\n\r\nThan you can use them:\r\n\r\n``` javascript\r\n// use loaders\r\nvar fileContent = require(\"raw!\"+__filename);\r\n\r\n// use loaders automatically\r\nvar template = require(\"./my-template.jade\");\r\n\r\nvar html = template({content: fileContent});\r\n\r\n// use require.context\r\nvar directoryRequire = require.context(\"raw!./subdir\");\r\nvar txtFile = directoryRequire(\"./aFile.txt\");\r\n\r\n// use require.ensure\r\nrequire.ensure([\"./someFile.js\"], function(require) {\r\n\tvar someFile = require(\"./someFile.js\");\r\n});\r\n\r\n// use AMD define\r\nrequire.define([\"./aDep\"], function(aDep) {\r\n\taDep.run();\r\n});\r\n\r\n// use AMD require\r\nrequire([\"./bDep\"], function(bDep) {\r\n\tbDep.doSomething();\r\n});\r\n```\r\n\r\n## Hot Code Replacement\r\n\r\n``` javascript\r\nrequire(\"enhanced-require\")(module, {\r\n\trecursive: true, // enable for all modules\r\n\thot: true, // enable hot code replacement\r\n\twatch: true // watch for changes\r\n})(\"./startup\");\r\n```\r\n\r\nFor hot code reloading you need to follow the [hot code reloading spec](https://github.com/webpack/enhanced-require/wiki/HCR-Spec).\r\n\r\n## Testing/Mocking\r\n\r\n``` javascript\r\nvar er = require(\"enhanced-require\");\r\nit(\"should read the config option\", function(done) {\r\n\tvar subject = er(module, {\r\n\t\trecursive: true,\r\n\t\tsubstitutions: {\r\n\t\t\t// specify the exports of a module directly\r\n\t\t\t\"../lib/config.json\": {\r\n\t\t\t\t\"test-option\": { value: 1234 }\r\n\t\t\t}\r\n\t\t},\r\n\t\tsubstitutionFactories: {\r\n\t\t\t// specify lazy generated exports of a module\r\n\t\t\t\"../lib/otherConfig.json\": function(require) {\r\n\t\t\t\t// export the same object as \"config.json\"\r\n\t\t\t\treturn require(\"../lib/config.json\");\r\n\t\t\t}\r\n\t\t}\r\n\t})(\"../lib/subject\");\r\n\r\n\tvar result = subject.getConfigOption(\"test-option\");\r\n\tshould.exist(result);\r\n\tresult.should.be.eql({ value: 1234 });\r\n});\r\n```\r\n\r\n## Options\r\n\r\n``` javascript\r\n{\r\n\trecursive: false,\r\n\t// replace require function in required modules with enhanced require method\r\n\r\n\tresolve: {\r\n\t\t// ...\r\n\t\t// see enhanced-resolve\r\n\t\t// https://github.com/webpack/enhanced-resolve\r\n\t},\r\n\t\r\n\tsubstitutions: {},\r\n\tsubstitutionFactories: {},\r\n\t// See above\r\n\t// Replace modules with mocks\r\n\t// keys are resolved and have to exist\r\n\r\n\tamd: {},\r\n\t// The require.amd object\r\n\r\n\tenhanced: {},\r\n\t// The require.enhanced object\r\n\r\n\tloader: {},\r\n\t// additional stuff in the loaderContext\r\n\r\n\thot: false,\r\n\t// enable hot code replacement\r\n\r\n\twatch: false,\r\n\t// Watch for file changes and issue hot replacement\r\n\r\n\twatchDelay: 400,\r\n\t// Time to summarize changes for watching\r\n}\r\n```\r\n\r\n## Future Plans\r\n\r\n* cli tool\r\n\r\n## License\r\n\r\nCopyright (c) 2012 Tobias Koppers\r\n\r\nMIT (http://www.opensource.org/licenses/mit-license.php)","engines":{"node":">=0.6"},"license":"MIT","scripts":{"test":"node node_modules/mocha/bin/_mocha --reporter spec"},"_npmUser":{"name":"sokra","email":"tobias.koppers@googlemail.com"},"homepage":"http://github.com/webpack/enhanced-require","licenses":[{"url":"http://www.opensource.org/licenses/mit-license.php","type":"MIT"}],"_npmVersion":"1.1.59","description":"Enhance the require function in node.js with support for loaders which preprocess files and really async require (AMD). Enables Hot Code Replacement.","maintainers":[{"name":"sokra","email":"tobias.koppers@googlemail.com"}],"dependencies":{"clone":"0.0.x","buffer-equal":"0.0.x","enhanced-resolve":"0.4.x"},"devDependencies":{"mocha":"1.3.x","should":"1.1.x","raw-loader":"0.2.x","jade-loader":"0.2.x"},"_id":"enhanced-require@0.4.0","version":"0.4.0"}