Part of #456.
Symptom
exports.clone(x), var self = exports; self.run(), module.exports.helper() inside a CommonJS file were ambient_terminal — the binder marks exports and module GLOBAL_BUILTIN — although they call into the file itself. And exports = module.exports = Base; exports.list = function ...; Base.list(...) found no list on Base: the member was written through one name of an object that has two.
Fix
- Inside a module,
exports and module.exports evaluate to that module's own surface (the module value); a GLOBAL_BUILTIN receiver that got a value is not ambient.
- A member export row (
exports.x =, module.exports.x =) is a property of the module's CommonJS default value as well, when there is one — module.exports = Base and exports.list = ... name one object.
exports = module.exports = Base;
exports.list = function (failures) {};
function Base() {}
Base.list(this.failures); // -> the function assigned to exports.list
Part of #456.
Symptom
exports.clone(x),var self = exports; self.run(),module.exports.helper()inside a CommonJS file wereambient_terminal— the binder marksexportsandmoduleGLOBAL_BUILTIN — although they call into the file itself. Andexports = module.exports = Base; exports.list = function ...; Base.list(...)found nolistonBase: the member was written through one name of an object that has two.Fix
exportsandmodule.exportsevaluate to that module's own surface (themodulevalue); a GLOBAL_BUILTIN receiver that got a value is not ambient.exports.x =,module.exports.x =) is a property of the module's CommonJS default value as well, when there is one —module.exports = Baseandexports.list = ...name one object.