mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-11-18 07:22:06 +00:00
upgrade: 1st pass upgrade to Next.js v16
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"extends": ["next", "next/core-web-vitals", "prettier"],
|
||||
"globals": {
|
||||
"React": "readonly"
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@
|
||||
# pwa
|
||||
sw.*
|
||||
workbox*.*
|
||||
swe-worker*.*
|
||||
!src/app/sw.ts
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import nextCoreWebVitals from "eslint-config-next/core-web-vitals";
|
||||
import prettier from "eslint-config-prettier";
|
||||
import reactHooks from "eslint-plugin-react-hooks";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
export default [
|
||||
{
|
||||
ignores: [
|
||||
".next/**",
|
||||
"out/**",
|
||||
"build/**",
|
||||
"next-env.d.ts",
|
||||
"public/sw.js",
|
||||
"public/workbox-*.js",
|
||||
"public/swe-worker-*.js",
|
||||
],
|
||||
},
|
||||
...nextCoreWebVitals,
|
||||
{
|
||||
plugins: {
|
||||
"@typescript-eslint": tseslint.plugin,
|
||||
"react-hooks": reactHooks,
|
||||
},
|
||||
rules: {
|
||||
"@typescript-eslint/no-unused-vars": "warn",
|
||||
"@typescript-eslint/no-unused-expressions": "warn",
|
||||
"react-hooks/immutability": "warn",
|
||||
"react-hooks/refs": "warn",
|
||||
"react-hooks/set-state-in-effect": "warn",
|
||||
},
|
||||
},
|
||||
prettier,
|
||||
];
|
||||
+12
-6
@@ -7,10 +7,16 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({
|
||||
|
||||
const withNextIntl = require("next-intl/plugin")("./src/i18n.ts");
|
||||
|
||||
const withPWA = require("next-pwa")({
|
||||
dest: "public",
|
||||
disable: process.env.NODE_ENV === "development",
|
||||
});
|
||||
// PWA service worker, generated with Serwist. It hooks into webpack, so it is
|
||||
// only enabled for production builds (`next build --webpack`) and disabled for
|
||||
// development, letting `next dev` keep running on Turbopack.
|
||||
const withSerwist =
|
||||
process.env.NODE_ENV === "production"
|
||||
? require("@serwist/next").default({
|
||||
swSrc: "src/app/sw.ts",
|
||||
swDest: "public/sw.js",
|
||||
disable: process.env.NODE_ENV !== "production",
|
||||
})
|
||||
: (config) => config;
|
||||
|
||||
module.exports = nextConfig;
|
||||
module.exports = withBundleAnalyzer(withNextIntl(withPWA({})));
|
||||
module.exports = withBundleAnalyzer(withNextIntl(withSerwist(nextConfig)));
|
||||
+10
-10
@@ -5,9 +5,9 @@
|
||||
"scripts": {
|
||||
"test": "vitest --config vitetest.config.ts",
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"build": "next build --webpack",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"lint": "eslint .",
|
||||
"typeCheck": "tsc -p ./tsconfig.json",
|
||||
"format": "prettier --check \"**/*.{js,jsx,ts,tsx}\"",
|
||||
"format:fix": "prettier --write \"**/*.{js,jsx,ts,tsx}\""
|
||||
@@ -19,7 +19,8 @@
|
||||
"@headlessui/tailwindcss": "^0.2.1",
|
||||
"@hookform/resolvers": "^3.9.0",
|
||||
"@infra-blocks/zod-utils": "^0.4.2",
|
||||
"@next/bundle-analyzer": "^14.0.4",
|
||||
"@next/bundle-analyzer": "^16.3.6",
|
||||
"@serwist/next": "^9.5.12",
|
||||
"@socialgouv/matomo-next": "^1.10.0",
|
||||
"@tanstack/react-query": "^5.29.0",
|
||||
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
|
||||
@@ -38,10 +39,9 @@
|
||||
"leaflet.smooth_marker_bouncing": "3.0.3",
|
||||
"lodash": "^4.17.21",
|
||||
"mongodb": "^7.0.0",
|
||||
"next": "^14.2.3",
|
||||
"next-auth": "^5.0.0-beta.16",
|
||||
"next-intl": "^3.3.2",
|
||||
"next-pwa": "^5.6.0",
|
||||
"next": "^16.3.6",
|
||||
"next-auth": "^5.0.0-beta.32",
|
||||
"next-intl": "^4.14.7",
|
||||
"next-safe-action": "^7.9.3",
|
||||
"nodemailer": "^6.9.12",
|
||||
"postcss": "^8.4.47",
|
||||
@@ -57,6 +57,7 @@
|
||||
"react-leaflet-draw": "^0.20.4",
|
||||
"react-select": "^5.7.4",
|
||||
"react-tooltip": "^5.18.0",
|
||||
"serwist": "^9.5.12",
|
||||
"sharp": "^0.33.0",
|
||||
"superjson": "^2.2.1",
|
||||
"tailwind-merge": "^2.0.0",
|
||||
@@ -77,10 +78,9 @@
|
||||
"@types/react-date-range": "^1.4.9",
|
||||
"@types/react-dom": "^19.3.0",
|
||||
"@types/react-input-mask": "^3.0.2",
|
||||
"eslint": "8",
|
||||
"eslint-config-next": "^14.0.4",
|
||||
"eslint": "^9.0.0",
|
||||
"eslint-config-next": "^16.3.6",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-plugin-react-hooks": "^5.0.0-canary-7118f5dd7-20230705",
|
||||
"prettier": "^3.1.1",
|
||||
"prettier-plugin-tailwindcss": "^0.6.8"
|
||||
},
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
self.__WB_DISABLE_DEV_LOGS=!0;
|
||||
@@ -4,10 +4,11 @@ import SignInClient from "@/app/[locale]/(main)/auth/sign-in/SignInClient";
|
||||
import { baseUrl } from "@/constants";
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
|
||||
@@ -12,10 +12,11 @@ import ClubsDisplay from "./ClubsDisplay";
|
||||
export const revalidate = 3600; // Revalidate cache every 6 hours
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
|
||||
@@ -4,10 +4,11 @@ import EloClient from "@/app/[locale]/(main)/elo/EloClient";
|
||||
import { baseUrl } from "@/constants";
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
|
||||
@@ -20,10 +20,11 @@ import TournamentsDisplay from "./TournamentsDisplay";
|
||||
setDefaultOptions({ locale: fr });
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
return {
|
||||
alternates: {
|
||||
canonical:
|
||||
|
||||
|
Before Width: | Height: | Size: 197 KiB After Width: | Height: | Size: 197 KiB |
@@ -21,12 +21,13 @@ const title = Julius_Sans_One({
|
||||
});
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}) {
|
||||
// While the `locale` is required, the namespace is optional and
|
||||
// identical to the parameter that `useTranslations` accepts.
|
||||
const { locale } = await params;
|
||||
const t = await getTranslations({
|
||||
locale: locale ?? "fr",
|
||||
namespace: "Metadata",
|
||||
@@ -48,11 +49,12 @@ export async function generateMetadata({
|
||||
|
||||
export default async function RootLayout({
|
||||
children,
|
||||
params: { locale },
|
||||
params,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
params: { locale?: string };
|
||||
params: Promise<{ locale?: string }>;
|
||||
}) {
|
||||
const { locale } = await params;
|
||||
let messages;
|
||||
try {
|
||||
messages = (await import(`@/messages/${locale}.json`)).default;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { GrLineChart } from "react-icons/gr";
|
||||
import { HiUserGroup } from "react-icons/hi2";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import bannerImage from "/public/banner.jpeg";
|
||||
import bannerImage from "./banner.jpeg";
|
||||
import { Link } from "@/utils/routing";
|
||||
|
||||
export default function Home() {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { defaultCache } from "@serwist/next/worker";
|
||||
import type { PrecacheEntry } from "serwist";
|
||||
import { Serwist } from "serwist";
|
||||
|
||||
declare global {
|
||||
interface WorkerGlobalScope {
|
||||
__SW_MANIFEST: (PrecacheEntry | string)[] | undefined;
|
||||
}
|
||||
}
|
||||
|
||||
declare const self: WorkerGlobalScope;
|
||||
|
||||
const serwist = new Serwist({
|
||||
precacheEntries: self.__SW_MANIFEST,
|
||||
skipWaiting: true,
|
||||
clientsClaim: true,
|
||||
navigationPreload: true,
|
||||
runtimeCaching: defaultCache,
|
||||
});
|
||||
|
||||
serwist.addEventListeners();
|
||||
@@ -193,11 +193,16 @@ export const Map = ({
|
||||
const referencedMarkers = useMemo(
|
||||
() =>
|
||||
markers.map((marker) =>
|
||||
React.cloneElement(marker.component, {
|
||||
ref: (ref: MarkerRef) => {
|
||||
markerRefs.current[marker.markerId] = ref;
|
||||
React.cloneElement(
|
||||
marker.component as React.ReactElement<{
|
||||
ref?: (ref: MarkerRef) => void;
|
||||
}>,
|
||||
{
|
||||
ref: (ref: MarkerRef) => {
|
||||
markerRefs.current[marker.markerId] = ref;
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
),
|
||||
[markers],
|
||||
);
|
||||
|
||||
@@ -17,7 +17,7 @@ import { Field, GenericFieldProps } from "./Field";
|
||||
|
||||
export type BaseOption<T = string, D = unknown> = {
|
||||
value: T;
|
||||
label: string | JSX.Element;
|
||||
label: string | React.JSX.Element;
|
||||
disabled?: boolean;
|
||||
data?: D;
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Prettify } from "@/types";
|
||||
|
||||
export type BaseOption<T = string, D = unknown> = {
|
||||
value: T;
|
||||
label: string | JSX.Element;
|
||||
label: string | React.JSX.Element;
|
||||
disabled?: boolean;
|
||||
data?: D;
|
||||
};
|
||||
|
||||
@@ -91,7 +91,7 @@ export const TournamentSelectField = <
|
||||
background: `${TimeControlColours[option.data!.timeControl]}`,
|
||||
}}
|
||||
>
|
||||
{at("timeControlEnum", { tc: option.data?.timeControl })}
|
||||
{at("timeControlEnum", { tc: option.data!.timeControl })}
|
||||
</div>
|
||||
<div className="text-xs">{option.data?.date}</div>
|
||||
</div>
|
||||
|
||||
@@ -20,7 +20,7 @@ export type ZoneEditorProps = {
|
||||
|
||||
export const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => {
|
||||
const initialFeatures = React.useRef(value?.features);
|
||||
const featureGroup = React.useRef<L.FeatureGroup>();
|
||||
const featureGroup = React.useRef<L.FeatureGroup | null>(null);
|
||||
|
||||
const setFeatureCollectionRef = (element: L.FeatureGroup) => {
|
||||
featureGroup.current = element;
|
||||
|
||||
@@ -6,7 +6,7 @@ const useDatePickerWidth = ({
|
||||
datePickerRef,
|
||||
setDateDirectionState,
|
||||
}: {
|
||||
datePickerRef: RefObject<HTMLDivElement>;
|
||||
datePickerRef: RefObject<HTMLDivElement | null>;
|
||||
setDateDirectionState: Dispatch<SetStateAction<DatePickerDirection>>;
|
||||
}) => {
|
||||
useEffect(() => {
|
||||
|
||||
+4
-2
@@ -3,11 +3,13 @@ import { notFound } from "next/navigation";
|
||||
|
||||
import { routing } from "./utils/routing";
|
||||
|
||||
export default getRequestConfig(async ({ locale }) => {
|
||||
export default getRequestConfig(async ({ requestLocale }) => {
|
||||
// Validate that the incoming `locale` parameter is valid
|
||||
if (!routing.locales.includes(locale as any)) notFound();
|
||||
const locale = await requestLocale;
|
||||
if (!locale || !routing.locales.includes(locale as any)) notFound();
|
||||
|
||||
return {
|
||||
locale,
|
||||
messages: (
|
||||
await (locale === "en"
|
||||
? // When using Turbopack, this will enable HMR for `en`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createLocalizedPathnamesNavigation } from "next-intl/navigation";
|
||||
import { createNavigation } from "next-intl/navigation";
|
||||
import { defineRouting } from "next-intl/routing";
|
||||
|
||||
export const routing = defineRouting({
|
||||
@@ -62,4 +62,4 @@ export type Pathnames = keyof typeof routing.pathnames;
|
||||
export type Locale = (typeof routing.locales)[number];
|
||||
|
||||
export const { Link, redirect, usePathname, useRouter, getPathname } =
|
||||
createLocalizedPathnamesNavigation(routing);
|
||||
createNavigation(routing);
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"jsx": "react-jsx",
|
||||
"incremental": true,
|
||||
"plugins": [
|
||||
{
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
// To disable all workbox logging during development, you can set self.__WB_DISABLE_DEV_LOGS to true
|
||||
// https://developers.google.com/web/tools/workbox/guides/configure-workbox#disable_logging
|
||||
|
||||
// eslint-disable-next-line no-underscore-dangle,no-restricted-globals
|
||||
self.__WB_DISABLE_DEV_LOGS = true;
|
||||
Reference in New Issue
Block a user