unjs / jiti

Runtime TypeScript and ESM support for Node.js
MIT License
1.91k stars 62 forks source link

feat: use smarter proxy for `interopDefault` #318

Closed pi0 closed 1 month ago

pi0 commented 1 month ago

Resolves #317

With jiti v2.0.0 we have introduced native ESM import support which added a new kind of mixed export handling syntax. Early testing showed jiti v2 is broken with packages like mime without interop in mixed cases so in v2.1.0 we have enabled interopDefault by default to support out of the box.

Issues like #317 indicate that dependencies like zod will now be broken (because zod's default export is not expandable)

This PR introduces a new method for interopDefault using a Proxy which at least covers all of our current test fixtures and can be used to cover more of similar cases if reported in the future on proxy layer instead of modify default exports.