Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: i18n-js module resolution for esm #1549

Merged
merged 8 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smooth-students-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rainbow-me/rainbowkit": patch
---

Fixed a dependency resolution issue for `ESModule` projects related to `i18n-js`
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { I18n as _I18N } from 'i18n-js';
import React, { ReactNode, createContext, useMemo } from 'react';

import { Locale, i18n as _i18n } from '../../locales';
import { detectedBrowserLocale } from '../../utils/locale';

export const I18nContext = createContext<_I18N>(_i18n);
export const I18nContext = createContext<typeof _i18n>(_i18n);

interface I18nProviderProps {
children: ReactNode;
Expand Down
2 changes: 2 additions & 0 deletions packages/rainbowkit/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ declare module '*.png' {
const dataUrl: string;
export default dataUrl;
}

declare module 'i18n-js/dist/require/index.js';
6 changes: 4 additions & 2 deletions packages/rainbowkit/src/locales/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { I18n } from 'i18n-js';
import type * as I18nTypes from 'i18n-js';
import { I18n } from 'i18n-js/dist/require/index.js';

import ar_AR from './ar_AR.json';
import en_US from './en_US.json';
import es_419 from './es_419.json';
Expand Down Expand Up @@ -42,7 +44,7 @@ export type Locale =
| 'zh-CN';

// biome-ignore format: locale keys
export const i18n = new I18n({
export const i18n: I18nTypes.I18n = new I18n({
'ar': ar_AR,
'ar-AR': ar_AR,
'en': en_US,
Expand Down