azu / commonjs-to-es-module-codemod

Codemod that convert CommonJS(require/exports) to ES Modules(import/export) for JavaScript/TypeScript
MIT License
80 stars 15 forks source link

Fix export as object expression conversion #13

Closed albyrock87 closed 1 year ago

albyrock87 commented 1 year ago

I tested this on a big project with mixed ts and js and I encountered some errors. I had a cjs module doing module.exports = { foo } and the ts module importing it without errors using import { foo } from './my-cjs-module'. After conversion the ts import wasn't working anymore, this is the reason for this PR. I also took the time to improve the dev experience with unit tests by removing some manual/duplicate code.

Summary:

azu commented 1 year ago

Thanks!

https://github.com/azu/commonjs-to-es-module-codemod/releases/tag/v0.5.2