diff --git a/package.json b/package.json index 812bdc4b1..0888cc43f 100644 --- a/package.json +++ b/package.json @@ -137,7 +137,7 @@ "format": "prettier \"{,**/}*.{ts,tsx,mts,js,json,md}\" --check", "format:fix": "prettier \"{,**/}*.{ts,tsx,mts,js,json,md}\" --write", "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:es": "cross-env BABEL_ENV=ESNext babel src --out-dir dist/es", "build:cjs": "babel src --out-dir dist/commonjs", "build:umd": "rollup -c rollup.config.mjs --format umd && rollup -c rollup.config.mjs --format umd --uglify", "build:amd": "rollup -c rollup.config.mjs --format amd && rollup -c rollup.config.mjs --format amd --uglify", diff --git a/src/Translation.js b/src/Translation.js index 208a33ca3..e49c87ae3 100644 --- a/src/Translation.js +++ b/src/Translation.js @@ -1,7 +1,6 @@ import { useTranslation } from './useTranslation.js'; -export function Translation(props) { - const { ns, children, ...options } = props; +export const Translation = ({ ns, children, ...options }) => { const [t, i18n, ready] = useTranslation(ns, options); return children( @@ -12,4 +11,4 @@ export function Translation(props) { }, ready, ); -} +}; diff --git a/src/utils.js b/src/utils.js index 1a19fd81d..8c10aa5e5 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,22 +1,20 @@ -// Do not use arrow function here as it will break optimizations of arguments -export function warn(...args) { +export const warn = (...args) => { if (console && console.warn) { if (isString(args[0])) args[0] = `react-i18next:: ${args[0]}`; console.warn(...args); } -} +}; const alreadyWarned = {}; -// Do not use arrow function here as it will break optimizations of arguments -export function warnOnce(...args) { +export const warnOnce = (...args) => { if (isString(args[0]) && alreadyWarned[args[0]]) return; if (isString(args[0])) alreadyWarned[args[0]] = new Date(); warn(...args); -} +}; // not needed right now // -// export function deprecated(...args) { +// export const deprecated = (...args) => { // if (process && process.env && (!process.env.NODE_ENV || process.env.NODE_ENV === 'development')) { // if (isString(args[0])) args[0] = `deprecation warning -> ${args[0]}`; // warnOnce(...args); diff --git a/tsconfig.json b/tsconfig.json index 8da4bd772..97aca3246 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,11 +2,11 @@ "exclude": ["example/**/*"], "compilerOptions": { - "module": "commonjs", - "target": "es5", - "lib": ["es6", "dom"], + "module": "ESNext", + "target": "ES2020", + "lib": ["ES2020", "dom"], "jsx": "react", - "moduleResolution": "node", + "moduleResolution": "bundler", "forceConsistentCasingInFileNames": true, "strict": true, "noEmit": true,