Skip to content

Improve args to support nested functions #29

Open
@mateatslc

Description

@mateatslc

Functions that aren't defined as top-level properties of args are not making through to the loaded module source. So for example, this works fine:

// 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:

// 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 by @cowboy but I'm not in love with it.
Let me know if this is something you think worth looking into.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions