-
-
Notifications
You must be signed in to change notification settings - Fork 102
Closed
Description
Directory structure:
./index.js
./a/index.js
./a/util.js
./b/index.js
./b/util.js
Files:
// ./index.js
const proxyquire = require('proxyquire');
proxyquire('./a/index.js', {"./util": {c: "c"}});// ./a/index.js
const util = require('./util');
require('../b');
console.log(util);// ./a/util.js
exports.a = "a";// ./b/index.js
const util = require('./util');// ./b/util.js
exports.b = "b";Expected behavior:
index.js requires ./a/index.js via proxyquire, and overrides the propery c of './util.js. Since a/util.jsdefines a propertya, we would expect the console.log()in./a/index.js` to print:
{c: 'c', a: 'a'}
Actual behavior:
{ c: 'c', a: 'a', b: 'b' }
Every time any file does require('./util'), proxyquire requires the file, and merges it together into one giant object. This does bad things if you have two different files with the same name, that both contain the same property (which is pretty common in ES6 land, where we often export default ...).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels