Skip to content

Commit

Permalink
fix for node resolution, fixes #1589
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Dec 7, 2022
1 parent 83900fd commit 03640ed
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 33 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
### 12.1.1

- fix for node resolution [1589](https://github.com/i18next/react-i18next/issues/1589)

### 12.1.0

- context-less version of Trans component to be used for environments without react context [1588](https://github.com/i18next/react-i18next/pull/1588)
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -113,15 +113,16 @@
},
"scripts": {
"clean": "rimraf dist && mkdirp dist",
"copy": "cp-cli ./dist/umd/react-i18next.min.js ./react-i18next.min.js && cp-cli ./dist/umd/react-i18next.js ./react-i18next.js",
"copy": "cp-cli ./dist/umd/react-i18next.min.js ./react-i18next.min.js && cp-cli ./dist/umd/react-i18next.js ./react-i18next.js && echo '{\"type\":\"module\"}' > dist/es/package.json",
"build:es": "cross-env BABEL_ENV=jsnext babel src --out-dir dist/es",
"build:cjs": "babel src --out-dir dist/commonjs",
"build:umd": "rollup -c rollup.config.js --format umd && rollup -c rollup.config.js --format umd --uglify",
"build:amd": "rollup -c rollup.config.js --format amd && rollup -c rollup.config.js --format amd --uglify",
"build:iife": "rollup -c rollup.config.js --format iife && rollup -c rollup.config.js --format iife --uglify",
"build": "npm run clean && npm run build:cjs && npm run build:es && npm run build:umd && npm run build:amd && npm run copy",
"fix_dist_package": "node -e 'console.log(`{\"type\":\"module\",\"version\":\"${process.env.npm_package_version}\"}`)' > dist/es/package.json",
"preversion": "npm run build && git push",
"postversion": "git push && git push --tags",
"postversion": "npm run fix_dist_package && git push && git push --tags",
"pretest": "npm run test:typescript && npm run test:typescript:noninterop && npm run test:typescript:customtypes",
"test": "cross-env BABEL_ENV=development jest --no-cache",
"test:watch": "cross-env BABEL_ENV=development jest --no-cache --watch",
Expand Down
2 changes: 1 addition & 1 deletion src/I18nextProvider.js
@@ -1,5 +1,5 @@
import { createElement, useMemo } from 'react';
import { I18nContext } from './context';
import { I18nContext } from './context.js';

export function I18nextProvider({ i18n, defaultNS, children }) {
const value = useMemo(
Expand Down
4 changes: 2 additions & 2 deletions src/Trans.js
@@ -1,6 +1,6 @@
import { useContext } from 'react';
import { nodesToString, Trans as TransWithoutContext } from './TransWithoutContext';
import { getI18n, I18nContext } from './context';
import { nodesToString, Trans as TransWithoutContext } from './TransWithoutContext.js';
import { getI18n, I18nContext } from './context.js';

export { nodesToString };

Expand Down
6 changes: 3 additions & 3 deletions src/TransWithoutContext.js
@@ -1,8 +1,8 @@
import { isValidElement, cloneElement, createElement } from 'react';
import HTML from 'html-parse-stringify';
import { warn, warnOnce } from './utils';
import { getDefaults } from './defaults';
import { getI18n } from './i18nInstance';
import { warn, warnOnce } from './utils.js';
import { getDefaults } from './defaults.js';
import { getI18n } from './i18nInstance.js';

function hasChildren(node, checkLength) {
if (!node) return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Translation.js
@@ -1,4 +1,4 @@
import { useTranslation } from './useTranslation';
import { useTranslation } from './useTranslation.js';

export function Translation(props) {
const { ns, children, ...options } = props;
Expand Down
6 changes: 3 additions & 3 deletions src/context.js
@@ -1,7 +1,7 @@
import { createContext } from 'react';
import { getDefaults, setDefaults } from './defaults';
import { getI18n, setI18n } from './i18nInstance';
import { initReactI18next } from './initReactI18next';
import { getDefaults, setDefaults } from './defaults.js';
import { getI18n, setI18n } from './i18nInstance.js';
import { initReactI18next } from './initReactI18next.js';

export { getDefaults, setDefaults, getI18n, setI18n, initReactI18next };

Expand Down
2 changes: 1 addition & 1 deletion src/defaults.js
@@ -1,4 +1,4 @@
import { unescape } from './unescape';
import { unescape } from './unescape.js';

let defaultOptions = {
bindI18n: 'languageChanged',
Expand Down
18 changes: 9 additions & 9 deletions src/index.js
@@ -1,11 +1,11 @@
export { Trans } from './Trans';
export { Trans as TransWithoutContext } from './TransWithoutContext';
export { useTranslation } from './useTranslation';
export { withTranslation } from './withTranslation';
export { Translation } from './Translation';
export { I18nextProvider } from './I18nextProvider';
export { withSSR } from './withSSR';
export { useSSR } from './useSSR';
export { Trans } from './Trans.js';
export { Trans as TransWithoutContext } from './TransWithoutContext.js';
export { useTranslation } from './useTranslation.js';
export { withTranslation } from './withTranslation.js';
export { Translation } from './Translation.js';
export { I18nextProvider } from './I18nextProvider.js';
export { withSSR } from './withSSR.js';
export { useSSR } from './useSSR.js';

export {
I18nContext,
Expand All @@ -16,7 +16,7 @@ export {
getI18n,
composeInitialProps,
getInitialProps,
} from './context';
} from './context.js';

// dummy functions for icu.macro support

Expand Down
4 changes: 2 additions & 2 deletions src/initReactI18next.js
@@ -1,5 +1,5 @@
import { setDefaults } from './defaults';
import { setI18n } from './i18nInstance';
import { setDefaults } from './defaults.js';
import { setI18n } from './i18nInstance.js';

export const initReactI18next = {
type: '3rdParty',
Expand Down
4 changes: 2 additions & 2 deletions src/useSSR.js
@@ -1,5 +1,5 @@
import { useContext } from 'react';
import { getI18n, I18nContext } from './context';
import { getI18n, I18nContext } from './context.js';

export function useSSR(initialI18nStore, initialLanguage, props = {}) {
const { i18n: i18nFromProps } = props;
Expand All @@ -16,7 +16,7 @@ export function useSSR(initialI18nStore, initialLanguage, props = {}) {

// add namespaces to the config - so a languageChange call loads all namespaces needed
i18n.options.ns = Object.values(initialI18nStore).reduce((mem, lngResources) => {
Object.keys(lngResources).forEach(ns => {
Object.keys(lngResources).forEach((ns) => {
if (mem.indexOf(ns) < 0) mem.push(ns);
});
return mem;
Expand Down
4 changes: 2 additions & 2 deletions src/useTranslation.js
@@ -1,6 +1,6 @@
import { useState, useEffect, useContext, useRef } from 'react';
import { getI18n, getDefaults, ReportNamespaces, I18nContext } from './context';
import { warnOnce, loadNamespaces, hasLoadedNamespace } from './utils';
import { getI18n, getDefaults, ReportNamespaces, I18nContext } from './context.js';
import { warnOnce, loadNamespaces, hasLoadedNamespace } from './utils.js';

const usePrevious = (value, ignore) => {
const ref = useRef();
Expand Down
6 changes: 3 additions & 3 deletions src/withSSR.js
@@ -1,7 +1,7 @@
import { createElement } from 'react';
import { useSSR } from './useSSR';
import { composeInitialProps } from './context';
import { getDisplayName } from './utils';
import { useSSR } from './useSSR.js';
import { composeInitialProps } from './context.js';
import { getDisplayName } from './utils.js';

export function withSSR() {
return function Extend(WrappedComponent) {
Expand Down
4 changes: 2 additions & 2 deletions src/withTranslation.js
@@ -1,6 +1,6 @@
import { createElement, forwardRef as forwardRefReact } from 'react';
import { useTranslation } from './useTranslation';
import { getDisplayName } from './utils';
import { useTranslation } from './useTranslation.js';
import { getDisplayName } from './utils.js';

export function withTranslation(ns, options = {}) {
return function Extend(WrappedComponent) {
Expand Down

0 comments on commit 03640ed

Please sign in to comment.