alibaba / react-intl-universal

Internationalize React apps. Not only for Component but also for Vanilla JS.
1.33k stars 153 forks source link

Drop deprecated formatter libraries #247

Open Chevindu opened 6 months ago

Chevindu commented 6 months ago

Description

This change updates intl-messageformat dependency version so that it fixes following npm deprecation warnings logged when installing react-intl-universal in a project.

npm WARN deprecated intl-messageformat-parser@3.6.4: We've written a new parser that's 6x faster and is backwards compatible. Please use @formatjs/icu-messageformat-parser
npm WARN deprecated @formatjs/intl-utils@2.3.0: the package is rather renamed to @formatjs/ecma-abstract with some changes in functionality (primarily selectUnit is removed and we don't plan to make any further changes to this package
npm WARN deprecated @formatjs/intl-unified-numberformat@3.3.7: We have renamed the package to @formatjs/intl-numberformat

Type of change

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

SamuelLeclerc33 commented 4 months ago

Is this going to get merged ? @cwtuan

cwtuan commented 4 months ago

Is it possible to avoid making a breaking change?

Chevindu commented 4 months ago

I noticed the upstream library (formatjs) does not support the full HTML spec as rich text according to this part in their docs.

We could add support for a limited set of HTML/XML tags in react-intl-universal and allow users to override it during init(). But I did not do it due to following reasons:

Thus I added the option of xmlParser to allow users to define the parsing they want to use in their messages. This part would need a documentation update, which should probably also point to the limitations mentioned in the upstream documentation.

cwtuan commented 4 months ago

Thank you for your reply. As you mentioned, this change will require an update to the documentation. Could you please update the README?

Chevindu commented 4 months ago

I'm sorry about the delay. I just updated the docs. Feel free to adjust/correct my wording.

SamuelLeclerc33 commented 4 months ago

Bump @cwtuan

cwtuan commented 3 months ago

Thank you for your contribution to this upgrade. The new version of intl-messageformat shows promise in handling rich text messages effectively. However, the potential for breaking changes could lead to disruptions in existing applications.

Internally, we're actively discussing strategies to mitigate these concerns and provide developers with the necessary tools to transition smoothly. Our suggestion is developing a tool to scan application source code and assist developers in writing correct messages. We believe such a tool could be immensely valuable in helping developers identify and address any potential issues introduced by the update.

We'd love to hear more about your thoughts on this idea and any insights you might have on how we can best implement it.

cwtuan commented 3 months ago

Another approach is to implement a new function such as intl.getComponent that supports rich text, while ensuring that the intl.getHTML function remains compatible with its previous behavior.