fnando / i18n-js

It's a small library to provide the I18n translations on the Javascript. It comes with Rails support.
MIT License
3.75k stars 519 forks source link

Feature Request: Support `esmodule` #715

Open magiziz opened 9 months ago

magiziz commented 9 months ago

Description

We have been shipping awesome features with i18n-js. But we also encountered some of the issues with esmodule when people were downloading our package and it didn't work well. We say that from here: https://github.com/fnando/i18n/issues/44#issuecomment-1385151034

But we also went with your appraoch too: https://github.com/fnando/i18n/issues/44#issuecomment-1362209550

I feel like i can help you raise a PR on this repo if you can show me how you want me to update it. I was thinking of going with the same approach as this guy suggested: https://github.com/fnando/i18n/issues/44#issuecomment-1385151034

But let me know what you think 👍

magiziz commented 9 months ago

Also want to address this too. Locally this works fine, but when we ship it externally then it doesn't point out well and people might get this bug too:

`import { I18n } from "i18n-js";
         ^^^^
SyntaxError: Named export 'I18n' not found. The requested module 'i18n-js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using: