From 91582bd583543180c956e9b25d4651d9d590b4ab Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 24 Dec 2023 20:12:01 +0100 Subject: [PATCH 1/3] [docs] Update Next.js to v13.5.6 --- CONTRIBUTING.md | 2 +- docs/next.config.mjs | 26 +++++++++++++++++--------- docs/package.json | 5 ++--- netlify.toml | 2 +- package.json | 1 - pnpm-lock.yaml | 2 +- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 60a57fd49d0273..3849faf72350a3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -238,7 +238,7 @@ Clicking on **Details** will show you the differences. #### deploy/netlify This renders a preview of the docs with your changes if it succeeds. -Otherwise `pnpm docs:build` or `pnpm docs:export` usually fail locally as well. +Otherwise `yarn docs:build` usually fail locally as well. #### codecov/project diff --git a/docs/next.config.mjs b/docs/next.config.mjs index 55248cc2e94c07..3003172d42ea77 100644 --- a/docs/next.config.mjs +++ b/docs/next.config.mjs @@ -174,6 +174,7 @@ export default withDocsInfra({ ? `Basic ${Buffer.from(process.env.GITHUB_AUTH).toString('base64')}` : '', }, + distDir: 'export', // Next.js provides a `defaultPathMap` argument, we could simplify the logic. // However, we don't in order to prevent any regression in the `findPages()` method. // @ts-ignore @@ -232,13 +233,20 @@ export default withDocsInfra({ return map; }, - // rewrites has no effect when run `next export` for production - rewrites: async () => { - return [ - { source: `/:lang(${LANGUAGES.join('|')})?/:rest*`, destination: '/:rest*' }, - // Make sure to include the trailing slash if `trailingSlash` option is set - { source: '/api/:rest*/', destination: '/api-docs/:rest*/' }, - { source: `/static/x/:rest*`, destination: 'http://0.0.0.0:3001/static/x/:rest*' }, - ]; - }, + // Used to signal we run yarn build + ...(process.env.NODE_ENV === 'production' + ? { + output: 'export', + } + : { + // rewrites has no effect when run `next export` for production + rewrites: async () => { + return [ + { source: `/:lang(${LANGUAGES.join('|')})?/:rest*`, destination: '/:rest*' }, + // Make sure to include the trailing slash if `trailingSlash` option is set + { source: '/api/:rest*/', destination: '/api-docs/:rest*/' }, + { source: `/static/x/:rest*`, destination: 'http://0.0.0.0:3001/static/x/:rest*' }, + ]; + }, + }), }); diff --git a/docs/package.json b/docs/package.json index 24a5e6e1342895..acf7e7df83f350 100644 --- a/docs/package.json +++ b/docs/package.json @@ -5,12 +5,11 @@ "author": "MUI Team", "license": "MIT", "scripts": { - "build": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 next build --profile", + "build": "rimraf docs/export && cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 next build --profile && pnpm build-sw", "build:clean": "rimraf .next && pnpm build", "build-sw": "node ./scripts/buildServiceWorker.js", "dev": "next dev", "deploy": "git push -f material-ui-docs master:latest", - "export": "rimraf docs/export && next export --threads=3 -o export && pnpm build-sw", "icons": "rimraf --glob public/static/icons/* && node ./scripts/buildIcons.js", "start": "next start", "create-playground": "cpy --cwd=scripts playground.template.tsx ../../pages/playground --rename=index.tsx", @@ -84,7 +83,7 @@ "lz-string": "^1.5.0", "markdown-to-jsx": "^7.4.1", "material-ui-popup-state": "^5.0.10", - "next": "13.5.1", + "next": "^13.5.1", "notistack": "3.0.1", "nprogress": "^0.2.0", "postcss": "^8.4.33", diff --git a/netlify.toml b/netlify.toml index 2328098efcbe53..6745d8863ce9d4 100644 --- a/netlify.toml +++ b/netlify.toml @@ -5,7 +5,7 @@ publish = "docs/export/" # Default build command. - command = "pnpm docs:build && pnpm docs:export" + command = "pnpm docs:build" [build.environment] NODE_VERSION = "18" diff --git a/package.json b/package.json index 0c5fdd82c6ce64..92635d84dac9f0 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ "docs:build-color-preview": "babel-node scripts/buildColorTypes", "docs:deploy": "pnpm --filter docs run deploy", "docs:dev": "pnpm --filter docs dev", - "docs:export": "pnpm --filter docs export", "docs:icons": "pnpm --filter docs icons", "docs:size-why": "cross-env DOCS_STATS_ENABLED=true pnpm docs:build", "docs:start": "pnpm --filter docs start", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f17d8a145db7f6..04e11d49f7c4fa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -737,7 +737,7 @@ importers: specifier: ^5.0.10 version: 5.0.10(@emotion/react@11.11.3)(@emotion/styled@11.11.0)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0) next: - specifier: 13.5.1 + specifier: ^13.5.1 version: 13.5.1(@babel/core@7.23.9)(babel-plugin-macros@3.1.0)(react-dom@18.2.0)(react@18.2.0) notistack: specifier: 3.0.1 From b499bebc1716ea6290064655660aa89d0d0403b7 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Fri, 9 Feb 2024 15:26:13 +0100 Subject: [PATCH 2/3] Polish Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com> Signed-off-by: Olivier Tassinari --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3849faf72350a3..9c7b4b1d1ca47a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -238,7 +238,7 @@ Clicking on **Details** will show you the differences. #### deploy/netlify This renders a preview of the docs with your changes if it succeeds. -Otherwise `yarn docs:build` usually fail locally as well. +Otherwise `yarn docs:build` usually fails locally as well. #### codecov/project From 1c61afe970d5af81a7cd6bf809538e18fe7247b4 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Fri, 9 Feb 2024 15:26:40 +0100 Subject: [PATCH 3/3] Update CONTRIBUTING.md Signed-off-by: Olivier Tassinari --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9c7b4b1d1ca47a..c29c80d7ee367b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -238,7 +238,7 @@ Clicking on **Details** will show you the differences. #### deploy/netlify This renders a preview of the docs with your changes if it succeeds. -Otherwise `yarn docs:build` usually fails locally as well. +Otherwise `pnpm docs:build` usually fails locally as well. #### codecov/project