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

interopDefault breaks when combining a default string export with named exports #194

Closed
hayes opened this issue Sep 23, 2023 · 2 comments
Closed

Comments

@hayes
Copy link

hayes commented Sep 23, 2023

Environment

node 18

Reproduction

require('mlly').interopDefault({ default: 'test', x: 123 })

Describe the bug

I would expect in this case that the original module would be returned rather the just the default export test

Additional context

Checking if newModule is an object after it is assigned here: https://github.com/unjs/mlly/blob/main/src/cjs.ts#L38C3-L38C3 and returning the sourceModule instead if its not an object or function should work

Logs

No response

@pi0
Copy link
Member

pi0 commented Sep 26, 2023

By default interopDefault returns a proxified object that allows mixed syntax usage. We might support interopDefault({ default: 'test', x: 123 }, { strict: true }) to always return default key.

pi0 added a commit that referenced this issue Jan 11, 2024
@pi0
Copy link
Member

pi0 commented Jan 11, 2024

preferNamespace added as an opt-in (and non behavior changing) feature see 5d23c98 and 14eb72d

I hope it can help in your case but if you have some usecases that belive this behavior being default could be beneficial please mention.

@pi0 pi0 closed this as completed Jan 11, 2024
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

No branches or pull requests

2 participants