Comparing version 0.5.2 to 0.5.3
@@ -36,2 +36,3 @@ 'use strict'; | ||
this.$mm = new ModuleMapper(config); | ||
this.$require = config.require || module.require.bind(module); | ||
} | ||
@@ -53,3 +54,3 @@ | ||
// Require module | ||
return require(name); | ||
return this.$require(name); | ||
} | ||
@@ -60,3 +61,3 @@ finally { | ||
delete require.cache[key]; | ||
}); | ||
}, this); | ||
} | ||
@@ -63,0 +64,0 @@ }; |
{ | ||
"name": "r42", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "Dependency injection done right.", | ||
@@ -32,9 +32,9 @@ "author": { | ||
"devDependencies": { | ||
"chai": "~1.9.0", | ||
"chalk": ">=0.4.0", | ||
"grunt": "~0.4.1", | ||
"grunt-mocha-test": "~0.9.0", | ||
"chai": "~1.9.0", | ||
"grunt-mocha-test": "^0.10.2", | ||
"sinon": "^1.9.0", | ||
"sinon-chai": "~2.5.0", | ||
"chalk": ">=0.4.0" | ||
"sinon-chai": "~2.5.0" | ||
} | ||
} |
@@ -314,4 +314,8 @@ ## r42 | ||
var r42 = require('r42'); | ||
var context = r42.config(/* Your configuration object */); | ||
var context = r42.config({ | ||
require: require, | ||
/* Other configuration properties */ | ||
}); | ||
context.inject(function (/* Your dependencies */) { | ||
@@ -324,4 +328,15 @@ module.exports = { | ||
Since your library uses r42, you have to take into account the fact that a module depending on your code also uses it. If the versions required by your module and its dependant are compatible, they will share the r42 codebase. This means that r42 will be installed in a parent `node_modules` folder. If nothing is done, it will break `require` in your r42. To prevent this from happening, | ||
you **HAVE TO** add the `require` configuration variable to your configuration (in the same way as in the previous example). | ||
### Changelog | ||
#### 0.5.3 | ||
* Add `config.require` configuration property (see *Using r42 in libraries* in the documentation) | ||
#### 0.5.2 | ||
* Allow `config.path` to contain plugin syntax (e.g: `json!package.json` is valid) | ||
#### 0.5.0 & 0.5.1 | ||
@@ -328,0 +343,0 @@ |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
29082
549
375
4