When the binding is itself one that was created by __createBinding,
re-use its descriptor, which avoids piling multiple levels of getters in
the case of multiple levels of exports.
In addition, reuse a descriptor if the bindings is marked as
non-writable and non-configurable, which makes a getter not
necessary. (This can be done manually if needed, even though tsc
doesn't do it now.)
Could be considered as a fix for #165 -- first, this PR prevents piling
up multiple layers of getters. Second, it allows a hack of adding
if (typeof exports === "object") exports = Object.freeze(exports);
to avoid getters altogether. (And in the future, tsc could mark const
exports as non-writable and non-configurable which would make it
possible to avoid this hack.)
Reflect microsoft/TypeScript#46997:
When the binding is itself one that was created by
__createBinding
, re-use its descriptor, which avoids piling multiple levels of getters in the case of multiple levels of exports.In addition, reuse a descriptor if the bindings is marked as non-writable and non-configurable, which makes a getter not necessary. (This can be done manually if needed, even though tsc doesn't do it now.)
Could be considered as a fix for #165 -- first, this PR prevents piling up multiple layers of getters. Second, it allows a hack of adding
to avoid getters altogether. (And in the future, tsc could mark
const
exports as non-writable and non-configurable which would make it possible to avoid this hack.)