Skip to content

fix: Use default export conditions instead of import #6

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

Merged
merged 1 commit into from
Apr 28, 2025

Conversation

beeequeue
Copy link
Contributor

This change allows the package to be imported with require(esm)

This is what is shown with the current export conditions:

Screenshot

image

But it works with default:

Screenshot

image

And older node versions without require(esm) get a clearer error:

Screenshot

image

@beeequeue beeequeue changed the title Use default export condition instead of import fix: Use default export condition instead of import Apr 23, 2025
@beeequeue beeequeue changed the title fix: Use default export condition instead of import fix: Use default export conditions instead of import Apr 23, 2025
@lukeed
Copy link
Owner

lukeed commented Apr 23, 2025

What’s the current error message for Node 18 doing a require?

I think the recommended approach is to use “module-sync” instead of adding an ambiguous default?

If Node18 error with current configuration is clear I think module-sync is way to go

@beeequeue
Copy link
Contributor Author

beeequeue commented Apr 23, 2025

The current error in node 18 is the same as the first image - not very clear what the error actually is.

module-sync gives the same unclear error as import in node 18, so it's up to you what you think is better

image

@lukeed
Copy link
Owner

lukeed commented Apr 28, 2025

Thanks. I'll merge, but I think I'm going to just include require exports, actually. I took a look around this morning & still so much of tooling ecosystem is using require-only builds, so these changes wouldn't help them either 😞

@lukeed lukeed merged commit 63b0dfa into lukeed:main Apr 28, 2025
@beeequeue
Copy link
Contributor Author

That would be very nice, I have looked into 3 packages where neither empathic or find-up-simple work because they need find.any which simple doesn't have, and can't use ESM!

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