From 5b218d4123697a6cc3efe26a74675451a33c3fd6 Mon Sep 17 00:00:00 2001 From: Thomas Wiringa Date: Fri, 24 Jan 2025 11:14:26 +0100 Subject: [PATCH] fix: Change imports to use `.js` to make them compatible with `eslint-plugin-import` (#1667) @amannn Following our conversation on X, these are the changes that I've made that appear to be fixing the imports when the `import/named` ESLint rule is used. As mentioned before, I also took the liberty of adding the ESLint rule `'import/extensions': 'error'` to ensure the right extensions are used in the import/export statements. For context, when compiling to ESM modules, TS copies over the import/export statements as-is, so during development, runtime compatible file extensions must be used. For local testing I ran a build and then manually copied over the `dist` folder into `node_modules/next-intl` in my other project. --- packages/next-intl/eslint.config.mjs | 3 +- packages/next-intl/src/index.react-client.tsx | 2 +- packages/next-intl/src/index.react-server.tsx | 2 +- packages/next-intl/src/middleware.tsx | 2 +- .../getAlternateLinksHeaderValue.test.tsx | 6 +-- .../getAlternateLinksHeaderValue.tsx | 8 ++-- packages/next-intl/src/middleware/index.tsx | 2 +- .../src/middleware/middleware.test.tsx | 4 +- .../next-intl/src/middleware/middleware.tsx | 16 ++++---- .../src/middleware/resolveLocale.test.tsx | 2 +- .../src/middleware/resolveLocale.tsx | 10 ++--- .../next-intl/src/middleware/syncCookie.tsx | 6 +-- .../next-intl/src/middleware/utils.test.tsx | 2 +- packages/next-intl/src/middleware/utils.tsx | 4 +- .../next-intl/src/navigation.react-client.tsx | 2 +- .../next-intl/src/navigation.react-server.tsx | 2 +- .../src/navigation/createNavigation.test.tsx | 12 ++---- .../react-client/createNavigation.test.tsx | 4 +- .../react-client/createNavigation.tsx | 12 +++--- .../src/navigation/react-client/index.tsx | 4 +- .../react-client/useBasePathname.test.tsx | 4 +- .../react-client/useBasePathname.tsx | 4 +- .../react-server/createNavigation.test.tsx | 2 +- .../react-server/createNavigation.tsx | 8 ++-- .../react-server/getServerLocale.tsx | 2 +- .../src/navigation/react-server/index.tsx | 4 +- .../src/navigation/shared/BaseLink.tsx | 4 +- .../shared/createSharedNavigationFns.tsx | 14 +++---- .../navigation/shared/syncLocaleCookie.tsx | 4 +- .../src/navigation/shared/utils.test.tsx | 2 +- .../next-intl/src/navigation/shared/utils.tsx | 8 ++-- packages/next-intl/src/plugin.tsx | 2 +- .../src/plugin/createMessagesDeclaration.tsx | 2 +- .../src/plugin/createNextIntlPlugin.tsx | 8 ++-- .../next-intl/src/plugin/getNextConfig.tsx | 4 +- packages/next-intl/src/plugin/index.tsx | 2 +- packages/next-intl/src/react-client/index.tsx | 2 +- .../src/react-client/useFormatter.test.tsx | 2 +- .../src/react-client/useNow.test.tsx | 2 +- .../src/react-client/useTimeZone.test.tsx | 2 +- .../src/react-client/useTranslations.test.tsx | 2 +- .../NextIntlClientProviderServer.test.tsx | 10 ++--- .../NextIntlClientProviderServer.tsx | 8 ++-- .../next-intl/src/react-server/index.test.tsx | 6 +-- packages/next-intl/src/react-server/index.tsx | 14 +++---- .../next-intl/src/react-server/useConfig.tsx | 4 +- .../src/react-server/useFormatter.test.tsx | 6 +-- .../src/react-server/useFormatter.tsx | 4 +- .../next-intl/src/react-server/useLocale.tsx | 2 +- .../src/react-server/useMessages.tsx | 4 +- .../next-intl/src/react-server/useNow.tsx | 4 +- .../src/react-server/useTimeZone.tsx | 2 +- .../src/react-server/useTranslations.test.tsx | 4 +- .../src/react-server/useTranslations.tsx | 4 +- packages/next-intl/src/routing.tsx | 2 +- packages/next-intl/src/routing/config.tsx | 2 +- .../src/routing/defineRouting.test.tsx | 2 +- .../next-intl/src/routing/defineRouting.tsx | 6 +-- packages/next-intl/src/routing/index.tsx | 6 +-- packages/next-intl/src/routing/types.test.tsx | 2 +- .../src/routing/validateLocales.test.tsx | 2 +- .../next-intl/src/routing/validateLocales.tsx | 2 +- .../next-intl/src/server.react-client.tsx | 2 +- .../next-intl/src/server.react-server.tsx | 2 +- .../src/server/react-client/index.test.tsx | 2 +- .../src/server/react-client/index.tsx | 2 +- .../src/server/react-server/RequestLocale.tsx | 4 +- .../react-server/createRequestConfig.tsx | 2 +- .../src/server/react-server/getConfig.tsx | 6 +-- .../src/server/react-server/getConfigNow.tsx | 2 +- .../src/server/react-server/getFormats.tsx | 2 +- .../server/react-server/getFormatter.test.tsx | 4 +- .../src/server/react-server/getFormatter.tsx | 4 +- .../src/server/react-server/getLocale.tsx | 2 +- .../src/server/react-server/getMessages.tsx | 2 +- .../src/server/react-server/getNow.tsx | 4 +- .../react-server/getServerFormatter.tsx | 2 +- .../src/server/react-server/getTimeZone.tsx | 2 +- .../react-server/getTranslations.test.tsx | 2 +- .../server/react-server/getTranslations.tsx | 4 +- .../src/server/react-server/index.test.tsx | 4 +- .../src/server/react-server/index.tsx | 16 ++++---- packages/next-intl/src/shared/utils.test.tsx | 2 +- packages/next-intl/src/shared/utils.tsx | 2 +- packages/next-intl/tsconfig.json | 1 - packages/use-intl/eslint.config.mjs | 3 +- packages/use-intl/src/core.tsx | 2 +- .../src/core/DateTimeFormatOptions.tsx | 2 +- packages/use-intl/src/core/Formats.tsx | 4 +- packages/use-intl/src/core/IntlConfig.tsx | 10 ++--- packages/use-intl/src/core/IntlError.tsx | 2 +- .../convertFormatsToIntlMessageFormat.tsx | 4 +- .../src/core/createBaseTranslator.tsx | 24 +++++------ .../src/core/createFormatter.test.tsx | 2 +- .../use-intl/src/core/createFormatter.tsx | 20 +++++----- .../src/core/createTranslator.test.tsx | 8 ++-- .../use-intl/src/core/createTranslator.tsx | 20 +++++----- .../src/core/createTranslatorImpl.tsx | 12 +++--- packages/use-intl/src/core/defaults.tsx | 4 +- packages/use-intl/src/core/hasLocale.test.tsx | 2 +- packages/use-intl/src/core/hasLocale.tsx | 2 +- packages/use-intl/src/core/index.tsx | 40 +++++++++---------- .../use-intl/src/core/initializeConfig.tsx | 6 +-- .../use-intl/src/core/validateMessages.tsx | 8 ++-- packages/use-intl/src/index.tsx | 4 +- packages/use-intl/src/react.tsx | 2 +- packages/use-intl/src/react/IntlContext.tsx | 4 +- .../use-intl/src/react/IntlProvider.test.tsx | 6 +-- packages/use-intl/src/react/IntlProvider.tsx | 8 ++-- packages/use-intl/src/react/index.test.tsx | 10 ++--- packages/use-intl/src/react/index.tsx | 14 +++---- .../use-intl/src/react/useFormatter.test.tsx | 6 +-- packages/use-intl/src/react/useFormatter.tsx | 4 +- .../use-intl/src/react/useIntlContext.tsx | 2 +- .../use-intl/src/react/useLocale.test.tsx | 4 +- packages/use-intl/src/react/useLocale.tsx | 4 +- .../use-intl/src/react/useMessages.test.tsx | 4 +- packages/use-intl/src/react/useMessages.tsx | 4 +- packages/use-intl/src/react/useNow.test.tsx | 4 +- packages/use-intl/src/react/useNow.tsx | 2 +- .../use-intl/src/react/useTimeZone.test.tsx | 4 +- packages/use-intl/src/react/useTimeZone.tsx | 2 +- .../src/react/useTranslations.test.tsx | 6 +-- .../use-intl/src/react/useTranslations.tsx | 10 ++--- .../src/react/useTranslationsImpl.tsx | 12 +++--- packages/use-intl/tsconfig.json | 1 - 126 files changed, 322 insertions(+), 330 deletions(-) diff --git a/packages/next-intl/eslint.config.mjs b/packages/next-intl/eslint.config.mjs index a2d92e6aa..9308ce875 100644 --- a/packages/next-intl/eslint.config.mjs +++ b/packages/next-intl/eslint.config.mjs @@ -27,6 +27,7 @@ export default (await getPresets('typescript', 'react', 'vitest')).concat({ '@typescript-eslint/consistent-type-imports': 'error', '@typescript-eslint/consistent-type-exports': 'error', '@typescript-eslint/no-import-type-side-effects': 'error', - 'import/no-duplicates': ['error', {'prefer-inline': true}] + 'import/no-duplicates': ['error', {'prefer-inline': true}], + 'import/extensions': 'error' } }); diff --git a/packages/next-intl/src/index.react-client.tsx b/packages/next-intl/src/index.react-client.tsx index d1d057aec..ccc872cea 100644 --- a/packages/next-intl/src/index.react-client.tsx +++ b/packages/next-intl/src/index.react-client.tsx @@ -6,4 +6,4 @@ * from `./react-server` instead. */ -export * from './react-client/index.tsx'; +export * from './react-client/index.js'; diff --git a/packages/next-intl/src/index.react-server.tsx b/packages/next-intl/src/index.react-server.tsx index 172bd7da0..b80740326 100644 --- a/packages/next-intl/src/index.react-server.tsx +++ b/packages/next-intl/src/index.react-server.tsx @@ -1 +1 @@ -export * from './react-server/index.tsx'; +export * from './react-server/index.js'; diff --git a/packages/next-intl/src/middleware.tsx b/packages/next-intl/src/middleware.tsx index 0943679ef..d02f285ee 100644 --- a/packages/next-intl/src/middleware.tsx +++ b/packages/next-intl/src/middleware.tsx @@ -1 +1 @@ -export {default} from './middleware/index.tsx'; +export {default} from './middleware/index.js'; diff --git a/packages/next-intl/src/middleware/getAlternateLinksHeaderValue.test.tsx b/packages/next-intl/src/middleware/getAlternateLinksHeaderValue.test.tsx index 562331ec8..5ef8dd183 100644 --- a/packages/next-intl/src/middleware/getAlternateLinksHeaderValue.test.tsx +++ b/packages/next-intl/src/middleware/getAlternateLinksHeaderValue.test.tsx @@ -2,9 +2,9 @@ import {NextRequest} from 'next/server.js'; import {afterEach, beforeEach, describe, expect, it} from 'vitest'; -import {receiveRoutingConfig} from '../routing/config.tsx'; -import type {Pathnames} from '../routing.tsx'; -import getAlternateLinksHeaderValue from './getAlternateLinksHeaderValue.tsx'; +import {receiveRoutingConfig} from '../routing/config.js'; +import type {Pathnames} from '../routing.js'; +import getAlternateLinksHeaderValue from './getAlternateLinksHeaderValue.js'; describe.each([{basePath: undefined}, {basePath: '/base'}])( 'basePath: $basePath', diff --git a/packages/next-intl/src/middleware/getAlternateLinksHeaderValue.tsx b/packages/next-intl/src/middleware/getAlternateLinksHeaderValue.tsx index 52f627ba3..fbe9e44b6 100644 --- a/packages/next-intl/src/middleware/getAlternateLinksHeaderValue.tsx +++ b/packages/next-intl/src/middleware/getAlternateLinksHeaderValue.tsx @@ -1,12 +1,12 @@ import type {NextRequest} from 'next/server.js'; -import type {ResolvedRoutingConfig} from '../routing/config.tsx'; +import type {ResolvedRoutingConfig} from '../routing/config.js'; import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames -} from '../routing/types.tsx'; -import {normalizeTrailingSlash} from '../shared/utils.tsx'; +} from '../routing/types.js'; +import {normalizeTrailingSlash} from '../shared/utils.js'; import { applyBasePath, formatTemplatePathname, @@ -14,7 +14,7 @@ import { getLocalePrefixes, getNormalizedPathname, isLocaleSupportedOnDomain -} from './utils.tsx'; +} from './utils.js'; /** * See https://developers.google.com/search/docs/specialty/international/localized-versions diff --git a/packages/next-intl/src/middleware/index.tsx b/packages/next-intl/src/middleware/index.tsx index 0cb9c5e88..b5a6b6397 100644 --- a/packages/next-intl/src/middleware/index.tsx +++ b/packages/next-intl/src/middleware/index.tsx @@ -2,4 +2,4 @@ * The middleware, available as `next-intl/middleware`. */ -export {default} from './middleware.tsx'; +export {default} from './middleware.js'; diff --git a/packages/next-intl/src/middleware/middleware.test.tsx b/packages/next-intl/src/middleware/middleware.test.tsx index ea4fd43f8..6801f7baf 100644 --- a/packages/next-intl/src/middleware/middleware.test.tsx +++ b/packages/next-intl/src/middleware/middleware.test.tsx @@ -12,8 +12,8 @@ import { it, vi } from 'vitest'; -import createMiddleware from '../middleware.tsx'; -import {type Pathnames, defineRouting} from '../routing.tsx'; +import createMiddleware from '../middleware.js'; +import {type Pathnames, defineRouting} from '../routing.js'; const COOKIE_LOCALE_NAME = 'NEXT_LOCALE'; diff --git a/packages/next-intl/src/middleware/middleware.tsx b/packages/next-intl/src/middleware/middleware.tsx index c41100d4e..066c488a3 100644 --- a/packages/next-intl/src/middleware/middleware.tsx +++ b/packages/next-intl/src/middleware/middleware.tsx @@ -1,20 +1,20 @@ import {type NextRequest, NextResponse} from 'next/server.js'; -import {type RoutingConfig, receiveRoutingConfig} from '../routing/config.tsx'; +import {type RoutingConfig, receiveRoutingConfig} from '../routing/config.js'; import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames -} from '../routing/types.tsx'; -import {HEADER_LOCALE_NAME} from '../shared/constants.tsx'; +} from '../routing/types.js'; +import {HEADER_LOCALE_NAME} from '../shared/constants.js'; import { getLocalePrefix, matchesPathname, normalizeTrailingSlash -} from '../shared/utils.tsx'; -import getAlternateLinksHeaderValue from './getAlternateLinksHeaderValue.tsx'; -import resolveLocale from './resolveLocale.tsx'; -import syncCookie from './syncCookie.tsx'; +} from '../shared/utils.js'; +import getAlternateLinksHeaderValue from './getAlternateLinksHeaderValue.js'; +import resolveLocale from './resolveLocale.js'; +import syncCookie from './syncCookie.js'; import { applyBasePath, formatPathname, @@ -26,7 +26,7 @@ import { getPathnameMatch, isLocaleSupportedOnDomain, sanitizePathname -} from './utils.tsx'; +} from './utils.js'; export default function createMiddleware< const AppLocales extends Locales, diff --git a/packages/next-intl/src/middleware/resolveLocale.test.tsx b/packages/next-intl/src/middleware/resolveLocale.test.tsx index 93a7bdfd8..338536132 100644 --- a/packages/next-intl/src/middleware/resolveLocale.test.tsx +++ b/packages/next-intl/src/middleware/resolveLocale.test.tsx @@ -1,5 +1,5 @@ import {describe, expect, it} from 'vitest'; -import {getAcceptLanguageLocale} from './resolveLocale.tsx'; +import {getAcceptLanguageLocale} from './resolveLocale.js'; describe('getAcceptLanguageLocale', () => { it('resolves a more specific locale to a generic one', () => { diff --git a/packages/next-intl/src/middleware/resolveLocale.tsx b/packages/next-intl/src/middleware/resolveLocale.tsx index ee4abdea0..71653e072 100644 --- a/packages/next-intl/src/middleware/resolveLocale.tsx +++ b/packages/next-intl/src/middleware/resolveLocale.tsx @@ -2,19 +2,15 @@ import {match} from '@formatjs/intl-localematcher'; import Negotiator from 'negotiator'; import type {RequestCookies} from 'next/dist/server/web/spec-extension/cookies.js'; import type {Locale} from 'use-intl'; -import type {ResolvedRoutingConfig} from '../routing/config.tsx'; +import type {ResolvedRoutingConfig} from '../routing/config.js'; import type { DomainConfig, DomainsConfig, LocalePrefixMode, Locales, Pathnames -} from '../routing/types.tsx'; -import { - getHost, - getPathnameMatch, - isLocaleSupportedOnDomain -} from './utils.tsx'; +} from '../routing/types.js'; +import {getHost, getPathnameMatch, isLocaleSupportedOnDomain} from './utils.js'; function findDomainFromHost( requestHeaders: Headers, diff --git a/packages/next-intl/src/middleware/syncCookie.tsx b/packages/next-intl/src/middleware/syncCookie.tsx index b37015cd4..42619882c 100644 --- a/packages/next-intl/src/middleware/syncCookie.tsx +++ b/packages/next-intl/src/middleware/syncCookie.tsx @@ -3,15 +3,15 @@ import type {Locale} from 'use-intl'; import type { InitializedLocaleCookieConfig, ResolvedRoutingConfig -} from '../routing/config.tsx'; +} from '../routing/config.js'; import type { DomainConfig, DomainsConfig, LocalePrefixMode, Locales, Pathnames -} from '../routing/types.tsx'; -import {getAcceptLanguageLocale} from './resolveLocale.tsx'; +} from '../routing/types.js'; +import {getAcceptLanguageLocale} from './resolveLocale.js'; export default function syncCookie< AppLocales extends Locales, diff --git a/packages/next-intl/src/middleware/utils.test.tsx b/packages/next-intl/src/middleware/utils.test.tsx index 61a0a1ecd..44e554566 100644 --- a/packages/next-intl/src/middleware/utils.test.tsx +++ b/packages/next-intl/src/middleware/utils.test.tsx @@ -5,7 +5,7 @@ import { getNormalizedPathname, getPathnameMatch, getRouteParams -} from './utils.tsx'; +} from './utils.js'; describe('getNormalizedPathname', () => { it('should return the normalized pathname', () => { diff --git a/packages/next-intl/src/middleware/utils.tsx b/packages/next-intl/src/middleware/utils.tsx index 996368ac9..b075ae15d 100644 --- a/packages/next-intl/src/middleware/utils.tsx +++ b/packages/next-intl/src/middleware/utils.tsx @@ -6,7 +6,7 @@ import type { LocalePrefixMode, Locales, Pathnames -} from '../routing/types.tsx'; +} from '../routing/types.js'; import { getLocalePrefix, getSortedPathnames, @@ -14,7 +14,7 @@ import { normalizeTrailingSlash, prefixPathname, templateToRegex -} from '../shared/utils.tsx'; +} from '../shared/utils.js'; export function getFirstPathnameSegment(pathname: string) { return pathname.split('/')[1]; diff --git a/packages/next-intl/src/navigation.react-client.tsx b/packages/next-intl/src/navigation.react-client.tsx index 1b752df45..690c40fe3 100644 --- a/packages/next-intl/src/navigation.react-client.tsx +++ b/packages/next-intl/src/navigation.react-client.tsx @@ -1 +1 @@ -export * from './navigation/react-client/index.tsx'; +export * from './navigation/react-client/index.js'; diff --git a/packages/next-intl/src/navigation.react-server.tsx b/packages/next-intl/src/navigation.react-server.tsx index de1da08cd..62fcb6ec3 100644 --- a/packages/next-intl/src/navigation.react-server.tsx +++ b/packages/next-intl/src/navigation.react-server.tsx @@ -1 +1 @@ -export * from './navigation/react-server/index.tsx'; +export * from './navigation/react-server/index.js'; diff --git a/packages/next-intl/src/navigation/createNavigation.test.tsx b/packages/next-intl/src/navigation/createNavigation.test.tsx index a6ea4c698..abe1b113a 100644 --- a/packages/next-intl/src/navigation/createNavigation.test.tsx +++ b/packages/next-intl/src/navigation/createNavigation.test.tsx @@ -7,14 +7,10 @@ import { import {renderToString} from 'react-dom/server'; import {type Locale, useLocale} from 'use-intl'; import {beforeEach, describe, expect, it, vi} from 'vitest'; -import { - type DomainsConfig, - type Pathnames, - defineRouting -} from '../routing.tsx'; -import createNavigationClient from './react-client/createNavigation.tsx'; -import createNavigationServer from './react-server/createNavigation.tsx'; -import getServerLocale from './react-server/getServerLocale.tsx'; +import {type DomainsConfig, type Pathnames, defineRouting} from '../routing.js'; +import createNavigationClient from './react-client/createNavigation.js'; +import createNavigationServer from './react-server/createNavigation.js'; +import getServerLocale from './react-server/getServerLocale.js'; vi.mock('react'); vi.mock('next/navigation.js', async () => ({ diff --git a/packages/next-intl/src/navigation/react-client/createNavigation.test.tsx b/packages/next-intl/src/navigation/react-client/createNavigation.test.tsx index 4ff993686..238aaad2d 100644 --- a/packages/next-intl/src/navigation/react-client/createNavigation.test.tsx +++ b/packages/next-intl/src/navigation/react-client/createNavigation.test.tsx @@ -5,8 +5,8 @@ import { } from 'next/navigation.js'; import {type Locale, useLocale} from 'use-intl'; import {beforeEach, describe, expect, it, vi} from 'vitest'; -import type {DomainsConfig, Pathnames} from '../../routing.tsx'; -import createNavigation from './createNavigation.tsx'; +import type {DomainsConfig, Pathnames} from '../../routing.js'; +import createNavigation from './createNavigation.js'; vi.mock('next/navigation.js'); vi.mock('use-intl', async () => ({ diff --git a/packages/next-intl/src/navigation/react-client/createNavigation.tsx b/packages/next-intl/src/navigation/react-client/createNavigation.tsx index 68f97e3b9..a1e712295 100644 --- a/packages/next-intl/src/navigation/react-client/createNavigation.tsx +++ b/packages/next-intl/src/navigation/react-client/createNavigation.tsx @@ -7,17 +7,17 @@ import {type Locale, useLocale} from 'use-intl'; import type { RoutingConfigLocalizedNavigation, RoutingConfigSharedNavigation -} from '../../routing/config.tsx'; +} from '../../routing/config.js'; import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames -} from '../../routing/types.tsx'; -import createSharedNavigationFns from '../shared/createSharedNavigationFns.tsx'; -import syncLocaleCookie from '../shared/syncLocaleCookie.tsx'; -import {getRoute} from '../shared/utils.tsx'; -import useBasePathname from './useBasePathname.tsx'; +} from '../../routing/types.js'; +import createSharedNavigationFns from '../shared/createSharedNavigationFns.js'; +import syncLocaleCookie from '../shared/syncLocaleCookie.js'; +import {getRoute} from '../shared/utils.js'; +import useBasePathname from './useBasePathname.js'; export default function createNavigation< const AppLocales extends Locales, diff --git a/packages/next-intl/src/navigation/react-client/index.tsx b/packages/next-intl/src/navigation/react-client/index.tsx index c3cb1a965..c2f39bbc0 100644 --- a/packages/next-intl/src/navigation/react-client/index.tsx +++ b/packages/next-intl/src/navigation/react-client/index.tsx @@ -1,2 +1,2 @@ -export {default as createNavigation} from './createNavigation.tsx'; -export type {QueryParams} from '../shared/utils.tsx'; +export {default as createNavigation} from './createNavigation.js'; +export type {QueryParams} from '../shared/utils.js'; diff --git a/packages/next-intl/src/navigation/react-client/useBasePathname.test.tsx b/packages/next-intl/src/navigation/react-client/useBasePathname.test.tsx index 715256f4e..f12a60977 100644 --- a/packages/next-intl/src/navigation/react-client/useBasePathname.test.tsx +++ b/packages/next-intl/src/navigation/react-client/useBasePathname.test.tsx @@ -1,8 +1,8 @@ import {render, screen} from '@testing-library/react'; import {usePathname as useNextPathname} from 'next/navigation.js'; import {beforeEach, describe, expect, it, vi} from 'vitest'; -import {NextIntlClientProvider, useLocale} from '../../index.react-client.tsx'; -import useBasePathname from './useBasePathname.tsx'; +import {NextIntlClientProvider, useLocale} from '../../index.react-client.js'; +import useBasePathname from './useBasePathname.js'; vi.mock('next/navigation.js'); vi.mock('use-intl', async () => ({ diff --git a/packages/next-intl/src/navigation/react-client/useBasePathname.tsx b/packages/next-intl/src/navigation/react-client/useBasePathname.tsx index 5e283ff17..e7ced2828 100644 --- a/packages/next-intl/src/navigation/react-client/useBasePathname.tsx +++ b/packages/next-intl/src/navigation/react-client/useBasePathname.tsx @@ -5,13 +5,13 @@ import type { LocalePrefixConfigVerbose, LocalePrefixMode, Locales -} from '../../routing/types.tsx'; +} from '../../routing/types.js'; import { getLocaleAsPrefix, getLocalePrefix, hasPathnamePrefixed, unprefixPathname -} from '../../shared/utils.tsx'; +} from '../../shared/utils.js'; export default function useBasePathname< AppLocales extends Locales, diff --git a/packages/next-intl/src/navigation/react-server/createNavigation.test.tsx b/packages/next-intl/src/navigation/react-server/createNavigation.test.tsx index 73277434f..18f48d8b3 100644 --- a/packages/next-intl/src/navigation/react-server/createNavigation.test.tsx +++ b/packages/next-intl/src/navigation/react-server/createNavigation.test.tsx @@ -1,5 +1,5 @@ import {describe, expect, it, vi} from 'vitest'; -import createNavigation from './createNavigation.tsx'; +import createNavigation from './createNavigation.js'; vi.mock('react'); diff --git a/packages/next-intl/src/navigation/react-server/createNavigation.tsx b/packages/next-intl/src/navigation/react-server/createNavigation.tsx index 96c921c58..4ccccc12e 100644 --- a/packages/next-intl/src/navigation/react-server/createNavigation.tsx +++ b/packages/next-intl/src/navigation/react-server/createNavigation.tsx @@ -1,15 +1,15 @@ import type { RoutingConfigLocalizedNavigation, RoutingConfigSharedNavigation -} from '../../routing/config.tsx'; +} from '../../routing/config.js'; import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames -} from '../../routing/types.tsx'; -import createSharedNavigationFns from '../shared/createSharedNavigationFns.tsx'; -import getServerLocale from './getServerLocale.tsx'; +} from '../../routing/types.js'; +import createSharedNavigationFns from '../shared/createSharedNavigationFns.js'; +import getServerLocale from './getServerLocale.js'; export default function createNavigation< const AppLocales extends Locales, diff --git a/packages/next-intl/src/navigation/react-server/getServerLocale.tsx b/packages/next-intl/src/navigation/react-server/getServerLocale.tsx index e6bd11965..ba8529277 100644 --- a/packages/next-intl/src/navigation/react-server/getServerLocale.tsx +++ b/packages/next-intl/src/navigation/react-server/getServerLocale.tsx @@ -1,4 +1,4 @@ -import getConfig from '../../server/react-server/getConfig.tsx'; +import getConfig from '../../server/react-server/getConfig.js'; /** * This is only moved to a separate module for easier mocking in diff --git a/packages/next-intl/src/navigation/react-server/index.tsx b/packages/next-intl/src/navigation/react-server/index.tsx index 7bc2e12ed..e1f566961 100644 --- a/packages/next-intl/src/navigation/react-server/index.tsx +++ b/packages/next-intl/src/navigation/react-server/index.tsx @@ -1,2 +1,2 @@ -export {default as createNavigation} from './createNavigation.tsx'; -export type {Pathnames} from '../../routing/types.tsx'; +export {default as createNavigation} from './createNavigation.js'; +export type {Pathnames} from '../../routing/types.js'; diff --git a/packages/next-intl/src/navigation/shared/BaseLink.tsx b/packages/next-intl/src/navigation/shared/BaseLink.tsx index 10aa07c93..0012cfe2a 100644 --- a/packages/next-intl/src/navigation/shared/BaseLink.tsx +++ b/packages/next-intl/src/navigation/shared/BaseLink.tsx @@ -11,8 +11,8 @@ import { useState } from 'react'; import {type Locale, useLocale} from 'use-intl'; -import type {InitializedLocaleCookieConfig} from '../../routing/config.tsx'; -import syncLocaleCookie from './syncLocaleCookie.tsx'; +import type {InitializedLocaleCookieConfig} from '../../routing/config.js'; +import syncLocaleCookie from './syncLocaleCookie.js'; type NextLinkProps = Omit, keyof LinkProps> & Omit; diff --git a/packages/next-intl/src/navigation/shared/createSharedNavigationFns.tsx b/packages/next-intl/src/navigation/shared/createSharedNavigationFns.tsx index 9d973300d..2cae2c352 100644 --- a/packages/next-intl/src/navigation/shared/createSharedNavigationFns.tsx +++ b/packages/next-intl/src/navigation/shared/createSharedNavigationFns.tsx @@ -8,18 +8,18 @@ import { type RoutingConfigLocalizedNavigation, type RoutingConfigSharedNavigation, receiveRoutingConfig -} from '../../routing/config.tsx'; +} from '../../routing/config.js'; import type { DomainConfig, DomainsConfig, LocalePrefixMode, Locales, Pathnames -} from '../../routing/types.tsx'; -import type {ParametersExceptFirst, Prettify} from '../../shared/types.tsx'; -import use from '../../shared/use.tsx'; -import {isLocalizableHref} from '../../shared/utils.tsx'; -import BaseLink from './BaseLink.tsx'; +} 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 BaseLink from './BaseLink.js'; import { type HrefOrHrefWithParams, type HrefOrUrlObjectWithParams, @@ -29,7 +29,7 @@ import { normalizeNameOrNameWithParams, serializeSearchParams, validateReceivedConfig -} from './utils.tsx'; +} from './utils.js'; type PromiseOrValue = Type | Promise; diff --git a/packages/next-intl/src/navigation/shared/syncLocaleCookie.tsx b/packages/next-intl/src/navigation/shared/syncLocaleCookie.tsx index 41b42531a..af826e352 100644 --- a/packages/next-intl/src/navigation/shared/syncLocaleCookie.tsx +++ b/packages/next-intl/src/navigation/shared/syncLocaleCookie.tsx @@ -1,6 +1,6 @@ import type {Locale} from 'use-intl'; -import type {InitializedLocaleCookieConfig} from '../../routing/config.tsx'; -import {getBasePath} from './utils.tsx'; +import type {InitializedLocaleCookieConfig} from '../../routing/config.js'; +import {getBasePath} from './utils.js'; /** * We have to keep the cookie value in sync as Next.js might diff --git a/packages/next-intl/src/navigation/shared/utils.test.tsx b/packages/next-intl/src/navigation/shared/utils.test.tsx index 1e99fe485..1e59939e8 100644 --- a/packages/next-intl/src/navigation/shared/utils.test.tsx +++ b/packages/next-intl/src/navigation/shared/utils.test.tsx @@ -3,7 +3,7 @@ import { compileLocalizedPathname, getBasePath, serializeSearchParams -} from './utils.tsx'; +} from './utils.js'; describe('serializeSearchParams', () => { it('handles strings', () => { diff --git a/packages/next-intl/src/navigation/shared/utils.tsx b/packages/next-intl/src/navigation/shared/utils.tsx index 26f6372f0..ac92fa530 100644 --- a/packages/next-intl/src/navigation/shared/utils.tsx +++ b/packages/next-intl/src/navigation/shared/utils.tsx @@ -1,13 +1,13 @@ import type {ParsedUrlQueryInput} from 'node:querystring'; import type {UrlObject} from 'url'; import type {Locale} from 'use-intl'; -import type {ResolvedRoutingConfig} from '../../routing/config.tsx'; +import type {ResolvedRoutingConfig} from '../../routing/config.js'; import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames -} from '../../routing/types.tsx'; +} from '../../routing/types.js'; import { getLocalePrefix, getSortedPathnames, @@ -15,8 +15,8 @@ import { matchesPathname, normalizeTrailingSlash, prefixPathname -} from '../../shared/utils.tsx'; -import type StrictParams from './StrictParams.tsx'; +} from '../../shared/utils.js'; +import type StrictParams from './StrictParams.js'; type SearchParamValue = ParsedUrlQueryInput[keyof ParsedUrlQueryInput]; diff --git a/packages/next-intl/src/plugin.tsx b/packages/next-intl/src/plugin.tsx index ef53890a0..3963d42d9 100644 --- a/packages/next-intl/src/plugin.tsx +++ b/packages/next-intl/src/plugin.tsx @@ -1 +1 @@ -export {default} from './plugin/index.tsx'; +export {default} from './plugin/index.js'; diff --git a/packages/next-intl/src/plugin/createMessagesDeclaration.tsx b/packages/next-intl/src/plugin/createMessagesDeclaration.tsx index 1fc6b2427..ee40aafd7 100644 --- a/packages/next-intl/src/plugin/createMessagesDeclaration.tsx +++ b/packages/next-intl/src/plugin/createMessagesDeclaration.tsx @@ -1,6 +1,6 @@ import fs from 'fs'; import path from 'path'; -import {throwError} from './utils.tsx'; +import {throwError} from './utils.js'; function runOnce(fn: () => void) { if (process.env._NEXT_INTL_COMPILE_MESSAGES === '1') { diff --git a/packages/next-intl/src/plugin/createNextIntlPlugin.tsx b/packages/next-intl/src/plugin/createNextIntlPlugin.tsx index c6464a960..bc60f83fb 100644 --- a/packages/next-intl/src/plugin/createNextIntlPlugin.tsx +++ b/packages/next-intl/src/plugin/createNextIntlPlugin.tsx @@ -1,8 +1,8 @@ import type {NextConfig} from 'next'; -import createMessagesDeclaration from './createMessagesDeclaration.tsx'; -import getNextConfig from './getNextConfig.tsx'; -import type {PluginConfig} from './types.tsx'; -import {warn} from './utils.tsx'; +import createMessagesDeclaration from './createMessagesDeclaration.js'; +import getNextConfig from './getNextConfig.js'; +import type {PluginConfig} from './types.js'; +import {warn} from './utils.js'; function initPlugin( pluginConfig: PluginConfig, diff --git a/packages/next-intl/src/plugin/getNextConfig.tsx b/packages/next-intl/src/plugin/getNextConfig.tsx index f417a0028..5b7f8d277 100644 --- a/packages/next-intl/src/plugin/getNextConfig.tsx +++ b/packages/next-intl/src/plugin/getNextConfig.tsx @@ -1,8 +1,8 @@ import fs from 'fs'; import path from 'path'; import type {NextConfig} from 'next'; -import type {PluginConfig} from './types.tsx'; -import {throwError} from './utils.tsx'; +import type {PluginConfig} from './types.js'; +import {throwError} from './utils.js'; function withExtensions(localPath: string) { return [ diff --git a/packages/next-intl/src/plugin/index.tsx b/packages/next-intl/src/plugin/index.tsx index d3403203e..06c26f724 100644 --- a/packages/next-intl/src/plugin/index.tsx +++ b/packages/next-intl/src/plugin/index.tsx @@ -1 +1 @@ -export {default} from './createNextIntlPlugin.tsx'; +export {default} from './createNextIntlPlugin.js'; diff --git a/packages/next-intl/src/react-client/index.tsx b/packages/next-intl/src/react-client/index.tsx index dbfac9656..0e7fe3d0e 100644 --- a/packages/next-intl/src/react-client/index.tsx +++ b/packages/next-intl/src/react-client/index.tsx @@ -46,4 +46,4 @@ export const useFormatter = callHook( base_useFormatter ) as typeof base_useFormatter; -export {default as NextIntlClientProvider} from '../shared/NextIntlClientProvider.tsx'; +export {default as NextIntlClientProvider} from '../shared/NextIntlClientProvider.js'; diff --git a/packages/next-intl/src/react-client/useFormatter.test.tsx b/packages/next-intl/src/react-client/useFormatter.test.tsx index d77ad0825..123f39fc5 100644 --- a/packages/next-intl/src/react-client/useFormatter.test.tsx +++ b/packages/next-intl/src/react-client/useFormatter.test.tsx @@ -1,6 +1,6 @@ import {render, screen} from '@testing-library/react'; import {expect, it} from 'vitest'; -import {NextIntlClientProvider, useFormatter} from './index.tsx'; +import {NextIntlClientProvider, useFormatter} from './index.js'; function Component() { const format = useFormatter(); diff --git a/packages/next-intl/src/react-client/useNow.test.tsx b/packages/next-intl/src/react-client/useNow.test.tsx index 82d134004..6c2e783b7 100644 --- a/packages/next-intl/src/react-client/useNow.test.tsx +++ b/packages/next-intl/src/react-client/useNow.test.tsx @@ -1,6 +1,6 @@ import {render, screen} from '@testing-library/react'; import {it} from 'vitest'; -import {NextIntlClientProvider, useNow} from './index.tsx'; +import {NextIntlClientProvider, useNow} from './index.js'; function Component() { const now = useNow(); diff --git a/packages/next-intl/src/react-client/useTimeZone.test.tsx b/packages/next-intl/src/react-client/useTimeZone.test.tsx index bae67114c..3e2b6709f 100644 --- a/packages/next-intl/src/react-client/useTimeZone.test.tsx +++ b/packages/next-intl/src/react-client/useTimeZone.test.tsx @@ -1,6 +1,6 @@ import {render, screen} from '@testing-library/react'; import {it} from 'vitest'; -import {NextIntlClientProvider, useTimeZone} from './index.tsx'; +import {NextIntlClientProvider, useTimeZone} from './index.js'; function Component() { const timeZone = useTimeZone(); diff --git a/packages/next-intl/src/react-client/useTranslations.test.tsx b/packages/next-intl/src/react-client/useTranslations.test.tsx index ac1264e8c..e74e9fc56 100644 --- a/packages/next-intl/src/react-client/useTranslations.test.tsx +++ b/packages/next-intl/src/react-client/useTranslations.test.tsx @@ -1,6 +1,6 @@ import {render, screen} from '@testing-library/react'; import {expect, it, vi} from 'vitest'; -import {NextIntlClientProvider, useTranslations} from './index.tsx'; +import {NextIntlClientProvider, useTranslations} from './index.js'; function Component() { const t = useTranslations('Component'); diff --git a/packages/next-intl/src/react-server/NextIntlClientProviderServer.test.tsx b/packages/next-intl/src/react-server/NextIntlClientProviderServer.test.tsx index 013d5e0fd..9680df759 100644 --- a/packages/next-intl/src/react-server/NextIntlClientProviderServer.test.tsx +++ b/packages/next-intl/src/react-server/NextIntlClientProviderServer.test.tsx @@ -1,9 +1,9 @@ import {expect, it, vi} from 'vitest'; -import getConfigNow from '../server/react-server/getConfigNow.tsx'; -import getFormats from '../server/react-server/getFormats.tsx'; -import {getLocale, getTimeZone} from '../server.react-server.tsx'; -import NextIntlClientProvider from '../shared/NextIntlClientProvider.tsx'; -import NextIntlClientProviderServer from './NextIntlClientProviderServer.tsx'; +import getConfigNow from '../server/react-server/getConfigNow.js'; +import getFormats from '../server/react-server/getFormats.js'; +import {getLocale, getTimeZone} from '../server.react-server.js'; +import NextIntlClientProvider from '../shared/NextIntlClientProvider.js'; +import NextIntlClientProviderServer from './NextIntlClientProviderServer.js'; vi.mock('../../src/server/react-server', async () => ({ getLocale: vi.fn(async () => 'en-US'), diff --git a/packages/next-intl/src/react-server/NextIntlClientProviderServer.tsx b/packages/next-intl/src/react-server/NextIntlClientProviderServer.tsx index abf19ee30..fc03de3d9 100644 --- a/packages/next-intl/src/react-server/NextIntlClientProviderServer.tsx +++ b/packages/next-intl/src/react-server/NextIntlClientProviderServer.tsx @@ -1,8 +1,8 @@ import type {ComponentProps} from 'react'; -import getConfigNow from '../server/react-server/getConfigNow.tsx'; -import getFormats from '../server/react-server/getFormats.tsx'; -import {getLocale, getTimeZone} from '../server.react-server.tsx'; -import BaseNextIntlClientProvider from '../shared/NextIntlClientProvider.tsx'; +import getConfigNow from '../server/react-server/getConfigNow.js'; +import getFormats from '../server/react-server/getFormats.js'; +import {getLocale, getTimeZone} from '../server.react-server.js'; +import BaseNextIntlClientProvider from '../shared/NextIntlClientProvider.js'; type Props = ComponentProps; diff --git a/packages/next-intl/src/react-server/index.test.tsx b/packages/next-intl/src/react-server/index.test.tsx index 1bbe1511b..9864cf6c5 100644 --- a/packages/next-intl/src/react-server/index.test.tsx +++ b/packages/next-intl/src/react-server/index.test.tsx @@ -1,5 +1,6 @@ import {describe, expect, it, vi} from 'vitest'; -import {getTranslations} from '../server.react-server.tsx'; +import {getTranslations} from '../server.react-server.js'; +import {renderToStream} from './testUtils.js'; import { _createCache, useFormatter, @@ -7,8 +8,7 @@ import { useMessages, useNow, useTranslations -} from './index.tsx'; -import {renderToStream} from './testUtils.tsx'; +} from './index.js'; vi.mock('react'); diff --git a/packages/next-intl/src/react-server/index.tsx b/packages/next-intl/src/react-server/index.tsx index f7bc68c7d..52c25e38d 100644 --- a/packages/next-intl/src/react-server/index.tsx +++ b/packages/next-intl/src/react-server/index.tsx @@ -7,13 +7,13 @@ */ // Replaced exports from the `react` package -export {default as useLocale} from './useLocale.tsx'; -export {default as useTranslations} from './useTranslations.tsx'; -export {default as useFormatter} from './useFormatter.tsx'; -export {default as useNow} from './useNow.tsx'; -export {default as useTimeZone} from './useTimeZone.tsx'; -export {default as useMessages} from './useMessages.tsx'; -export {default as NextIntlClientProvider} from './NextIntlClientProviderServer.tsx'; +export {default as useLocale} from './useLocale.js'; +export {default as useTranslations} from './useTranslations.js'; +export {default as useFormatter} from './useFormatter.js'; +export {default as useNow} from './useNow.js'; +export {default as useTimeZone} from './useTimeZone.js'; +export {default as useMessages} from './useMessages.js'; +export {default as NextIntlClientProvider} from './NextIntlClientProviderServer.js'; // Everything from `core` export * from 'use-intl/core'; diff --git a/packages/next-intl/src/react-server/useConfig.tsx b/packages/next-intl/src/react-server/useConfig.tsx index fcba08ca5..75d099e80 100644 --- a/packages/next-intl/src/react-server/useConfig.tsx +++ b/packages/next-intl/src/react-server/useConfig.tsx @@ -1,5 +1,5 @@ -import getConfig from '../server/react-server/getConfig.tsx'; -import use from '../shared/use.tsx'; +import getConfig from '../server/react-server/getConfig.js'; +import use from '../shared/use.js'; function useHook(hookName: string, promise: Promise) { try { diff --git a/packages/next-intl/src/react-server/useFormatter.test.tsx b/packages/next-intl/src/react-server/useFormatter.test.tsx index e6b5a3bee..b371c2ddc 100644 --- a/packages/next-intl/src/react-server/useFormatter.test.tsx +++ b/packages/next-intl/src/react-server/useFormatter.test.tsx @@ -1,7 +1,7 @@ import {describe, expect, it, vi} from 'vitest'; -import getDefaultNow from '../server/react-server/getDefaultNow.tsx'; -import {renderToStream} from './testUtils.tsx'; -import useFormatter from './useFormatter.tsx'; +import getDefaultNow from '../server/react-server/getDefaultNow.js'; +import {renderToStream} from './testUtils.js'; +import useFormatter from './useFormatter.js'; vi.mock('react'); vi.mock('../server/react-server/getDefaultNow.tsx', () => ({ diff --git a/packages/next-intl/src/react-server/useFormatter.tsx b/packages/next-intl/src/react-server/useFormatter.tsx index 7e41b86b6..b5f03ed1c 100644 --- a/packages/next-intl/src/react-server/useFormatter.tsx +++ b/packages/next-intl/src/react-server/useFormatter.tsx @@ -1,6 +1,6 @@ import type {useFormatter as useFormatterType} from 'use-intl'; -import getServerFormatter from '../server/react-server/getServerFormatter.tsx'; -import useConfig from './useConfig.tsx'; +import getServerFormatter from '../server/react-server/getServerFormatter.js'; +import useConfig from './useConfig.js'; export default function useFormatter(): ReturnType { const config = useConfig('useFormatter'); diff --git a/packages/next-intl/src/react-server/useLocale.tsx b/packages/next-intl/src/react-server/useLocale.tsx index a517f0afc..88b638dc1 100644 --- a/packages/next-intl/src/react-server/useLocale.tsx +++ b/packages/next-intl/src/react-server/useLocale.tsx @@ -1,5 +1,5 @@ import type {useLocale as useLocaleType} from 'use-intl'; -import useConfig from './useConfig.tsx'; +import useConfig from './useConfig.js'; export default function useLocale(): ReturnType { const config = useConfig('useLocale'); diff --git a/packages/next-intl/src/react-server/useMessages.tsx b/packages/next-intl/src/react-server/useMessages.tsx index 789304044..00016d160 100644 --- a/packages/next-intl/src/react-server/useMessages.tsx +++ b/packages/next-intl/src/react-server/useMessages.tsx @@ -1,6 +1,6 @@ import type {useMessages as useMessagesType} from 'use-intl'; -import {getMessagesFromConfig} from '../server/react-server/getMessages.tsx'; -import useConfig from './useConfig.tsx'; +import {getMessagesFromConfig} from '../server/react-server/getMessages.js'; +import useConfig from './useConfig.js'; export default function useMessages(): ReturnType { const config = useConfig('useMessages'); diff --git a/packages/next-intl/src/react-server/useNow.tsx b/packages/next-intl/src/react-server/useNow.tsx index 3f103db46..6580e6de4 100644 --- a/packages/next-intl/src/react-server/useNow.tsx +++ b/packages/next-intl/src/react-server/useNow.tsx @@ -1,6 +1,6 @@ import type {useNow as useNowType} from 'use-intl'; -import getDefaultNow from '../server/react-server/getDefaultNow.tsx'; -import useConfig from './useConfig.tsx'; +import getDefaultNow from '../server/react-server/getDefaultNow.js'; +import useConfig from './useConfig.js'; export default function useNow( options?: Parameters[0] diff --git a/packages/next-intl/src/react-server/useTimeZone.tsx b/packages/next-intl/src/react-server/useTimeZone.tsx index c527b20c1..a1184a29a 100644 --- a/packages/next-intl/src/react-server/useTimeZone.tsx +++ b/packages/next-intl/src/react-server/useTimeZone.tsx @@ -1,5 +1,5 @@ import type {useTimeZone as useTimeZoneType} from 'use-intl'; -import useConfig from './useConfig.tsx'; +import useConfig from './useConfig.js'; export default function useTimeZone(): ReturnType { const config = useConfig('useTimeZone'); diff --git a/packages/next-intl/src/react-server/useTranslations.test.tsx b/packages/next-intl/src/react-server/useTranslations.test.tsx index 6631d3943..df0a36ab6 100644 --- a/packages/next-intl/src/react-server/useTranslations.test.tsx +++ b/packages/next-intl/src/react-server/useTranslations.test.tsx @@ -1,7 +1,7 @@ import {cache} from 'react'; import {beforeEach, describe, expect, it, vi} from 'vitest'; -import {createTranslator, useTranslations} from './index.tsx'; -import {renderToStream} from './testUtils.tsx'; +import {renderToStream} from './testUtils.js'; +import {createTranslator, useTranslations} from './index.js'; vi.mock('../../src/server/react-server/createRequestConfig', () => ({ default: async () => ({ diff --git a/packages/next-intl/src/react-server/useTranslations.tsx b/packages/next-intl/src/react-server/useTranslations.tsx index 836b415bf..cbb6293cc 100644 --- a/packages/next-intl/src/react-server/useTranslations.tsx +++ b/packages/next-intl/src/react-server/useTranslations.tsx @@ -1,6 +1,6 @@ import type {useTranslations as useTranslationsType} from 'use-intl'; -import getServerTranslator from '../server/react-server/getServerTranslator.tsx'; -import useConfig from './useConfig.tsx'; +import getServerTranslator from '../server/react-server/getServerTranslator.js'; +import useConfig from './useConfig.js'; export default function useTranslations( ...[namespace]: Parameters diff --git a/packages/next-intl/src/routing.tsx b/packages/next-intl/src/routing.tsx index 3cb1cbc99..692879791 100644 --- a/packages/next-intl/src/routing.tsx +++ b/packages/next-intl/src/routing.tsx @@ -1 +1 @@ -export * from './routing/index.tsx'; +export * from './routing/index.js'; diff --git a/packages/next-intl/src/routing/config.tsx b/packages/next-intl/src/routing/config.tsx index 728b46663..3fc6320dc 100644 --- a/packages/next-intl/src/routing/config.tsx +++ b/packages/next-intl/src/routing/config.tsx @@ -6,7 +6,7 @@ import type { LocalePrefixMode, Locales, Pathnames -} from './types.tsx'; +} from './types.js'; type CookieAttributes = Pick< NonNullable['2']>, diff --git a/packages/next-intl/src/routing/defineRouting.test.tsx b/packages/next-intl/src/routing/defineRouting.test.tsx index d3ea1fa2a..40c4ac0dd 100644 --- a/packages/next-intl/src/routing/defineRouting.test.tsx +++ b/packages/next-intl/src/routing/defineRouting.test.tsx @@ -1,5 +1,5 @@ import {describe, it} from 'vitest'; -import defineRouting from './defineRouting.tsx'; +import defineRouting from './defineRouting.js'; describe('defaultLocale', () => { it('ensures the `defaultLocale` is within `locales`', () => { diff --git a/packages/next-intl/src/routing/defineRouting.tsx b/packages/next-intl/src/routing/defineRouting.tsx index 1b34187ce..ca087ddb3 100644 --- a/packages/next-intl/src/routing/defineRouting.tsx +++ b/packages/next-intl/src/routing/defineRouting.tsx @@ -1,11 +1,11 @@ -import type {RoutingConfig} from './config.tsx'; +import type {RoutingConfig} from './config.js'; import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames -} from './types.tsx'; -import validateLocales from './validateLocales.tsx'; +} from './types.js'; +import validateLocales from './validateLocales.js'; export default function defineRouting< const AppLocales extends Locales, diff --git a/packages/next-intl/src/routing/index.tsx b/packages/next-intl/src/routing/index.tsx index 6a8aa9cd7..db9f16bb7 100644 --- a/packages/next-intl/src/routing/index.tsx +++ b/packages/next-intl/src/routing/index.tsx @@ -3,6 +3,6 @@ export type { LocalePrefix, DomainsConfig, LocalePrefixMode -} from './types.tsx'; -export {default as defineRouting} from './defineRouting.tsx'; -export type {RoutingConfig} from './config.tsx'; +} from './types.js'; +export {default as defineRouting} from './defineRouting.js'; +export type {RoutingConfig} from './config.js'; diff --git a/packages/next-intl/src/routing/types.test.tsx b/packages/next-intl/src/routing/types.test.tsx index 5b93b4deb..5ea870f51 100644 --- a/packages/next-intl/src/routing/types.test.tsx +++ b/packages/next-intl/src/routing/types.test.tsx @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import {describe, it} from 'vitest'; -import type {DomainConfig, LocalePrefix} from './types.tsx'; +import type {DomainConfig, LocalePrefix} from './types.js'; describe('LocalePrefix', () => { it('does not require a type param for simple values', () => { diff --git a/packages/next-intl/src/routing/validateLocales.test.tsx b/packages/next-intl/src/routing/validateLocales.test.tsx index 5e6d0f851..3f04b3407 100644 --- a/packages/next-intl/src/routing/validateLocales.test.tsx +++ b/packages/next-intl/src/routing/validateLocales.test.tsx @@ -1,5 +1,5 @@ import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest'; -import validateLocales from './validateLocales.tsx'; +import validateLocales from './validateLocales.js'; describe('accepts valid formats', () => { let consoleErrorSpy: ReturnType; diff --git a/packages/next-intl/src/routing/validateLocales.tsx b/packages/next-intl/src/routing/validateLocales.tsx index ba09f20b7..fea457f43 100644 --- a/packages/next-intl/src/routing/validateLocales.tsx +++ b/packages/next-intl/src/routing/validateLocales.tsx @@ -1,4 +1,4 @@ -import type {Locales} from './types.tsx'; +import type {Locales} from './types.js'; export default function validateLocales(locales: Locales) { for (const locale of locales) { diff --git a/packages/next-intl/src/server.react-client.tsx b/packages/next-intl/src/server.react-client.tsx index 4461b2caf..cf320e6f1 100644 --- a/packages/next-intl/src/server.react-client.tsx +++ b/packages/next-intl/src/server.react-client.tsx @@ -1 +1 @@ -export * from './server/react-client/index.tsx'; +export * from './server/react-client/index.js'; diff --git a/packages/next-intl/src/server.react-server.tsx b/packages/next-intl/src/server.react-server.tsx index d5cd6fcab..9324dd03a 100644 --- a/packages/next-intl/src/server.react-server.tsx +++ b/packages/next-intl/src/server.react-server.tsx @@ -1 +1 @@ -export * from './server/react-server/index.tsx'; +export * from './server/react-server/index.js'; diff --git a/packages/next-intl/src/server/react-client/index.test.tsx b/packages/next-intl/src/server/react-client/index.test.tsx index 9ad50db29..74eab6d42 100644 --- a/packages/next-intl/src/server/react-client/index.test.tsx +++ b/packages/next-intl/src/server/react-client/index.test.tsx @@ -1,5 +1,5 @@ import {describe, expect, it} from 'vitest'; -import {getRequestConfig} from '../../server.react-client.tsx'; +import {getRequestConfig} from '../../server.react-client.js'; describe('getRequestConfig', () => { it('can be called in the outer module closure', () => { diff --git a/packages/next-intl/src/server/react-client/index.tsx b/packages/next-intl/src/server/react-client/index.tsx index 5dbc371ec..f5bc34a81 100644 --- a/packages/next-intl/src/server/react-client/index.tsx +++ b/packages/next-intl/src/server/react-client/index.tsx @@ -6,7 +6,7 @@ import type { getRequestConfig as getRequestConfig_type, getTimeZone as getTimeZone_type, setRequestLocale as setRequestLocale_type -} from '../react-server/index.tsx'; +} from '../react-server/index.js'; /** * Allows to import `next-intl/server` in non-RSC environments. diff --git a/packages/next-intl/src/server/react-server/RequestLocale.tsx b/packages/next-intl/src/server/react-server/RequestLocale.tsx index 2d9d5492f..fd028ddac 100644 --- a/packages/next-intl/src/server/react-server/RequestLocale.tsx +++ b/packages/next-intl/src/server/react-server/RequestLocale.tsx @@ -1,8 +1,8 @@ import {headers} from 'next/headers.js'; import {cache} from 'react'; import type {Locale} from 'use-intl'; -import {HEADER_LOCALE_NAME} from '../../shared/constants.tsx'; -import {getCachedRequestLocale} from './RequestLocaleCache.tsx'; +import {HEADER_LOCALE_NAME} from '../../shared/constants.js'; +import {getCachedRequestLocale} from './RequestLocaleCache.js'; async function getHeadersImpl(): Promise { const promiseOrValue = headers(); diff --git a/packages/next-intl/src/server/react-server/createRequestConfig.tsx b/packages/next-intl/src/server/react-server/createRequestConfig.tsx index a433c1f13..fbe1831ee 100644 --- a/packages/next-intl/src/server/react-server/createRequestConfig.tsx +++ b/packages/next-intl/src/server/react-server/createRequestConfig.tsx @@ -2,7 +2,7 @@ import getRuntimeConfig from 'next-intl/config'; import type { GetRequestConfigParams, RequestConfig -} from './getRequestConfig.tsx'; +} from './getRequestConfig.js'; export default getRuntimeConfig as unknown as ( params: GetRequestConfigParams diff --git a/packages/next-intl/src/server/react-server/getConfig.tsx b/packages/next-intl/src/server/react-server/getConfig.tsx index 4b07ff97b..8372249a9 100644 --- a/packages/next-intl/src/server/react-server/getConfig.tsx +++ b/packages/next-intl/src/server/react-server/getConfig.tsx @@ -6,9 +6,9 @@ import { _createIntlFormatters, initializeConfig } from 'use-intl/core'; -import {getRequestLocale} from './RequestLocale.tsx'; -import createRequestConfig from './createRequestConfig.tsx'; -import type {GetRequestConfigParams} from './getRequestConfig.tsx'; +import {getRequestLocale} from './RequestLocale.js'; +import createRequestConfig from './createRequestConfig.js'; +import type {GetRequestConfigParams} from './getRequestConfig.js'; // This is automatically inherited by `NextIntlClientProvider` if // the component is rendered from a Server Component diff --git a/packages/next-intl/src/server/react-server/getConfigNow.tsx b/packages/next-intl/src/server/react-server/getConfigNow.tsx index 1a0750dc9..70088b327 100644 --- a/packages/next-intl/src/server/react-server/getConfigNow.tsx +++ b/packages/next-intl/src/server/react-server/getConfigNow.tsx @@ -1,6 +1,6 @@ import {cache} from 'react'; import type {Locale} from 'use-intl'; -import getConfig from './getConfig.tsx'; +import getConfig from './getConfig.js'; async function getConfigNowImpl(locale?: Locale) { const config = await getConfig(locale); diff --git a/packages/next-intl/src/server/react-server/getFormats.tsx b/packages/next-intl/src/server/react-server/getFormats.tsx index 4532b90ec..363a25efe 100644 --- a/packages/next-intl/src/server/react-server/getFormats.tsx +++ b/packages/next-intl/src/server/react-server/getFormats.tsx @@ -1,5 +1,5 @@ import {cache} from 'react'; -import getConfig from './getConfig.tsx'; +import getConfig from './getConfig.js'; async function getFormatsCachedImpl() { const config = await getConfig(); diff --git a/packages/next-intl/src/server/react-server/getFormatter.test.tsx b/packages/next-intl/src/server/react-server/getFormatter.test.tsx index 2499706da..b9a505dcb 100644 --- a/packages/next-intl/src/server/react-server/getFormatter.test.tsx +++ b/packages/next-intl/src/server/react-server/getFormatter.test.tsx @@ -1,6 +1,6 @@ import {describe, expect, it, vi} from 'vitest'; -import getDefaultNow from './getDefaultNow.tsx'; -import getFormatter from './getFormatter.tsx'; +import getDefaultNow from './getDefaultNow.js'; +import getFormatter from './getFormatter.js'; vi.mock('react'); vi.mock('./getDefaultNow.tsx', () => ({ diff --git a/packages/next-intl/src/server/react-server/getFormatter.tsx b/packages/next-intl/src/server/react-server/getFormatter.tsx index f90c99ea8..55591a5c3 100644 --- a/packages/next-intl/src/server/react-server/getFormatter.tsx +++ b/packages/next-intl/src/server/react-server/getFormatter.tsx @@ -1,7 +1,7 @@ import {cache} from 'react'; import type {Locale, createFormatter} from 'use-intl/core'; -import getConfig from './getConfig.tsx'; -import getServerFormatter from './getServerFormatter.tsx'; +import getConfig from './getConfig.js'; +import getServerFormatter from './getServerFormatter.js'; async function getFormatterCachedImpl(locale?: Locale) { const config = await getConfig(locale); diff --git a/packages/next-intl/src/server/react-server/getLocale.tsx b/packages/next-intl/src/server/react-server/getLocale.tsx index 4911306c1..61a8deb31 100644 --- a/packages/next-intl/src/server/react-server/getLocale.tsx +++ b/packages/next-intl/src/server/react-server/getLocale.tsx @@ -1,6 +1,6 @@ import {cache} from 'react'; import type {Locale} from 'use-intl'; -import getConfig from './getConfig.tsx'; +import getConfig from './getConfig.js'; async function getLocaleCachedImpl(): Promise { const config = await getConfig(); diff --git a/packages/next-intl/src/server/react-server/getMessages.tsx b/packages/next-intl/src/server/react-server/getMessages.tsx index b752a99b6..90495438d 100644 --- a/packages/next-intl/src/server/react-server/getMessages.tsx +++ b/packages/next-intl/src/server/react-server/getMessages.tsx @@ -1,6 +1,6 @@ import {cache} from 'react'; import type {Locale, useMessages as useMessagesType} from 'use-intl'; -import getConfig from './getConfig.tsx'; +import getConfig from './getConfig.js'; export function getMessagesFromConfig( config: Awaited> diff --git a/packages/next-intl/src/server/react-server/getNow.tsx b/packages/next-intl/src/server/react-server/getNow.tsx index 8daf796e8..767338158 100644 --- a/packages/next-intl/src/server/react-server/getNow.tsx +++ b/packages/next-intl/src/server/react-server/getNow.tsx @@ -1,6 +1,6 @@ import type {Locale} from 'use-intl'; -import getConfigNow from './getConfigNow.tsx'; -import getDefaultNow from './getDefaultNow.tsx'; +import getConfigNow from './getConfigNow.js'; +import getDefaultNow from './getDefaultNow.js'; export default async function getNow(opts?: {locale?: Locale}): Promise { return (await getConfigNow(opts?.locale)) ?? getDefaultNow(); diff --git a/packages/next-intl/src/server/react-server/getServerFormatter.tsx b/packages/next-intl/src/server/react-server/getServerFormatter.tsx index 5beeb0820..33654204e 100644 --- a/packages/next-intl/src/server/react-server/getServerFormatter.tsx +++ b/packages/next-intl/src/server/react-server/getServerFormatter.tsx @@ -1,6 +1,6 @@ import {cache} from 'react'; import {createFormatter} from 'use-intl/core'; -import getDefaultNow from './getDefaultNow.tsx'; +import getDefaultNow from './getDefaultNow.js'; function getFormatterCachedImpl(config: Parameters[0]) { // same here? diff --git a/packages/next-intl/src/server/react-server/getTimeZone.tsx b/packages/next-intl/src/server/react-server/getTimeZone.tsx index fca1601f9..feba75f95 100644 --- a/packages/next-intl/src/server/react-server/getTimeZone.tsx +++ b/packages/next-intl/src/server/react-server/getTimeZone.tsx @@ -1,6 +1,6 @@ import {cache} from 'react'; import type {Locale} from 'use-intl'; -import getConfig from './getConfig.tsx'; +import getConfig from './getConfig.js'; async function getTimeZoneCachedImpl(locale?: Locale) { const config = await getConfig(locale); diff --git a/packages/next-intl/src/server/react-server/getTranslations.test.tsx b/packages/next-intl/src/server/react-server/getTranslations.test.tsx index 5a19977c5..e2b9c2350 100644 --- a/packages/next-intl/src/server/react-server/getTranslations.test.tsx +++ b/packages/next-intl/src/server/react-server/getTranslations.test.tsx @@ -1,6 +1,6 @@ import {createTranslator} from 'use-intl/core'; import {expect, it, vi} from 'vitest'; -import getTranslations from './getTranslations.tsx'; +import getTranslations from './getTranslations.js'; vi.mock('react'); vi.mock('use-intl/core'); diff --git a/packages/next-intl/src/server/react-server/getTranslations.tsx b/packages/next-intl/src/server/react-server/getTranslations.tsx index 51690d083..2cd909052 100644 --- a/packages/next-intl/src/server/react-server/getTranslations.tsx +++ b/packages/next-intl/src/server/react-server/getTranslations.tsx @@ -6,8 +6,8 @@ import type { NestedKeyOf, createTranslator } from 'use-intl/core'; -import getConfig from './getConfig.tsx'; -import getServerTranslator from './getServerTranslator.tsx'; +import getConfig from './getConfig.js'; +import getServerTranslator from './getServerTranslator.js'; // Maintainer note: `getTranslations` has two different call signatures. // We need to define these with function overloads, otherwise TypeScript diff --git a/packages/next-intl/src/server/react-server/index.test.tsx b/packages/next-intl/src/server/react-server/index.test.tsx index 8f6054387..77878e1bc 100644 --- a/packages/next-intl/src/server/react-server/index.test.tsx +++ b/packages/next-intl/src/server/react-server/index.test.tsx @@ -1,14 +1,14 @@ // @vitest-environment edge-runtime import {describe, expect, it, vi} from 'vitest'; -import {HEADER_LOCALE_NAME} from '../../shared/constants.tsx'; +import {HEADER_LOCALE_NAME} from '../../shared/constants.js'; import { getFormatter, getMessages, getNow, getTimeZone, getTranslations -} from './index.tsx'; +} from './index.js'; vi.mock('next-intl/config', () => ({ default: async () => diff --git a/packages/next-intl/src/server/react-server/index.tsx b/packages/next-intl/src/server/react-server/index.tsx index 524ae9fa0..846ff4599 100644 --- a/packages/next-intl/src/server/react-server/index.tsx +++ b/packages/next-intl/src/server/react-server/index.tsx @@ -6,12 +6,12 @@ export { default as getRequestConfig, type GetRequestConfigParams, type RequestConfig -} from './getRequestConfig.tsx'; -export {default as getFormatter} from './getFormatter.tsx'; -export {default as getNow} from './getNow.tsx'; -export {default as getTimeZone} from './getTimeZone.tsx'; -export {default as getTranslations} from './getTranslations.tsx'; -export {default as getMessages} from './getMessages.tsx'; -export {default as getLocale} from './getLocale.tsx'; +} from './getRequestConfig.js'; +export {default as getFormatter} from './getFormatter.js'; +export {default as getNow} from './getNow.js'; +export {default as getTimeZone} from './getTimeZone.js'; +export {default as getTranslations} from './getTranslations.js'; +export {default as getMessages} from './getMessages.js'; +export {default as getLocale} from './getLocale.js'; -export {setCachedRequestLocale as setRequestLocale} from './RequestLocaleCache.tsx'; +export {setCachedRequestLocale as setRequestLocale} from './RequestLocaleCache.js'; diff --git a/packages/next-intl/src/shared/utils.test.tsx b/packages/next-intl/src/shared/utils.test.tsx index b16504cb6..c9456ac70 100644 --- a/packages/next-intl/src/shared/utils.test.tsx +++ b/packages/next-intl/src/shared/utils.test.tsx @@ -5,7 +5,7 @@ import { matchesPathname, prefixPathname, unprefixPathname -} from './utils.tsx'; +} from './utils.js'; describe('prefixPathname', () => { it("doesn't add trailing slashes for the root", () => { diff --git a/packages/next-intl/src/shared/utils.tsx b/packages/next-intl/src/shared/utils.tsx index 02c6960f1..28e6451fe 100644 --- a/packages/next-intl/src/shared/utils.tsx +++ b/packages/next-intl/src/shared/utils.tsx @@ -3,7 +3,7 @@ import type { LocalePrefixConfigVerbose, LocalePrefixMode, Locales -} from '../routing/types.tsx'; +} from '../routing/types.js'; type Href = LinkProps['href']; diff --git a/packages/next-intl/tsconfig.json b/packages/next-intl/tsconfig.json index f32652031..9dcc99414 100644 --- a/packages/next-intl/tsconfig.json +++ b/packages/next-intl/tsconfig.json @@ -2,7 +2,6 @@ "extends": "eslint-config-molindo/tsconfig.json", "include": ["src", "test", "__mocks__", "types", "next-env.d.ts"], "compilerOptions": { - "allowImportingTsExtensions": true, // For ESM "lib": ["dom", "esnext"], "target": "ES2020", "declaration": true, diff --git a/packages/use-intl/eslint.config.mjs b/packages/use-intl/eslint.config.mjs index 48b5300b4..e92ad614a 100644 --- a/packages/use-intl/eslint.config.mjs +++ b/packages/use-intl/eslint.config.mjs @@ -12,6 +12,7 @@ export default (await getPresets('typescript', 'react', 'vitest')).concat({ '@typescript-eslint/consistent-type-imports': 'error', '@typescript-eslint/consistent-type-exports': 'error', '@typescript-eslint/no-import-type-side-effects': 'error', - 'import/no-duplicates': ['error', {'prefer-inline': true}] + 'import/no-duplicates': ['error', {'prefer-inline': true}], + 'import/extensions': 'error' } }); diff --git a/packages/use-intl/src/core.tsx b/packages/use-intl/src/core.tsx index 4a80db990..17f45946d 100644 --- a/packages/use-intl/src/core.tsx +++ b/packages/use-intl/src/core.tsx @@ -1 +1 @@ -export * from './core/index.tsx'; +export * from './core/index.js'; diff --git a/packages/use-intl/src/core/DateTimeFormatOptions.tsx b/packages/use-intl/src/core/DateTimeFormatOptions.tsx index 6fca63f22..0cd45ee08 100644 --- a/packages/use-intl/src/core/DateTimeFormatOptions.tsx +++ b/packages/use-intl/src/core/DateTimeFormatOptions.tsx @@ -1,6 +1,6 @@ // https://github.com/microsoft/TypeScript/issues/35865 -import type TimeZone from './TimeZone.tsx'; +import type TimeZone from './TimeZone.js'; /** * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat diff --git a/packages/use-intl/src/core/Formats.tsx b/packages/use-intl/src/core/Formats.tsx index 96eb1e6be..05702cc82 100644 --- a/packages/use-intl/src/core/Formats.tsx +++ b/packages/use-intl/src/core/Formats.tsx @@ -1,5 +1,5 @@ -import type DateTimeFormatOptions from './DateTimeFormatOptions.tsx'; -import type NumberFormatOptions from './NumberFormatOptions.tsx'; +import type DateTimeFormatOptions from './DateTimeFormatOptions.js'; +import type NumberFormatOptions from './NumberFormatOptions.js'; type Formats = { number?: Record; diff --git a/packages/use-intl/src/core/IntlConfig.tsx b/packages/use-intl/src/core/IntlConfig.tsx index 7a4f85208..76caded15 100644 --- a/packages/use-intl/src/core/IntlConfig.tsx +++ b/packages/use-intl/src/core/IntlConfig.tsx @@ -1,8 +1,8 @@ -import type AbstractIntlMessages from './AbstractIntlMessages.tsx'; -import type {Locale} from './AppConfig.tsx'; -import type Formats from './Formats.tsx'; -import type IntlError from './IntlError.tsx'; -import type TimeZone from './TimeZone.tsx'; +import type AbstractIntlMessages from './AbstractIntlMessages.js'; +import type {Locale} from './AppConfig.js'; +import type Formats from './Formats.js'; +import type IntlError from './IntlError.js'; +import type TimeZone from './TimeZone.js'; /** * Should be used for entry points that configure the library. diff --git a/packages/use-intl/src/core/IntlError.tsx b/packages/use-intl/src/core/IntlError.tsx index aa25d0385..25177b820 100644 --- a/packages/use-intl/src/core/IntlError.tsx +++ b/packages/use-intl/src/core/IntlError.tsx @@ -1,4 +1,4 @@ -import type IntlErrorCode from './IntlErrorCode.tsx'; +import type IntlErrorCode from './IntlErrorCode.js'; export default class IntlError extends Error { public readonly code: IntlErrorCode; diff --git a/packages/use-intl/src/core/convertFormatsToIntlMessageFormat.tsx b/packages/use-intl/src/core/convertFormatsToIntlMessageFormat.tsx index 71c76e64b..ca5d32dd4 100644 --- a/packages/use-intl/src/core/convertFormatsToIntlMessageFormat.tsx +++ b/packages/use-intl/src/core/convertFormatsToIntlMessageFormat.tsx @@ -2,8 +2,8 @@ import { type Formats as IntlFormats, IntlMessageFormat } from 'intl-messageformat'; -import type Formats from './Formats.tsx'; -import type TimeZone from './TimeZone.tsx'; +import type Formats from './Formats.js'; +import type TimeZone from './TimeZone.js'; /** * `intl-messageformat` uses separate keys for `date` and `time`, but there's diff --git a/packages/use-intl/src/core/createBaseTranslator.tsx b/packages/use-intl/src/core/createBaseTranslator.tsx index c4ac43ec0..d961fec63 100644 --- a/packages/use-intl/src/core/createBaseTranslator.tsx +++ b/packages/use-intl/src/core/createBaseTranslator.tsx @@ -1,27 +1,27 @@ import {IntlMessageFormat} from 'intl-messageformat'; import {type ReactNode, cloneElement, isValidElement} from 'react'; -import type AbstractIntlMessages from './AbstractIntlMessages.tsx'; -import type {Locale} from './AppConfig.tsx'; -import type Formats from './Formats.tsx'; -import type {InitializedIntlConfig} from './IntlConfig.tsx'; -import IntlError from './IntlError.tsx'; -import IntlErrorCode from './IntlErrorCode.tsx'; -import type {MessageKeys, NestedKeyOf, NestedValueOf} from './MessageKeys.tsx'; +import type AbstractIntlMessages from './AbstractIntlMessages.js'; +import type {Locale} from './AppConfig.js'; +import type Formats from './Formats.js'; +import type {InitializedIntlConfig} from './IntlConfig.js'; +import IntlError from './IntlError.js'; +import IntlErrorCode from './IntlErrorCode.js'; +import type {MessageKeys, NestedKeyOf, NestedValueOf} from './MessageKeys.js'; import type { MarkupTranslationValues, RichTranslationValues, TranslationValues -} from './TranslationValues.tsx'; -import convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat.tsx'; -import {defaultGetMessageFallback, defaultOnError} from './defaults.tsx'; +} from './TranslationValues.js'; +import convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat.js'; +import {defaultGetMessageFallback, defaultOnError} from './defaults.js'; import { type Formatters, type IntlCache, type IntlFormatters, type MessageFormatter, memoFn -} from './formatters.tsx'; -import joinPath from './joinPath.tsx'; +} from './formatters.js'; +import joinPath from './joinPath.js'; // Placed here for improved tree shaking. Somehow when this is placed in // `formatters.tsx`, then it can't be shaken off from `next-intl`. diff --git a/packages/use-intl/src/core/createFormatter.test.tsx b/packages/use-intl/src/core/createFormatter.test.tsx index cd7014cc9..a45eebef5 100644 --- a/packages/use-intl/src/core/createFormatter.test.tsx +++ b/packages/use-intl/src/core/createFormatter.test.tsx @@ -1,6 +1,6 @@ import {parseISO} from 'date-fns'; import {describe, expect, it} from 'vitest'; -import createFormatter from './createFormatter.tsx'; +import createFormatter from './createFormatter.js'; describe('dateTime', () => { it('formats a date and time', () => { diff --git a/packages/use-intl/src/core/createFormatter.tsx b/packages/use-intl/src/core/createFormatter.tsx index 2d92573e5..c3d31a3d9 100644 --- a/packages/use-intl/src/core/createFormatter.tsx +++ b/packages/use-intl/src/core/createFormatter.tsx @@ -1,19 +1,19 @@ import type {ReactElement} from 'react'; -import type {FormatNames, Locale} from './AppConfig.tsx'; -import type DateTimeFormatOptions from './DateTimeFormatOptions.tsx'; -import type Formats from './Formats.tsx'; -import IntlError from './IntlError.tsx'; -import IntlErrorCode from './IntlErrorCode.tsx'; -import type NumberFormatOptions from './NumberFormatOptions.tsx'; -import type RelativeTimeFormatOptions from './RelativeTimeFormatOptions.tsx'; -import type TimeZone from './TimeZone.tsx'; -import {defaultOnError} from './defaults.tsx'; +import type {FormatNames, Locale} from './AppConfig.js'; +import type DateTimeFormatOptions from './DateTimeFormatOptions.js'; +import type Formats from './Formats.js'; +import IntlError from './IntlError.js'; +import IntlErrorCode from './IntlErrorCode.js'; +import type NumberFormatOptions from './NumberFormatOptions.js'; +import type RelativeTimeFormatOptions from './RelativeTimeFormatOptions.js'; +import type TimeZone from './TimeZone.js'; +import {defaultOnError} from './defaults.js'; import { type Formatters, type IntlCache, createCache, createIntlFormatters -} from './formatters.tsx'; +} from './formatters.js'; const SECOND = 1; const MINUTE = SECOND * 60; diff --git a/packages/use-intl/src/core/createTranslator.test.tsx b/packages/use-intl/src/core/createTranslator.test.tsx index 1a4a4c9bd..ea4d4e7c2 100644 --- a/packages/use-intl/src/core/createTranslator.test.tsx +++ b/packages/use-intl/src/core/createTranslator.test.tsx @@ -1,10 +1,10 @@ import {isValidElement} from 'react'; import {renderToString} from 'react-dom/server'; import {describe, expect, it, vi} from 'vitest'; -import type {Messages} from './AppConfig.tsx'; -import type IntlError from './IntlError.tsx'; -import IntlErrorCode from './IntlErrorCode.tsx'; -import createTranslator from './createTranslator.tsx'; +import type {Messages} from './AppConfig.js'; +import type IntlError from './IntlError.js'; +import IntlErrorCode from './IntlErrorCode.js'; +import createTranslator from './createTranslator.js'; const messages = { Home: { diff --git a/packages/use-intl/src/core/createTranslator.tsx b/packages/use-intl/src/core/createTranslator.tsx index 4b08ae315..18a37f6b1 100644 --- a/packages/use-intl/src/core/createTranslator.tsx +++ b/packages/use-intl/src/core/createTranslator.tsx @@ -1,28 +1,28 @@ import type {ReactNode} from 'react'; -import type Formats from './Formats.tsx'; -import type ICUArgs from './ICUArgs.tsx'; -import type ICUTags from './ICUTags.tsx'; -import type IntlConfig from './IntlConfig.tsx'; +import type Formats from './Formats.js'; +import type ICUArgs from './ICUArgs.js'; +import type ICUTags from './ICUTags.js'; +import type IntlConfig from './IntlConfig.js'; import type { MessageKeys, NamespaceKeys, NestedKeyOf, NestedValueOf -} from './MessageKeys.tsx'; +} from './MessageKeys.js'; import type { MarkupTagsFunction, RichTagsFunction, TranslationValues -} from './TranslationValues.tsx'; -import createTranslatorImpl from './createTranslatorImpl.tsx'; -import {defaultGetMessageFallback, defaultOnError} from './defaults.tsx'; +} from './TranslationValues.js'; +import createTranslatorImpl from './createTranslatorImpl.js'; +import {defaultGetMessageFallback, defaultOnError} from './defaults.js'; import { type Formatters, type IntlCache, createCache, createIntlFormatters -} from './formatters.tsx'; -import type {Prettify} from './types.tsx'; +} from './formatters.js'; +import type {Prettify} from './types.js'; type ICUArgsWithTags< MessageString extends string, diff --git a/packages/use-intl/src/core/createTranslatorImpl.tsx b/packages/use-intl/src/core/createTranslatorImpl.tsx index a87097776..3f3fdb614 100644 --- a/packages/use-intl/src/core/createTranslatorImpl.tsx +++ b/packages/use-intl/src/core/createTranslatorImpl.tsx @@ -1,9 +1,9 @@ -import type AbstractIntlMessages from './AbstractIntlMessages.tsx'; -import type {InitializedIntlConfig} from './IntlConfig.tsx'; -import type {NestedKeyOf} from './MessageKeys.tsx'; -import createBaseTranslator from './createBaseTranslator.tsx'; -import type {Formatters, IntlCache} from './formatters.tsx'; -import resolveNamespace from './resolveNamespace.tsx'; +import type AbstractIntlMessages from './AbstractIntlMessages.js'; +import type {InitializedIntlConfig} from './IntlConfig.js'; +import type {NestedKeyOf} from './MessageKeys.js'; +import createBaseTranslator from './createBaseTranslator.js'; +import type {Formatters, IntlCache} from './formatters.js'; +import resolveNamespace from './resolveNamespace.js'; export type CreateTranslatorImplProps = Omit< InitializedIntlConfig, diff --git a/packages/use-intl/src/core/defaults.tsx b/packages/use-intl/src/core/defaults.tsx index f86619763..a35403f0f 100644 --- a/packages/use-intl/src/core/defaults.tsx +++ b/packages/use-intl/src/core/defaults.tsx @@ -1,5 +1,5 @@ -import type IntlError from './IntlError.tsx'; -import joinPath from './joinPath.tsx'; +import type IntlError from './IntlError.js'; +import joinPath from './joinPath.js'; /** * Contains defaults that are used for all entry points into the core. diff --git a/packages/use-intl/src/core/hasLocale.test.tsx b/packages/use-intl/src/core/hasLocale.test.tsx index 36c611f3b..b77d4b5de 100644 --- a/packages/use-intl/src/core/hasLocale.test.tsx +++ b/packages/use-intl/src/core/hasLocale.test.tsx @@ -1,5 +1,5 @@ import {expect, it} from 'vitest'; -import hasLocale from './hasLocale.tsx'; +import hasLocale from './hasLocale.js'; it('narrows down the type', () => { const locales = ['en-US', 'en-GB'] as const; diff --git a/packages/use-intl/src/core/hasLocale.tsx b/packages/use-intl/src/core/hasLocale.tsx index 576ee3289..e8177f1db 100644 --- a/packages/use-intl/src/core/hasLocale.tsx +++ b/packages/use-intl/src/core/hasLocale.tsx @@ -1,4 +1,4 @@ -import type {Locale} from './AppConfig.tsx'; +import type {Locale} from './AppConfig.js'; /** * Checks if a locale exists in a list of locales. diff --git a/packages/use-intl/src/core/index.tsx b/packages/use-intl/src/core/index.tsx index 4f5c6e503..a80ad92b7 100644 --- a/packages/use-intl/src/core/index.tsx +++ b/packages/use-intl/src/core/index.tsx @@ -1,31 +1,31 @@ -export type {default as AbstractIntlMessages} from './AbstractIntlMessages.tsx'; +export type {default as AbstractIntlMessages} from './AbstractIntlMessages.js'; export type { TranslationValues, RichTranslationValues, MarkupTranslationValues, RichTagsFunction, MarkupTagsFunction -} from './TranslationValues.tsx'; -export type {default as Formats} from './Formats.tsx'; -export type {default as IntlConfig} from './IntlConfig.tsx'; -export type {default as DateTimeFormatOptions} from './DateTimeFormatOptions.tsx'; -export type {default as NumberFormatOptions} from './NumberFormatOptions.tsx'; -export {default as IntlError} from './IntlError.tsx'; -export {default as IntlErrorCode} from './IntlErrorCode.tsx'; -export {default as createTranslator} from './createTranslator.tsx'; -export {default as createFormatter} from './createFormatter.tsx'; -export {default as initializeConfig} from './initializeConfig.tsx'; +} from './TranslationValues.js'; +export type {default as Formats} from './Formats.js'; +export type {default as IntlConfig} from './IntlConfig.js'; +export type {default as DateTimeFormatOptions} from './DateTimeFormatOptions.js'; +export type {default as NumberFormatOptions} from './NumberFormatOptions.js'; +export {default as IntlError} from './IntlError.js'; +export {default as IntlErrorCode} from './IntlErrorCode.js'; +export {default as createTranslator} from './createTranslator.js'; +export {default as createFormatter} from './createFormatter.js'; +export {default as initializeConfig} from './initializeConfig.js'; export type { MessageKeys, NamespaceKeys, NestedKeyOf, NestedValueOf -} from './MessageKeys.tsx'; -export {createIntlFormatters as _createIntlFormatters} from './formatters.tsx'; -export {createCache as _createCache} from './formatters.tsx'; -export type {default as AppConfig, Locale, Messages} from './AppConfig.tsx'; -export {default as hasLocale} from './hasLocale.tsx'; -export type {default as RelativeTimeFormatOptions} from './RelativeTimeFormatOptions.tsx'; -export type {default as Timezone} from './TimeZone.tsx'; -export type {default as ICUArgs} from './ICUArgs.tsx'; -export type {default as ICUTags} from './ICUTags.tsx'; +} from './MessageKeys.js'; +export {createIntlFormatters as _createIntlFormatters} from './formatters.js'; +export {createCache as _createCache} from './formatters.js'; +export type {default as AppConfig, Locale, Messages} from './AppConfig.js'; +export {default as hasLocale} from './hasLocale.js'; +export type {default as RelativeTimeFormatOptions} from './RelativeTimeFormatOptions.js'; +export type {default as Timezone} from './TimeZone.js'; +export type {default as ICUArgs} from './ICUArgs.js'; +export type {default as ICUTags} from './ICUTags.js'; diff --git a/packages/use-intl/src/core/initializeConfig.tsx b/packages/use-intl/src/core/initializeConfig.tsx index 3a52d6c6b..1bce4c21c 100644 --- a/packages/use-intl/src/core/initializeConfig.tsx +++ b/packages/use-intl/src/core/initializeConfig.tsx @@ -1,6 +1,6 @@ -import type IntlConfig from './IntlConfig.tsx'; -import {defaultGetMessageFallback, defaultOnError} from './defaults.tsx'; -import validateMessages from './validateMessages.tsx'; +import type IntlConfig from './IntlConfig.js'; +import {defaultGetMessageFallback, defaultOnError} from './defaults.js'; +import validateMessages from './validateMessages.js'; /** * Enhances the incoming props with defaults. diff --git a/packages/use-intl/src/core/validateMessages.tsx b/packages/use-intl/src/core/validateMessages.tsx index d8f4b31f0..f5b2fd7e5 100644 --- a/packages/use-intl/src/core/validateMessages.tsx +++ b/packages/use-intl/src/core/validateMessages.tsx @@ -1,7 +1,7 @@ -import type AbstractIntlMessages from './AbstractIntlMessages.tsx'; -import IntlError from './IntlError.tsx'; -import IntlErrorCode from './IntlErrorCode.tsx'; -import joinPath from './joinPath.tsx'; +import type AbstractIntlMessages from './AbstractIntlMessages.js'; +import IntlError from './IntlError.js'; +import IntlErrorCode from './IntlErrorCode.js'; +import joinPath from './joinPath.js'; function validateMessagesSegment( messages: AbstractIntlMessages, diff --git a/packages/use-intl/src/index.tsx b/packages/use-intl/src/index.tsx index a7f352cea..03330e7ba 100644 --- a/packages/use-intl/src/index.tsx +++ b/packages/use-intl/src/index.tsx @@ -1,2 +1,2 @@ -export * from './core.tsx'; -export * from './react.tsx'; +export * from './core.js'; +export * from './react.js'; diff --git a/packages/use-intl/src/react.tsx b/packages/use-intl/src/react.tsx index 858a6b562..a6189cdec 100644 --- a/packages/use-intl/src/react.tsx +++ b/packages/use-intl/src/react.tsx @@ -1 +1 @@ -export * from './react/index.tsx'; +export * from './react/index.js'; diff --git a/packages/use-intl/src/react/IntlContext.tsx b/packages/use-intl/src/react/IntlContext.tsx index 1ba115907..dbe190bcd 100644 --- a/packages/use-intl/src/react/IntlContext.tsx +++ b/packages/use-intl/src/react/IntlContext.tsx @@ -1,6 +1,6 @@ import {createContext} from 'react'; -import type {InitializedIntlConfig} from '../core/IntlConfig.tsx'; -import type {Formatters, IntlCache} from '../core/formatters.tsx'; +import type {InitializedIntlConfig} from '../core/IntlConfig.js'; +import type {Formatters, IntlCache} from '../core/formatters.js'; export type IntlContextValue = InitializedIntlConfig & { formatters: Formatters; diff --git a/packages/use-intl/src/react/IntlProvider.test.tsx b/packages/use-intl/src/react/IntlProvider.test.tsx index fccc57726..af2564910 100644 --- a/packages/use-intl/src/react/IntlProvider.test.tsx +++ b/packages/use-intl/src/react/IntlProvider.test.tsx @@ -1,9 +1,9 @@ import {fireEvent, render, screen} from '@testing-library/react'; import {memo, useState} from 'react'; import {expect, it, vi} from 'vitest'; -import IntlProvider from './IntlProvider.tsx'; -import useNow from './useNow.tsx'; -import useTranslations from './useTranslations.tsx'; +import IntlProvider from './IntlProvider.js'; +import useNow from './useNow.js'; +import useTranslations from './useTranslations.js'; it("doesn't re-render context consumers unnecessarily", () => { const messages = {StaticText: {hello: 'Hello!'}}; diff --git a/packages/use-intl/src/react/IntlProvider.tsx b/packages/use-intl/src/react/IntlProvider.tsx index 58e5e1abc..81746ac34 100644 --- a/packages/use-intl/src/react/IntlProvider.tsx +++ b/packages/use-intl/src/react/IntlProvider.tsx @@ -1,12 +1,12 @@ import {type ReactNode, useContext, useMemo} from 'react'; -import type IntlConfig from '../core/IntlConfig.tsx'; +import type IntlConfig from '../core/IntlConfig.js'; import { type Formatters, createCache, createIntlFormatters -} from '../core/formatters.tsx'; -import initializeConfig from '../core/initializeConfig.tsx'; -import IntlContext from './IntlContext.tsx'; +} from '../core/formatters.js'; +import initializeConfig from '../core/initializeConfig.js'; +import IntlContext from './IntlContext.js'; type Props = IntlConfig & { children: ReactNode; diff --git a/packages/use-intl/src/react/index.test.tsx b/packages/use-intl/src/react/index.test.tsx index 225aa933b..8c211de88 100644 --- a/packages/use-intl/src/react/index.test.tsx +++ b/packages/use-intl/src/react/index.test.tsx @@ -1,11 +1,11 @@ import {render, screen} from '@testing-library/react'; import {parseISO} from 'date-fns'; import {beforeEach, describe, expect, it, vi} from 'vitest'; -import type {Locale} from '../core.tsx'; -import IntlProvider from './IntlProvider.tsx'; -import useFormatter from './useFormatter.tsx'; -import useNow from './useNow.tsx'; -import useTranslations from './useTranslations.tsx'; +import type {Locale} from '../core.js'; +import IntlProvider from './IntlProvider.js'; +import useFormatter from './useFormatter.js'; +import useNow from './useNow.js'; +import useTranslations from './useTranslations.js'; describe('performance', () => { beforeEach(() => { diff --git a/packages/use-intl/src/react/index.tsx b/packages/use-intl/src/react/index.tsx index 30a1e1a86..265427525 100644 --- a/packages/use-intl/src/react/index.tsx +++ b/packages/use-intl/src/react/index.tsx @@ -1,7 +1,7 @@ -export {default as IntlProvider} from './IntlProvider.tsx'; -export {default as useTranslations} from './useTranslations.tsx'; -export {default as useLocale} from './useLocale.tsx'; -export {default as useNow} from './useNow.tsx'; -export {default as useTimeZone} from './useTimeZone.tsx'; -export {default as useMessages} from './useMessages.tsx'; -export {default as useFormatter} from './useFormatter.tsx'; +export {default as IntlProvider} from './IntlProvider.js'; +export {default as useTranslations} from './useTranslations.js'; +export {default as useLocale} from './useLocale.js'; +export {default as useNow} from './useNow.js'; +export {default as useTimeZone} from './useTimeZone.js'; +export {default as useMessages} from './useMessages.js'; +export {default as useFormatter} from './useFormatter.js'; diff --git a/packages/use-intl/src/react/useFormatter.test.tsx b/packages/use-intl/src/react/useFormatter.test.tsx index 1e0735af4..fc9e42184 100644 --- a/packages/use-intl/src/react/useFormatter.test.tsx +++ b/packages/use-intl/src/react/useFormatter.test.tsx @@ -3,9 +3,9 @@ import {parseISO} from 'date-fns'; import type {ComponentProps, ReactElement, ReactNode} from 'react'; import {type SpyImpl, spyOn} from 'tinyspy'; import {beforeEach, describe, expect, it, vi} from 'vitest'; -import {type IntlError, IntlErrorCode} from '../core.tsx'; -import IntlProvider from './IntlProvider.tsx'; -import useFormatter from './useFormatter.tsx'; +import {type IntlError, IntlErrorCode} from '../core.js'; +import IntlProvider from './IntlProvider.js'; +import useFormatter from './useFormatter.js'; function MockProvider( props: Partial> & {children: ReactNode} diff --git a/packages/use-intl/src/react/useFormatter.tsx b/packages/use-intl/src/react/useFormatter.tsx index c551c7333..8a2221b6e 100644 --- a/packages/use-intl/src/react/useFormatter.tsx +++ b/packages/use-intl/src/react/useFormatter.tsx @@ -1,6 +1,6 @@ import {useMemo} from 'react'; -import createFormatter from '../core/createFormatter.tsx'; -import useIntlContext from './useIntlContext.tsx'; +import createFormatter from '../core/createFormatter.js'; +import useIntlContext from './useIntlContext.js'; export default function useFormatter(): ReturnType { const { diff --git a/packages/use-intl/src/react/useIntlContext.tsx b/packages/use-intl/src/react/useIntlContext.tsx index ec688ca75..d588105db 100644 --- a/packages/use-intl/src/react/useIntlContext.tsx +++ b/packages/use-intl/src/react/useIntlContext.tsx @@ -1,5 +1,5 @@ import {useContext} from 'react'; -import IntlContext, {type IntlContextValue} from './IntlContext.tsx'; +import IntlContext, {type IntlContextValue} from './IntlContext.js'; export default function useIntlContext(): IntlContextValue { const context = useContext(IntlContext); diff --git a/packages/use-intl/src/react/useLocale.test.tsx b/packages/use-intl/src/react/useLocale.test.tsx index 732aee4d7..3f644b5c1 100644 --- a/packages/use-intl/src/react/useLocale.test.tsx +++ b/packages/use-intl/src/react/useLocale.test.tsx @@ -1,7 +1,7 @@ import {render, screen} from '@testing-library/react'; import {it} from 'vitest'; -import IntlProvider from './IntlProvider.tsx'; -import useLocale from './useLocale.tsx'; +import IntlProvider from './IntlProvider.js'; +import useLocale from './useLocale.js'; it('returns the current locale', () => { function Component() { diff --git a/packages/use-intl/src/react/useLocale.tsx b/packages/use-intl/src/react/useLocale.tsx index 621b18847..bcac7e82f 100644 --- a/packages/use-intl/src/react/useLocale.tsx +++ b/packages/use-intl/src/react/useLocale.tsx @@ -1,5 +1,5 @@ -import type {Locale} from '../core.tsx'; -import useIntlContext from './useIntlContext.tsx'; +import type {Locale} from '../core.js'; +import useIntlContext from './useIntlContext.js'; export default function useLocale(): Locale { return useIntlContext().locale; diff --git a/packages/use-intl/src/react/useMessages.test.tsx b/packages/use-intl/src/react/useMessages.test.tsx index d8563b0e1..9e6ac6c54 100644 --- a/packages/use-intl/src/react/useMessages.test.tsx +++ b/packages/use-intl/src/react/useMessages.test.tsx @@ -1,7 +1,7 @@ import {render, screen} from '@testing-library/react'; import {expect, it} from 'vitest'; -import IntlProvider from './IntlProvider.tsx'; -import useMessages from './useMessages.tsx'; +import IntlProvider from './IntlProvider.js'; +import useMessages from './useMessages.js'; function Component() { const messages = useMessages(); diff --git a/packages/use-intl/src/react/useMessages.tsx b/packages/use-intl/src/react/useMessages.tsx index 987637ccf..c67f3d106 100644 --- a/packages/use-intl/src/react/useMessages.tsx +++ b/packages/use-intl/src/react/useMessages.tsx @@ -1,5 +1,5 @@ -import type {Messages} from '../core/AppConfig.tsx'; -import useIntlContext from './useIntlContext.tsx'; +import type {Messages} from '../core/AppConfig.js'; +import useIntlContext from './useIntlContext.js'; export default function useMessages(): Messages { const context = useIntlContext(); diff --git a/packages/use-intl/src/react/useNow.test.tsx b/packages/use-intl/src/react/useNow.test.tsx index 0e43f2eed..fa88bc8df 100644 --- a/packages/use-intl/src/react/useNow.test.tsx +++ b/packages/use-intl/src/react/useNow.test.tsx @@ -1,8 +1,8 @@ import {render, waitFor} from '@testing-library/react'; import {parseISO} from 'date-fns'; import {expect, it} from 'vitest'; -import IntlProvider from './IntlProvider.tsx'; -import useNow from './useNow.tsx'; +import IntlProvider from './IntlProvider.js'; +import useNow from './useNow.js'; it('returns the current time', () => { function Component() { diff --git a/packages/use-intl/src/react/useNow.tsx b/packages/use-intl/src/react/useNow.tsx index 3c0b054c4..efa17a754 100644 --- a/packages/use-intl/src/react/useNow.tsx +++ b/packages/use-intl/src/react/useNow.tsx @@ -1,5 +1,5 @@ import {useEffect, useState} from 'react'; -import useIntlContext from './useIntlContext.tsx'; +import useIntlContext from './useIntlContext.js'; type Options = { updateInterval?: number; diff --git a/packages/use-intl/src/react/useTimeZone.test.tsx b/packages/use-intl/src/react/useTimeZone.test.tsx index 57d4031e3..8a7319dff 100644 --- a/packages/use-intl/src/react/useTimeZone.test.tsx +++ b/packages/use-intl/src/react/useTimeZone.test.tsx @@ -1,7 +1,7 @@ import {render, screen} from '@testing-library/react'; import {expect, it} from 'vitest'; -import IntlProvider from './IntlProvider.tsx'; -import useTimeZone from './useTimeZone.tsx'; +import IntlProvider from './IntlProvider.js'; +import useTimeZone from './useTimeZone.js'; it('returns the time zone when it is configured', () => { function Component() { diff --git a/packages/use-intl/src/react/useTimeZone.tsx b/packages/use-intl/src/react/useTimeZone.tsx index f95f5b719..6709deee5 100644 --- a/packages/use-intl/src/react/useTimeZone.tsx +++ b/packages/use-intl/src/react/useTimeZone.tsx @@ -1,4 +1,4 @@ -import useIntlContext from './useIntlContext.tsx'; +import useIntlContext from './useIntlContext.js'; export default function useTimeZone() { return useIntlContext().timeZone; diff --git a/packages/use-intl/src/react/useTranslations.test.tsx b/packages/use-intl/src/react/useTranslations.test.tsx index cabcc94ab..184aca7e3 100644 --- a/packages/use-intl/src/react/useTranslations.test.tsx +++ b/packages/use-intl/src/react/useTranslations.test.tsx @@ -9,9 +9,9 @@ import { IntlErrorCode, type RichTranslationValues, type TranslationValues -} from '../core.tsx'; -import IntlProvider from './IntlProvider.tsx'; -import useTranslations from './useTranslations.tsx'; +} from '../core.js'; +import IntlProvider from './IntlProvider.js'; +import useTranslations from './useTranslations.js'; // Wrap the library to include a counter for parse // invocations for the cache test below. diff --git a/packages/use-intl/src/react/useTranslations.tsx b/packages/use-intl/src/react/useTranslations.tsx index 57d42b11b..b1f9860c0 100644 --- a/packages/use-intl/src/react/useTranslations.tsx +++ b/packages/use-intl/src/react/useTranslations.tsx @@ -1,8 +1,8 @@ -import type {Messages} from '../core/AppConfig.tsx'; -import type {NamespaceKeys, NestedKeyOf} from '../core/MessageKeys.tsx'; -import type createTranslator from '../core/createTranslator.tsx'; -import useIntlContext from './useIntlContext.tsx'; -import useTranslationsImpl from './useTranslationsImpl.tsx'; +import type {Messages} from '../core/AppConfig.js'; +import type {NamespaceKeys, NestedKeyOf} from '../core/MessageKeys.js'; +import type createTranslator from '../core/createTranslator.js'; +import useIntlContext from './useIntlContext.js'; +import useTranslationsImpl from './useTranslationsImpl.js'; /** * Translates messages from the given namespace by using the ICU syntax. diff --git a/packages/use-intl/src/react/useTranslationsImpl.tsx b/packages/use-intl/src/react/useTranslationsImpl.tsx index 243397100..bd190d0f0 100644 --- a/packages/use-intl/src/react/useTranslationsImpl.tsx +++ b/packages/use-intl/src/react/useTranslationsImpl.tsx @@ -1,10 +1,10 @@ import {useMemo} from 'react'; -import type AbstractIntlMessages from '../core/AbstractIntlMessages.tsx'; -import type {NestedKeyOf} from '../core/MessageKeys.tsx'; -import createBaseTranslator from '../core/createBaseTranslator.tsx'; -import resolveNamespace from '../core/resolveNamespace.tsx'; -import {IntlError, IntlErrorCode} from '../core.tsx'; -import useIntlContext from './useIntlContext.tsx'; +import type AbstractIntlMessages from '../core/AbstractIntlMessages.js'; +import type {NestedKeyOf} from '../core/MessageKeys.js'; +import createBaseTranslator from '../core/createBaseTranslator.js'; +import resolveNamespace from '../core/resolveNamespace.js'; +import {IntlError, IntlErrorCode} from '../core.js'; +import useIntlContext from './useIntlContext.js'; let hasWarnedForMissingTimezone = false; const isServer = typeof window === 'undefined'; diff --git a/packages/use-intl/tsconfig.json b/packages/use-intl/tsconfig.json index 1a0feb584..29d340f67 100644 --- a/packages/use-intl/tsconfig.json +++ b/packages/use-intl/tsconfig.json @@ -2,7 +2,6 @@ "extends": "eslint-config-molindo/tsconfig.json", "include": ["src", "test", "types"], "compilerOptions": { - "allowImportingTsExtensions": true, // For ESM "lib": ["dom", "esnext"], "target": "ES2020", "declaration": true,