Skip to content

fix: Account for module.exports export #197

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AbhiPrasad
Copy link

fixes #196

@AbhiPrasad AbhiPrasad self-assigned this May 28, 2025
@AbhiPrasad AbhiPrasad force-pushed the abhi-module.exports-skip branch 2 times, most recently from f07f8cf to 1ca82b3 Compare May 28, 2025 01:34
@AbhiPrasad AbhiPrasad changed the title fix: Skip module.exports exports fix: Skip module.exports export May 28, 2025
@AbhiPrasad AbhiPrasad force-pushed the abhi-module.exports-skip branch from 1ca82b3 to 63645a5 Compare May 28, 2025 02:03
@AbhiPrasad AbhiPrasad force-pushed the abhi-module.exports-skip branch from 63645a5 to 2a4f296 Compare May 28, 2025 02:04
@AbhiPrasad AbhiPrasad marked this pull request as ready for review May 28, 2025 02:04
@AbhiPrasad AbhiPrasad requested a review from timfish May 28, 2025 02:05
@AbhiPrasad AbhiPrasad changed the title fix: Skip module.exports export fix: Account for module.exports export May 28, 2025
@AbhiPrasad
Copy link
Author

#115 is the more robust fix for this

@AbhiPrasad AbhiPrasad closed this May 28, 2025
Comment on lines +263 to +264
const objectKey = n === 'module.exports' ? JSON.stringify(n) : n
const objectKeyWithAccess = n === 'module.exports' ? `[${objectKey}]` : `.${objectKey}`
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the object[bracket] syntax for all exports?

Copy link
Author

Choose a reason for hiding this comment

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

I figured we had done the dot syntax for some reason, so I elected to not change it, but now looking at it further, we probably can. Let me test something else out.

@timfish
Copy link
Contributor

timfish commented May 28, 2025

#115 excludes any library with "invalid" exports from being wrapped by iitm.

I think there might be a way to use the approach in this PR to actually export these and keep the library instrument'able by iitm...

@AbhiPrasad AbhiPrasad reopened this May 28, 2025
@AbhiPrasad
Copy link
Author

I think there might be a way to use the approach in this PR to actually export these and keep the library instrument'able by iitm...

I think if we just use the object syntax, we can do this. Let me push up another commit with what I'm thinking.

@timfish
Copy link
Contributor

timfish commented May 28, 2025

For the intermediate variables we currently use something containing the export name which causes issues but there's nothing stopping us from using something unique like a counter _1, etc.

Is it only newer versions of Node that accept exporting names with strings like that? I suspect we might need a legacy output mode for older Node versions...

@AbhiPrasad
Copy link
Author

Is it only newer versions of Node that accept exporting names with strings like that? I suspect we might need a legacy output mode for older Node versions...

I think so, the tests were breaking in node 12 and 14, so I pinned to node 16.

@AbhiPrasad AbhiPrasad marked this pull request as draft May 29, 2025 16:02
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.

yargs-parser and cliui integration tests failing
3 participants