Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy default properties as well as named #42

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jsumners-nr
Copy link
Contributor

This PR is a follow up to a discussion in Slack. As it is, IITM hooks will easily hook a "named" export from a CJS module but extra effort is required to hook the same exports that are defined on the "default" export. Prior to this PR, the lines 20 and 23 in the included test case will fail.

@jsumners-nr
Copy link
Contributor Author

I'm not sure who to request a review from, but @bengl I am familiar with you, so: tag, you're it.

@@ -128,6 +128,9 @@ ${exportNames.map((n) => `
let $${n} = namespace.${n}
export { $${n} as ${n} }
set.${n} = (v) => {
if ('${n}' !== 'default' && namespace.default['${n}']) {
namespace.default['${n}'] = v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to make sure that this only applies to CJS modules. This could easily be incorrect for ESM modules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. I'm putting this PR on hold until we have resolution on my others. Even if this one were merged, I'd still have to proxy the returned proxy because I need a symbol to detect the proxy. So I want to write up a case for that and discuss it.

@jsumners-nr jsumners-nr marked this pull request as draft December 11, 2023 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants