Skip to content

Commit

Permalink
Let let the first getter win when adding a getter that already exists. (
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton authored Apr 6, 2017
1 parent 0163fd7 commit 18eaf43
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions lib/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ function makeUniqueKey() {
}

Ep.addSetters = function (parent, setters, key) {
var entry = this;

if (typeof key === "undefined") {
// If no key was provided, make a new unique key that won't collide
// with any other keys.
Expand All @@ -57,15 +55,14 @@ Ep.addSetters = function (parent, setters, key) {
// Ignore any requests for the exports.__esModule property."
name !== "__esModule") {
setter.parent = parent;
(entry.setters[name] =
entry.setters[name] || Object.create(null)
(this.setters[name] =
this.setters[name] || Object.create(null)
)[key] = setter;
}
}
};

Ep.addGetters = function (getters) {
var entry = this;
var names = Object.keys(getters);
var nameCount = names.length;

Expand All @@ -74,9 +71,10 @@ Ep.addGetters = function (getters) {
var getter = getters[name];
if (typeof getter === "function" &&
// Ignore any requests for the exports.__esModule property."
name !== "__esModule") {
// Should this throw if hasOwn.call(this.getters, name)?
entry.getters[name] = getter;
name !== "__esModule" &&
// Should this throw if hasOwn.call(this.getters, name)?
! hasOwn.call(this.getters, name)) {
this.getters[name] = getter;
}
}
};
Expand All @@ -94,12 +92,11 @@ function runModuleGetters(module) {
}

Ep.runModuleGetters = function (module) {
var entry = this;
var names = Object.keys(entry.getters);
var names = Object.keys(this.getters);
var nameCount = names.length;

for (var i = 0; i < nameCount; ++i) {
entry.runGetter(module, names[i]);
this.runGetter(module, names[i]);
}
};

Expand All @@ -123,14 +120,14 @@ Ep.runGetter = function (module, name) {
// setters associated with the newly exported values.
Ep.runModuleSetters = function (module) {
var entry = this;
var names = Object.keys(entry.setters);
var names = Object.keys(this.setters);

// Make sure module.exports is up to date before we call
// module.getExportByName(name).
entry.runModuleGetters(module);
this.runModuleGetters(module);

if (names.length === 0) {
++entry.runCount;
++this.runCount;
return;
}

Expand Down

0 comments on commit 18eaf43

Please sign in to comment.