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

Build config and optimizations #1769

Merged
merged 2 commits into from
Jul 16, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions src/Translation.js
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -12,4 +11,4 @@ export function Translation(props) {
},
ready,
);
}
};
12 changes: 5 additions & 7 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
8 changes: 4 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading