upgrade: 1st pass upgrade to Next.js v16

This commit is contained in:
2026-09-28 20:59:11 +02:00
parent abb766c2ae
commit d57fa83aca
26 changed files with 1101 additions and 2313 deletions
-6
View File
@@ -1,6 +0,0 @@
{
"extends": ["next", "next/core-web-vitals", "prettier"],
"globals": {
"React": "readonly"
}
}
+2
View File
@@ -12,6 +12,8 @@
# pwa # pwa
sw.* sw.*
workbox*.* workbox*.*
swe-worker*.*
!src/app/sw.ts
# testing # testing
/coverage /coverage
+33
View File
@@ -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
View File
@@ -7,10 +7,16 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({
const withNextIntl = require("next-intl/plugin")("./src/i18n.ts"); const withNextIntl = require("next-intl/plugin")("./src/i18n.ts");
const withPWA = require("next-pwa")({ // PWA service worker, generated with Serwist. It hooks into webpack, so it is
dest: "public", // only enabled for production builds (`next build --webpack`) and disabled for
disable: process.env.NODE_ENV === "development", // 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(withSerwist(nextConfig)));
module.exports = withBundleAnalyzer(withNextIntl(withPWA({})));
+10 -10
View File
@@ -5,9 +5,9 @@
"scripts": { "scripts": {
"test": "vitest --config vitetest.config.ts", "test": "vitest --config vitetest.config.ts",
"dev": "next dev", "dev": "next dev",
"build": "next build", "build": "next build --webpack",
"start": "next start", "start": "next start",
"lint": "next lint", "lint": "eslint .",
"typeCheck": "tsc -p ./tsconfig.json", "typeCheck": "tsc -p ./tsconfig.json",
"format": "prettier --check \"**/*.{js,jsx,ts,tsx}\"", "format": "prettier --check \"**/*.{js,jsx,ts,tsx}\"",
"format:fix": "prettier --write \"**/*.{js,jsx,ts,tsx}\"" "format:fix": "prettier --write \"**/*.{js,jsx,ts,tsx}\""
@@ -19,7 +19,8 @@
"@headlessui/tailwindcss": "^0.2.1", "@headlessui/tailwindcss": "^0.2.1",
"@hookform/resolvers": "^3.9.0", "@hookform/resolvers": "^3.9.0",
"@infra-blocks/zod-utils": "^0.4.2", "@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", "@socialgouv/matomo-next": "^1.10.0",
"@tanstack/react-query": "^5.29.0", "@tanstack/react-query": "^5.29.0",
"@trivago/prettier-plugin-sort-imports": "^4.2.0", "@trivago/prettier-plugin-sort-imports": "^4.2.0",
@@ -38,10 +39,9 @@
"leaflet.smooth_marker_bouncing": "3.0.3", "leaflet.smooth_marker_bouncing": "3.0.3",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mongodb": "^7.0.0", "mongodb": "^7.0.0",
"next": "^14.2.3", "next": "^16.3.6",
"next-auth": "^5.0.0-beta.16", "next-auth": "^5.0.0-beta.32",
"next-intl": "^3.3.2", "next-intl": "^4.14.7",
"next-pwa": "^5.6.0",
"next-safe-action": "^7.9.3", "next-safe-action": "^7.9.3",
"nodemailer": "^6.9.12", "nodemailer": "^6.9.12",
"postcss": "^8.4.47", "postcss": "^8.4.47",
@@ -57,6 +57,7 @@
"react-leaflet-draw": "^0.20.4", "react-leaflet-draw": "^0.20.4",
"react-select": "^5.7.4", "react-select": "^5.7.4",
"react-tooltip": "^5.18.0", "react-tooltip": "^5.18.0",
"serwist": "^9.5.12",
"sharp": "^0.33.0", "sharp": "^0.33.0",
"superjson": "^2.2.1", "superjson": "^2.2.1",
"tailwind-merge": "^2.0.0", "tailwind-merge": "^2.0.0",
@@ -77,10 +78,9 @@
"@types/react-date-range": "^1.4.9", "@types/react-date-range": "^1.4.9",
"@types/react-dom": "^19.3.0", "@types/react-dom": "^19.3.0",
"@types/react-input-mask": "^3.0.2", "@types/react-input-mask": "^3.0.2",
"eslint": "8", "eslint": "^9.0.0",
"eslint-config-next": "^14.0.4", "eslint-config-next": "^16.3.6",
"eslint-config-prettier": "^9.0.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-react-hooks": "^5.0.0-canary-7118f5dd7-20230705",
"prettier": "^3.1.1", "prettier": "^3.1.1",
"prettier-plugin-tailwindcss": "^0.6.8" "prettier-plugin-tailwindcss": "^0.6.8"
}, },
-1
View File
@@ -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"; import { baseUrl } from "@/constants";
export async function generateMetadata({ export async function generateMetadata({
params: { locale }, params,
}: { }: {
params: { locale?: string }; params: Promise<{ locale?: string }>;
}): Promise<Metadata> { }): Promise<Metadata> {
const { locale } = await params;
return { return {
alternates: { alternates: {
canonical: canonical:
+3 -2
View File
@@ -12,10 +12,11 @@ import ClubsDisplay from "./ClubsDisplay";
export const revalidate = 3600; // Revalidate cache every 6 hours export const revalidate = 3600; // Revalidate cache every 6 hours
export async function generateMetadata({ export async function generateMetadata({
params: { locale }, params,
}: { }: {
params: { locale?: string }; params: Promise<{ locale?: string }>;
}): Promise<Metadata> { }): Promise<Metadata> {
const { locale } = await params;
return { return {
alternates: { alternates: {
canonical: canonical:
+3 -2
View File
@@ -4,10 +4,11 @@ import EloClient from "@/app/[locale]/(main)/elo/EloClient";
import { baseUrl } from "@/constants"; import { baseUrl } from "@/constants";
export async function generateMetadata({ export async function generateMetadata({
params: { locale }, params,
}: { }: {
params: { locale?: string }; params: Promise<{ locale?: string }>;
}): Promise<Metadata> { }): Promise<Metadata> {
const { locale } = await params;
return { return {
alternates: { alternates: {
canonical: canonical:
+3 -2
View File
@@ -20,10 +20,11 @@ import TournamentsDisplay from "./TournamentsDisplay";
setDefaultOptions({ locale: fr }); setDefaultOptions({ locale: fr });
export async function generateMetadata({ export async function generateMetadata({
params: { locale }, params,
}: { }: {
params: { locale?: string }; params: Promise<{ locale?: string }>;
}): Promise<Metadata> { }): Promise<Metadata> {
const { locale } = await params;
return { return {
alternates: { alternates: {
canonical: canonical:

Before

Width:  |  Height:  |  Size: 197 KiB

After

Width:  |  Height:  |  Size: 197 KiB

+6 -4
View File
@@ -21,12 +21,13 @@ const title = Julius_Sans_One({
}); });
export async function generateMetadata({ export async function generateMetadata({
params: { locale }, params,
}: { }: {
params: { locale?: string }; params: Promise<{ locale?: string }>;
}) { }) {
// While the `locale` is required, the namespace is optional and // While the `locale` is required, the namespace is optional and
// identical to the parameter that `useTranslations` accepts. // identical to the parameter that `useTranslations` accepts.
const { locale } = await params;
const t = await getTranslations({ const t = await getTranslations({
locale: locale ?? "fr", locale: locale ?? "fr",
namespace: "Metadata", namespace: "Metadata",
@@ -48,11 +49,12 @@ export async function generateMetadata({
export default async function RootLayout({ export default async function RootLayout({
children, children,
params: { locale }, params,
}: { }: {
children: ReactNode; children: ReactNode;
params: { locale?: string }; params: Promise<{ locale?: string }>;
}) { }) {
const { locale } = await params;
let messages; let messages;
try { try {
messages = (await import(`@/messages/${locale}.json`)).default; messages = (await import(`@/messages/${locale}.json`)).default;
+1 -1
View File
@@ -5,7 +5,7 @@ import { GrLineChart } from "react-icons/gr";
import { HiUserGroup } from "react-icons/hi2"; import { HiUserGroup } from "react-icons/hi2";
import { twMerge } from "tailwind-merge"; import { twMerge } from "tailwind-merge";
import bannerImage from "/public/banner.jpeg"; import bannerImage from "./banner.jpeg";
import { Link } from "@/utils/routing"; import { Link } from "@/utils/routing";
export default function Home() { export default function Home() {
+21
View File
@@ -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();
+7 -2
View File
@@ -193,11 +193,16 @@ export const Map = ({
const referencedMarkers = useMemo( const referencedMarkers = useMemo(
() => () =>
markers.map((marker) => markers.map((marker) =>
React.cloneElement(marker.component, { React.cloneElement(
marker.component as React.ReactElement<{
ref?: (ref: MarkerRef) => void;
}>,
{
ref: (ref: MarkerRef) => { ref: (ref: MarkerRef) => {
markerRefs.current[marker.markerId] = ref; markerRefs.current[marker.markerId] = ref;
}, },
}), },
),
), ),
[markers], [markers],
); );
+1 -1
View File
@@ -17,7 +17,7 @@ import { Field, GenericFieldProps } from "./Field";
export type BaseOption<T = string, D = unknown> = { export type BaseOption<T = string, D = unknown> = {
value: T; value: T;
label: string | JSX.Element; label: string | React.JSX.Element;
disabled?: boolean; disabled?: boolean;
data?: D; data?: D;
}; };
+1 -1
View File
@@ -8,7 +8,7 @@ import { Prettify } from "@/types";
export type BaseOption<T = string, D = unknown> = { export type BaseOption<T = string, D = unknown> = {
value: T; value: T;
label: string | JSX.Element; label: string | React.JSX.Element;
disabled?: boolean; disabled?: boolean;
data?: D; data?: D;
}; };
@@ -91,7 +91,7 @@ export const TournamentSelectField = <
background: `${TimeControlColours[option.data!.timeControl]}`, background: `${TimeControlColours[option.data!.timeControl]}`,
}} }}
> >
{at("timeControlEnum", { tc: option.data?.timeControl })} {at("timeControlEnum", { tc: option.data!.timeControl })}
</div> </div>
<div className="text-xs">{option.data?.date}</div> <div className="text-xs">{option.data?.date}</div>
</div> </div>
+1 -1
View File
@@ -20,7 +20,7 @@ export type ZoneEditorProps = {
export const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => { export const ZoneEditor = ({ value, onChange }: ZoneEditorProps) => {
const initialFeatures = React.useRef(value?.features); 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) => { const setFeatureCollectionRef = (element: L.FeatureGroup) => {
featureGroup.current = element; featureGroup.current = element;
+1 -1
View File
@@ -6,7 +6,7 @@ const useDatePickerWidth = ({
datePickerRef, datePickerRef,
setDateDirectionState, setDateDirectionState,
}: { }: {
datePickerRef: RefObject<HTMLDivElement>; datePickerRef: RefObject<HTMLDivElement | null>;
setDateDirectionState: Dispatch<SetStateAction<DatePickerDirection>>; setDateDirectionState: Dispatch<SetStateAction<DatePickerDirection>>;
}) => { }) => {
useEffect(() => { useEffect(() => {
+4 -2
View File
@@ -3,11 +3,13 @@ import { notFound } from "next/navigation";
import { routing } from "./utils/routing"; import { routing } from "./utils/routing";
export default getRequestConfig(async ({ locale }) => { export default getRequestConfig(async ({ requestLocale }) => {
// Validate that the incoming `locale` parameter is valid // 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 { return {
locale,
messages: ( messages: (
await (locale === "en" await (locale === "en"
? // When using Turbopack, this will enable HMR for `en` ? // When using Turbopack, this will enable HMR for `en`
View File
+2 -2
View File
@@ -1,4 +1,4 @@
import { createLocalizedPathnamesNavigation } from "next-intl/navigation"; import { createNavigation } from "next-intl/navigation";
import { defineRouting } from "next-intl/routing"; import { defineRouting } from "next-intl/routing";
export const routing = defineRouting({ export const routing = defineRouting({
@@ -62,4 +62,4 @@ export type Pathnames = keyof typeof routing.pathnames;
export type Locale = (typeof routing.locales)[number]; export type Locale = (typeof routing.locales)[number];
export const { Link, redirect, usePathname, useRouter, getPathname } = export const { Link, redirect, usePathname, useRouter, getPathname } =
createLocalizedPathnamesNavigation(routing); createNavigation(routing);
+1 -1
View File
@@ -16,7 +16,7 @@
"moduleResolution": "bundler", "moduleResolution": "bundler",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve", "jsx": "react-jsx",
"incremental": true, "incremental": true,
"plugins": [ "plugins": [
{ {
-5
View File
@@ -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;
+982 -2257
View File
File diff suppressed because it is too large Load Diff