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

feat: test canary release of next-i18next #2864

Closed
wants to merge 6 commits into from
Closed
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 .ncurc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# @link https://github.com/raineorshine/npm-check-updates

# Add here exclusions on packages if any
reject: ['i18next', 'react-i18next']
reject: []
6 changes: 3 additions & 3 deletions apps/nextjs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,21 @@
"clsx": "1.2.1",
"cors": "2.8.5",
"graphql": "16.6.0",
"i18next": "21.10.0",
"i18next": "22.0.4",
"jose": "4.10.4",
"ky": "0.32.2",
"next": "13.0.2",
"next-auth": "4.16.2",
"next-connect": "0.13.0",
"next-i18next": "12.1.0",
"next-i18next": "workspace:*",
"next-secure-headers": "2.2.0",
"next-seo": "5.14.0",
"next-transpile-modules": "10.0.0",
"picocolors": "1.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "7.39.1",
"react-i18next": "11.18.6",
"react-i18next": "12.0.0",
"rooks": "7.4.1",
"sharp": "0.31.2",
"superjson": "1.11.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-app/src/lib/i18n/I18nNamespace.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CustomTypeOptions } from 'react-i18next';
import type { CustomTypeOptions } from 'i18next';

export type I18nNamespace = keyof CustomTypeOptions['resources'];

Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs-app/src/pages/admin/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { HttpBadRequest } from '@belgattitude/http-exception';
import type { GetStaticProps, InferGetStaticPropsType } from 'next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import type { ReactElement } from 'react';
import { adminConfig } from '@/features/admin/admin.config';
import { AdminLayout } from '@/features/admin/layouts';
import { AdminMainPage } from '@/features/admin/pages';
import { getServerSideTranslations } from '@/lib/i18n';

type Props = {
/** Add props here */
Expand All @@ -22,7 +22,7 @@ export const getStaticProps: GetStaticProps<Props> = async (context) => {
const { i18nNamespaces } = adminConfig;
return {
props: {
...(await serverSideTranslations(locale, i18nNamespaces)),
...(await getServerSideTranslations(locale, i18nNamespaces)),
},
// revalidate: 60,
};
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs-app/src/pages/auth/login.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { HttpBadRequest } from '@belgattitude/http-exception';
import type { GetStaticProps, InferGetStaticPropsType } from 'next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { authConfig } from '@/features/auth/auth.config';
import { LoginPage } from '@/features/auth/pages/LoginPage';
import { getServerSideTranslations } from '@/lib/i18n';

type Props = {
/** Add props here */
Expand All @@ -22,7 +22,7 @@ export const getStaticProps: GetStaticProps<Props> = async (context) => {
const { i18nNamespaces } = authConfig;
return {
props: {
...(await serverSideTranslations(locale, i18nNamespaces)),
...(await getServerSideTranslations(locale, i18nNamespaces)),
},
};
};
4 changes: 2 additions & 2 deletions apps/nextjs-app/src/pages/home.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { HttpBadRequest } from '@belgattitude/http-exception';
import type { GetServerSideProps, InferGetServerSidePropsType } from 'next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { homeConfig } from '@/features/home/home.config';
import { HomePage } from '@/features/home/pages';
import { getServerSideTranslations } from '@/lib/i18n';

type Props = {
/** Add HomeRoute props here */
Expand All @@ -24,7 +24,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (
const { i18nNamespaces } = homeConfig;
return {
props: {
...(await serverSideTranslations(locale, i18nNamespaces)),
...(await getServerSideTranslations(locale, i18nNamespaces)),
},
};
};
4 changes: 2 additions & 2 deletions apps/nextjs-app/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { HttpBadRequest } from '@belgattitude/http-exception';
import type { GetStaticProps, InferGetStaticPropsType } from 'next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { demoConfig } from '@/features/demo/demo.config';
import { DemoPage } from '@/features/demo/pages';
import { getServerSideTranslations } from '@/lib/i18n';

type Props = {
/** Add HomeRoute props here */
Expand All @@ -22,7 +22,7 @@ export const getStaticProps: GetStaticProps<Props> = async (context) => {
const { i18nNamespaces } = demoConfig;
return {
props: {
...(await serverSideTranslations(locale, i18nNamespaces)),
...(await getServerSideTranslations(locale, i18nNamespaces)),
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* you can opt out by commenting the following code.
* @link https://react.i18next.com/latest/typescript
*/
import 'react-i18next';
import 'i18next';
import type { I18nNamespaces } from '@your-org/common-i18n';

declare module 'react-i18next' {
declare module 'i18next' {
interface CustomTypeOptions {
defaultNS: 'common';
resources: I18nNamespaces;
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@
"@graphql-inspector/core": "https://github.com/kamilkisiela/graphql-inspector/issues/2175"
},
"resolutions": {
"@graphql-inspector/core": "3.3.0",
"i18next": "^22.0.0"
"@graphql-inspector/core": "3.3.0"
},
"dependencies": {
"cross-env": "7.0.3"
Expand Down
80 changes: 80 additions & 0 deletions packages/next-i18next/.size-limit.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// @ts-check

const fullEsmMaxSize = "5KB";
// Recent Nextjs version have some optimizations for commonjs that
// aren't available on bare-bone webpack. don't worry about threshold
// difference here for cjs. We can keep this till cjs is supported.
const fullCjsMaxSize = "29KB";

const getSimpleExamplePageLimits = () => {
const dir = './examples/simple/.next'
let manifest;
try {
manifest = require(`${dir}/build-manifest.json`);
} catch (e) {
throw new Error(
'Cannot find a NextJs build folder, did you forget to run build:examples ?'
);
}
const limitCfg = {
defaultSize: '90kb',
pages: {
'/': '85kb',
'/404': '90kb',
'/_app': '100kb',
'/_error': '80Kb',
'/second-page': '85Kb'
},
};
let pageLimits = [];
for (const [uri, paths] of Object.entries(manifest.pages)) {
pageLimits.push({
name: `Example app: page '${uri}'`,
limit: limitCfg.pages?.[uri] ?? limitCfg.defaultSize,
webpack: false,
path: paths.map(p => `${dir}/${p}`)
});
}
return pageLimits;
}

const modifyWebpackConfig = config => {
config.resolve = {};
config.resolve.fallback = { "path": false, "fs": false };
}

/**
* Will ensure esm tree-shakeability and total size are within expectations.
*
* @link https://github.com/ai/size-limit/
* @type {{name: string, path: string[], limit: string, import?: string, webpack?: boolean, modifyWebpackConfig: any}[]}
*/
module.exports = [
// ###################################################
// Dist ESM full bundle
// ###################################################
{
name: "ESM (import everything *)",
path: ["dist/esm/index.js"],
import: "*",
limit: fullEsmMaxSize,
modifyWebpackConfig,
},
// ###################################################
// Fist commonjs full bundle
// Tip: older versions of nextjs will not tree-shake
// cjs very well. This explains threshold differences
// ###################################################
{
name: "CJS (require everything *)",
path: ["dist/commonjs/index.js"],
import: "*",
webpack: true,
limit: fullCjsMaxSize,
modifyWebpackConfig,
},
// ###################################################
// Example apps
// ###################################################
...getSimpleExamplePageLimits(),
];
Loading