privatenumber / tsx

⚡️ TypeScript Execute | The easiest way to run TypeScript in Node.js
https://tsx.is
MIT License
9.74k stars 152 forks source link

`__esModule` interop is applied to .cjs files #627

Open nichtsam opened 3 months ago

nichtsam commented 3 months ago

Acknowledgements

Minimal reproduction URL

https://github.com/nichtsam/tsx-import-differently

Problem & expected behavior (under 200 words)

Skip this section and let your reproduction do the talking...

But if you really need to explain, keep it under 200 words:

Bugs are expected to be fixed by those affected by it

Compensating engineering work will speed up resolution and support the project

privatenumber commented 3 months ago

Oh good catch. The __esModule property should be ignored if the file is .cjs.

This will be pretty complex to handle since it should handle:

Feel free to open a PR with a test first, but I think this will be very challenging and may have to be resolved with https://github.com/privatenumber/tsx/issues/614