Skip to content

Conversation

@elibarzilay
Copy link
Contributor

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

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 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.)
@elibarzilay elibarzilay force-pushed the optimize_createBinding branch from 95a77b9 to 5ad0250 Compare January 14, 2022 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants