Skip to content

Conversation

ChALkeR
Copy link
Contributor

@ChALkeR ChALkeR commented Apr 9, 2025

The current wretch logic is still broken with bundlers, even on 1.7.4.

See #32.

The issue occurred because wretch.browser.js exports wretch as an ESModule default export, and when imported via require, the default export is wrapped inside a .default property. This fix explicitly accesses the .default property when importing wretch.browser.js in wretch.js, ensuring compatibility with CommonJS.

That's not the case, wretch.browser.js is CJS, not ESM.

The real issue is that require('wretch') is a function with x.default = x, so each time it's imported (either from 'wretch', ./wretch.browswer.js, ./wretch.js or anywhere else) some bundlers get confused and unwrap that to an object { default : x } instead of a function.

The only way to break that loop is to wrap the function, removing it's .default property.

This reverts the change from #32 and instead does that.

@ChALkeR ChALkeR merged commit 18b5b2a into master Apr 9, 2025
1 check passed
@ChALkeR ChALkeR deleted the chalker/wretch-is-a-function branch April 9, 2025 17:46
Copy link

github-actions bot commented Apr 9, 2025

🎉 This PR is included in version 1.7.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants