amannn / next-intl

🌐 Internationalization (i18n) for Next.js
https://next-intl-docs.vercel.app
MIT License
2.58k stars 236 forks source link

feat!: Make package ESM-only, target modern browsers, use modern JSX transform #1470

Closed amannn closed 2 weeks ago

amannn commented 3 weeks ago

With these optimizations, next-intl is now ~7% smaller and provides full support for tree shaking.

Features

  1. next-intl as well as its base library use-intl are now ESM-only. The only exception is next-intl/plugin which is provided both as ESM as well as CommonJS due to next.config.js still being popular.
  2. The modern JSX transform that was introduced in React 17 is now used.
  3. To reduce bundle size, syntax is compiled down to the Browserslist defaults query, which is a shortcut for > 0.5%, last 2 versions, Firefox ESR, not dead. The defaults query was thoroughly designed by the Browserslist community and is considered a reasonable default for modern apps.

Breaking changes

  1. The CommonJS build has been removed. While most tools support ESM out-of-the-box, some might require additional configuration (e.g. Jest might benefit from next/jest).
  2. The minimum required React version is 17 now.
  3. If you target outdated browsers, you can use transpilePackages in combination with a browserslist config in Next.js to compile next-intl for older browsers.
vercel[bot] commented 3 weeks ago

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
next-intl-docs βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Oct 29, 2024 9:05am
next-intl-example-app-router βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Oct 29, 2024 9:05am
next-intl-example-app-router-without-i18n-routing βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Oct 29, 2024 9:05am