Skip to content

Commit

Permalink
fix: Merge remote-tracking branch 'origin/main' into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
amannn committed Feb 18, 2025
2 parents 15c826b + a881e62 commit ca68f02
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 3.26.4 (2025-02-18)

### Bug Fixes

* Add workaround for OpenTelemetry/Zone.js ([#1719](https://github.com/amannn/next-intl/issues/1719)) ([1cac9a6](https://github.com/amannn/next-intl/commit/1cac9a65d2aefe20ff7fcf734e70f1fe85cac19d)), closes [#1711](https://github.com/amannn/next-intl/issues/1711) – by @amannn

## 3.26.3 (2024-12-20)

### Bug Fixes
Expand Down
5 changes: 3 additions & 2 deletions docs/src/pages/blog/next-intl-4-0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ I'm particularly excited about the announcement of `rootParams`, as it seems lik
2. Require locale to be returned from `getRequestConfig` (see [PR #1486](https://github.com/amannn/next-intl/pull/1486))
3. Disallow passing `null`, `undefined` or `boolean` as an ICU argument (see [PR #1561](https://github.com/amannn/next-intl/pull/1561))
4. Bump minimum required TypeScript version to 5 for projects using TypeScript (see [PR #1481](https://github.com/amannn/next-intl/pull/1481))
5. Remove deprecated APIs (see [PR #1479](https://github.com/amannn/next-intl/pull/1479))
6. Remove deprecated APIs pt. 2 (see [PR #1482](https://github.com/amannn/next-intl/pull/1482))
5. Return `x-default` alternate link also for sub pages when using `localePrefix: 'always'` and update middleware matcher suggestion in docs (see [PR #1720](https://github.com/amannn/next-intl/pull/1720))
6. Remove deprecated APIs (see [PR #1479](https://github.com/amannn/next-intl/pull/1479))
7. Remove deprecated APIs pt. 2 (see [PR #1482](https://github.com/amannn/next-intl/pull/1482))

## Upgrade now

Expand Down
6 changes: 4 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"$schema": "node_modules/@lerna-lite/cli/schemas/lerna-schema.json",
"version": "3.26.3",
"packages": ["packages/*"],
"version": "3.26.4",
"packages": [
"packages/*"
],
"npmClient": "pnpm",
"changelogPreset": "conventional-changelog-conventionalcommits",
"command": {
Expand Down
6 changes: 3 additions & 3 deletions packages/next-intl/.size-limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const config: SizeLimitConfig = [
{
name: "import * from 'next-intl' (react-server)",
path: 'dist/esm/production/index.react-server.js',
limit: '14.035 KB'
limit: '14.055 KB'
},
{
name: "import {createNavigation} from 'next-intl/navigation' (react-client)",
Expand All @@ -27,7 +27,7 @@ const config: SizeLimitConfig = [
name: "import {createNavigation} from 'next-intl/navigation' (react-server)",
path: 'dist/esm/production/navigation.react-server.js',
import: '{createNavigation}',
limit: '3.25 KB'
limit: '3.255 KB'
},
{
name: "import * from 'next-intl/server' (react-client)",
Expand All @@ -37,7 +37,7 @@ const config: SizeLimitConfig = [
{
name: "import * from 'next-intl/server' (react-server)",
path: 'dist/esm/production/server.react-server.js',
limit: '13.335 KB'
limit: '13.375 KB'
},
{
name: "import * from 'next-intl/middleware'",
Expand Down
6 changes: 6 additions & 0 deletions packages/next-intl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 3.26.4 (2025-02-18)

### Bug Fixes

* Add workaround for OpenTelemetry/Zone.js ([#1719](https://github.com/amannn/next-intl/issues/1719)) ([1cac9a6](https://github.com/amannn/next-intl/commit/1cac9a65d2aefe20ff7fcf734e70f1fe85cac19d)), closes [#1711](https://github.com/amannn/next-intl/issues/1711) – by @amannn

## 3.26.3 (2024-12-20)

### Bug Fixes
Expand Down
4 changes: 3 additions & 1 deletion packages/next-intl/__mocks__/react.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {isPromise} from '../src/shared/utils';

// @ts-expect-error -- React uses CJS
export * from 'react';

export {default} from 'react';

export function use(promise: Promise<unknown> & {value?: unknown}) {
if (!(promise instanceof Promise)) {
if (!isPromise(promise)) {
throw new Error('Expected a promise, got ' + typeof promise);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/next-intl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-intl",
"version": "3.26.3",
"version": "3.26.4",
"sideEffects": false,
"author": "Jan Amann <[email protected]>",
"funding": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type {
} from '../../routing/types.js';
import type {ParametersExceptFirst, Prettify} from '../../shared/types.js';
import use from '../../shared/use.js';
import {isLocalizableHref} from '../../shared/utils.js';
import {isLocalizableHref, isPromise} from '../../shared/utils.js';
import BaseLink from './BaseLink.js';
import {
type HrefOrHrefWithParams,
Expand Down Expand Up @@ -107,10 +107,9 @@ export default function createSharedNavigationFns<
const isLocalizable = isLocalizableHref(href);

const localePromiseOrValue = getLocale();
const curLocale =
localePromiseOrValue instanceof Promise
? use(localePromiseOrValue)
: localePromiseOrValue;
const curLocale = isPromise(localePromiseOrValue)
? use(localePromiseOrValue)
: localePromiseOrValue;

const finalPathname = isLocalizable
? getPathname(
Expand Down
3 changes: 2 additions & 1 deletion packages/next-intl/src/react-server/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {describe, expect, it, vi} from 'vitest';
import {getTranslations} from '../server.react-server.js';
import {isPromise} from '../shared/utils.js';
import {renderToStream} from './testUtils.js';
import {
_createCache,
Expand Down Expand Up @@ -72,7 +73,7 @@ describe('performance', () => {
try {
useTranslations('Component');
} catch (promiseOrError) {
if (promiseOrError instanceof Promise) {
if (isPromise(promiseOrError)) {
await promiseOrError;
useTranslations('Component');
} else {
Expand Down
5 changes: 2 additions & 3 deletions packages/next-intl/src/server/react-server/RequestLocale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import {headers} from 'next/headers.js';
import {cache} from 'react';
import type {Locale} from 'use-intl';
import {HEADER_LOCALE_NAME} from '../../shared/constants.js';
import {isPromise} from '../../shared/utils.js';
import {getCachedRequestLocale} from './RequestLocaleCache.js';

async function getHeadersImpl(): Promise<Headers> {
const promiseOrValue = headers();

// Compatibility with Next.js <15
return promiseOrValue instanceof Promise
? await promiseOrValue
: promiseOrValue;
return isPromise(promiseOrValue) ? await promiseOrValue : promiseOrValue;
}
const getHeaders = cache(getHeadersImpl);

Expand Down
3 changes: 2 additions & 1 deletion packages/next-intl/src/server/react-server/getConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
_createIntlFormatters,
initializeConfig
} from 'use-intl/core';
import {isPromise} from '../../shared/utils.js';
import {getRequestLocale} from './RequestLocale.js';
import createRequestConfig from './createRequestConfig.js';
import type {GetRequestConfigParams} from './getRequestConfig.js';
Expand Down Expand Up @@ -52,7 +53,7 @@ See also: https://next-intl.dev/docs/usage/configuration#i18n-request
};

let result = getConfig(params);
if (result instanceof Promise) {
if (isPromise(result)) {
result = await result;
}

Expand Down
7 changes: 7 additions & 0 deletions packages/next-intl/src/shared/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,10 @@ function comparePathnamePairs(a: string, b: string): number {
export function getSortedPathnames(pathnames: Array<string>) {
return pathnames.sort(comparePathnamePairs);
}

export function isPromise<Value>(
value: Value | Promise<Value>
): value is Promise<Value> {
// https://github.com/amannn/next-intl/issues/1711
return typeof (value as any).then === 'function';
}
6 changes: 6 additions & 0 deletions packages/use-intl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 3.26.4 (2025-02-18)

### Bug Fixes

* Add workaround for OpenTelemetry/Zone.js ([#1719](https://github.com/amannn/next-intl/issues/1719)) ([1cac9a6](https://github.com/amannn/next-intl/commit/1cac9a65d2aefe20ff7fcf734e70f1fe85cac19d)), closes [#1711](https://github.com/amannn/next-intl/issues/1711) – by @amannn

## 3.26.3 (2024-12-20)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion packages/use-intl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "use-intl",
"version": "3.26.3",
"version": "3.26.4",
"sideEffects": false,
"author": "Jan Amann <[email protected]>",
"description": "Internationalization (i18n) for React",
Expand Down

0 comments on commit ca68f02

Please sign in to comment.