bahmutov / bahmutov/really-need
Improve `args` to support nested functions
- Dominant language
- JavaScript
- Stars
- 107
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Functions that aren't defined as top-level properties of [`args`](https://github.com/bahmutov/really-need#args) are not making through to the loaded module source. So for example, this works fine:
``` javascript
// another-require.js
require('something');
// index.js
require = require('really-need');
require('./another-require', {
args: {
require: function (name) {
console.log('no requires allowed');
}
}
});
// prints "no requires allowed"
```
... but this doesn't:
``` javascript
// stuff-with-lodash.js
console.log( _.yam );
_.filter();
// index.js
require = require('really-need');
require('./stuff-with-lodash', {
args: {
_: {
'yam': 678,
'filter': function () {
console.log('look! a fake lodash filter!');
}
}
}
});
// prints:
// 678
// _.filter is not a function
```
I already hacked together something that works using a [dusty gist](https://gist.github.com/cowboy/3749767) by @cowboy but I'm not in love with it.
Let me know if this is something you think worth looking into.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the require wrapper behavior shown in index.js and reproduce the nested args case in stuff-with-lodash.js; compare it with the working top-level require example in another-require.js. Review the linked dusty gist as prior art, then verify that nested function values such as _.filter reach the loaded module and remain callable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100