From b4e36dfa4a2b59a4a9b7a342a9ae377001862e27 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Tue, 6 Aug 2024 02:50:14 +0900 Subject: [PATCH 1/7] chore: upgrade next to 14.2.5 --- next-env.d.ts | 1 + package.json | 2 +- .../{next+13.4.1.patch => next+14.2.5.patch} | 6 +- tsconfig.json | 10 +- yarn.lock | 179 +++++++++--------- 5 files changed, 103 insertions(+), 95 deletions(-) rename patches/{next+13.4.1.patch => next+14.2.5.patch} (88%) diff --git a/next-env.d.ts b/next-env.d.ts index 4f11a03dc6c..fd36f9494e2 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,5 +1,6 @@ /// /// +/// // NOTE: This file should not be edited // see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/package.json b/package.json index 1f63eb121b2..576986a7940 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "date-fns": "^2.16.1", "debounce": "^1.2.1", "github-slugger": "^1.3.0", - "next": "^13.4.1", + "next": "^14.2.5", "next-remote-watch": "^1.0.0", "parse-numeric-range": "^1.2.0", "react": "^0.0.0-experimental-16d053d59-20230506", diff --git a/patches/next+13.4.1.patch b/patches/next+14.2.5.patch similarity index 88% rename from patches/next+13.4.1.patch rename to patches/next+14.2.5.patch index 6de490aa45c..72303ed8f37 100644 --- a/patches/next+13.4.1.patch +++ b/patches/next+14.2.5.patch @@ -1,12 +1,12 @@ diff --git a/node_modules/next/dist/server/render.js b/node_modules/next/dist/server/render.js -index a1f8648..1b3d608 100644 +index b808abf..94ee987 100644 --- a/node_modules/next/dist/server/render.js +++ b/node_modules/next/dist/server/render.js -@@ -758,9 +758,14 @@ async function renderToHTML(req, res, pathname, query, renderOpts) { +@@ -831,9 +831,14 @@ async function renderToHTMLImpl(req, res, pathname, query, renderOpts, extra) { // Always using react concurrent rendering mode with required react version 18.x const renderShell = async (EnhancedApp, EnhancedComponent)=>{ const content = renderContent(EnhancedApp, EnhancedComponent); -- return await (0, _nodewebstreamshelper.renderToInitialStream)({ +- return await (0, _nodewebstreamshelper.renderToInitialFizzStream)({ - ReactDOMServer: _serverbrowser.default, - element: content + return new Promise((resolve, reject) => { diff --git a/tsconfig.json b/tsconfig.json index 440b38510fa..9d72e01bc55 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,12 +22,18 @@ "isolatedModules": true, "jsx": "preserve", "baseUrl": "src", - "incremental": true + "incremental": true, + "plugins": [ + { + "name": "next" + } + ] }, "include": [ "next-env.d.ts", "src/**/*.ts", - "src/**/*.tsx" + "src/**/*.tsx", + ".next/types/**/*.ts" ], "exclude": [ "node_modules" diff --git a/yarn.lock b/yarn.lock index d8da351ba43..ed3223930d9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -850,10 +850,10 @@ unist-util-visit "^4.0.0" vfile "^5.0.0" -"@next/env@13.4.1": - version "13.4.1" - resolved "https://registry.yarnpkg.com/@next/env/-/env-13.4.1.tgz#57322da2630b6bb6d7204577b0a18f6f9324db0c" - integrity sha512-eD6WCBMFjLFooLM19SIhSkWBHtaFrZFfg2Cxnyl3vS3DAdFRfnx5TY2RxlkuKXdIRCC0ySbtK9JXXt8qLCqzZg== +"@next/env@14.2.5": + version "14.2.5" + resolved "https://registry.yarnpkg.com/@next/env/-/env-14.2.5.tgz#1d9328ab828711d3517d0a1d505acb55e5ef7ad0" + integrity sha512-/zZGkrTOsraVfYjGP8uM0p6r0BDT6xWpkjdVbcz66PJVSpwXX3yNiRycxAuDfBKGWBrZBXRuK/YVlkNgxHGwmA== "@next/eslint-plugin-next@12.0.3": version "12.0.3" @@ -862,50 +862,50 @@ dependencies: glob "7.1.7" -"@next/swc-darwin-arm64@13.4.1": - version "13.4.1" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.1.tgz#3748040d2dd0d89d3cdcc897f96aeda5130eed8f" - integrity sha512-eF8ARHtYfnoYtDa6xFHriUKA/Mfj/cCbmKb3NofeKhMccs65G6/loZ15a6wYCCx4rPAd6x4t1WmVYtri7EdeBg== - -"@next/swc-darwin-x64@13.4.1": - version "13.4.1" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.1.tgz#c59fc270005f17e04eb7eab4fd68793d0e3409a4" - integrity sha512-7cmDgF9tGWTgn5Gw+vP17miJbH4wcraMHDCOHTYWkO/VeKT73dUWG23TNRLfgtCNSPgH4V5B4uLHoZTanx9bAw== - -"@next/swc-linux-arm64-gnu@13.4.1": - version "13.4.1" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.1.tgz#1aef371bcef5d832d7f7e3aec3e68cfb98282393" - integrity sha512-qwJqmCri2ie8aTtE5gjTSr8S6O8B67KCYgVZhv9gKH44yvc/zXbAY8u23QGULsYOyh1islWE5sWfQNLOj9iryg== - -"@next/swc-linux-arm64-musl@13.4.1": - version "13.4.1" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.1.tgz#2522927cb0af6918405a49f5a1d1687d6847f3ec" - integrity sha512-qcC54tWNGDv/VVIFkazxhqH1Bnagjfs4enzELVRlUOoJPD2BGJTPI7z08pQPbbgxLtRiu8gl2mXvpB8WlOkMeA== - -"@next/swc-linux-x64-gnu@13.4.1": - version "13.4.1" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.1.tgz#5ec9418a35510048a5ceb79ed300463e1a9b312d" - integrity sha512-9TeWFlpLsBosZ+tsm/rWBaMwt5It9tPH8m3nawZqFUUrZyGRfGcI67js774vtx0k3rL9qbyY6+3pw9BCVpaYUA== - -"@next/swc-linux-x64-musl@13.4.1": - version "13.4.1" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.1.tgz#3478b9c89b75c1d0e7def9f35a9a77cb15d1a115" - integrity sha512-sNDGaWmSqTS4QRUzw61wl4mVPeSqNIr1OOjLlQTRuyInxMxtqImRqdvzDvFTlDfdeUMU/DZhWGYoHrXLlZXe6A== - -"@next/swc-win32-arm64-msvc@13.4.1": - version "13.4.1" - resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.1.tgz#efe53d48ff51d2485eabb910ab7caee78425fc01" - integrity sha512-+CXZC7u1iXdLRudecoUYbhbsXpglYv8KFYsFxKBPn7kg+bk7eJo738wAA4jXIl8grTF2mPdmO93JOQym+BlYGA== - -"@next/swc-win32-ia32-msvc@13.4.1": - version "13.4.1" - resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.1.tgz#952cdf1c53df46a90d5151d99310195d2c384e55" - integrity sha512-vIoXVVc7UYO68VwVMDKwJC2+HqAZQtCYiVlApyKEeIPIQpz2gpufzGxk1z3/gwrJt/kJ5CDZjlhYDCzd3hdz+g== - -"@next/swc-win32-x64-msvc@13.4.1": - version "13.4.1" - resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.1.tgz#447b7dcee5f5d4824cdff331a4ec34b13d0b449d" - integrity sha512-n8V5ImLQZibKTu10UUdI3nIeTLkliEXe628qxqW9v8My3BAH2a7H0SaCqkV2OgqFnn8sG1wxKYw9/SNJ632kSA== +"@next/swc-darwin-arm64@14.2.5": + version "14.2.5" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.5.tgz#d0a160cf78c18731c51cc0bff131c706b3e9bb05" + integrity sha512-/9zVxJ+K9lrzSGli1///ujyRfon/ZneeZ+v4ptpiPoOU+GKZnm8Wj8ELWU1Pm7GHltYRBklmXMTUqM/DqQ99FQ== + +"@next/swc-darwin-x64@14.2.5": + version "14.2.5" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.5.tgz#eb832a992407f6e6352eed05a073379f1ce0589c" + integrity sha512-vXHOPCwfDe9qLDuq7U1OYM2wUY+KQ4Ex6ozwsKxp26BlJ6XXbHleOUldenM67JRyBfVjv371oneEvYd3H2gNSA== + +"@next/swc-linux-arm64-gnu@14.2.5": + version "14.2.5" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.5.tgz#098fdab57a4664969bc905f5801ef5a89582c689" + integrity sha512-vlhB8wI+lj8q1ExFW8lbWutA4M2ZazQNvMWuEDqZcuJJc78iUnLdPPunBPX8rC4IgT6lIx/adB+Cwrl99MzNaA== + +"@next/swc-linux-arm64-musl@14.2.5": + version "14.2.5" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.5.tgz#243a1cc1087fb75481726dd289c7b219fa01f2b5" + integrity sha512-NpDB9NUR2t0hXzJJwQSGu1IAOYybsfeB+LxpGsXrRIb7QOrYmidJz3shzY8cM6+rO4Aojuef0N/PEaX18pi9OA== + +"@next/swc-linux-x64-gnu@14.2.5": + version "14.2.5" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.5.tgz#b8a2e436387ee4a52aa9719b718992e0330c4953" + integrity sha512-8XFikMSxWleYNryWIjiCX+gU201YS+erTUidKdyOVYi5qUQo/gRxv/3N1oZFCgqpesN6FPeqGM72Zve+nReVXQ== + +"@next/swc-linux-x64-musl@14.2.5": + version "14.2.5" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.5.tgz#cb8a9adad5fb8df86112cfbd363aab5c6d32757b" + integrity sha512-6QLwi7RaYiQDcRDSU/os40r5o06b5ue7Jsk5JgdRBGGp8l37RZEh9JsLSM8QF0YDsgcosSeHjglgqi25+m04IQ== + +"@next/swc-win32-arm64-msvc@14.2.5": + version "14.2.5" + resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.5.tgz#81f996c1c38ea0900d4e7719cc8814be8a835da0" + integrity sha512-1GpG2VhbspO+aYoMOQPQiqc/tG3LzmsdBH0LhnDS3JrtDx2QmzXe0B6mSZZiN3Bq7IOMXxv1nlsjzoS1+9mzZw== + +"@next/swc-win32-ia32-msvc@14.2.5": + version "14.2.5" + resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.5.tgz#f61c74ce823e10b2bc150e648fc192a7056422e0" + integrity sha512-Igh9ZlxwvCDsu6438FXlQTHlRno4gFpJzqPjSIBZooD22tKeI4fE/YMRoHVJHmrQ2P5YL1DoZ0qaOKkbeFWeMg== + +"@next/swc-win32-x64-msvc@14.2.5": + version "14.2.5" + resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.5.tgz#ed199a920efb510cfe941cd75ed38a7be21e756f" + integrity sha512-tEQ7oinq1/CjSG9uSTerca3v4AZ+dFa+4Yu6ihaG8Ud8ddqLQgFGcnwYls13H5X5CPDPZJdYxyeMui6muOLd4g== "@nodelib/fs.scandir@2.1.5": version "2.1.5" @@ -1202,11 +1202,17 @@ resolved "https://registry.yarnpkg.com/@stitches/core/-/core-1.2.8.tgz#dce3b8fdc764fbc6dbea30c83b73bfb52cf96173" integrity sha512-Gfkvwk9o9kE9r9XNBmJRfV8zONvXThnm1tcuojL04Uy5uRyqg93DC83lDebl0rocZCfKSjUv+fWYtMQmEDJldg== -"@swc/helpers@0.5.1": - version "0.5.1" - resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.5.1.tgz#e9031491aa3f26bfcc974a67f48bd456c8a5357a" - integrity sha512-sJ902EfIzn1Fa+qYmjdQqh8tPsoxyBz+8yBKC2HKUxyezKJFwPGOn7pv4WY6QuQW//ySQi5lJjA/ZT9sNWWNTg== +"@swc/counter@^0.1.3": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@swc/counter/-/counter-0.1.3.tgz#cc7463bd02949611c6329596fccd2b0ec782b0e9" + integrity sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ== + +"@swc/helpers@0.5.5": + version "0.5.5" + resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.5.5.tgz#12689df71bfc9b21c4f4ca00ae55f2f16c8b77c0" + integrity sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A== dependencies: + "@swc/counter" "^0.1.3" tslib "^2.4.0" "@types/acorn@^4.0.0": @@ -1910,10 +1916,10 @@ caniuse-lite@^1.0.30001370: resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001390.tgz#158a43011e7068ef7fc73590e9fd91a7cece5e7f" integrity sha512-sS4CaUM+/+vqQUlCvCJ2WtDlV81aWtHhqeEVkLokVJJa3ViN4zDxAGfq9R8i1m90uGHxo99cy10Od+lvn3hf0g== -caniuse-lite@^1.0.30001406: - version "1.0.30001410" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001410.tgz#b5a86366fbbf439d75dd3db1d21137a73e829f44" - integrity sha512-QoblBnuE+rG0lc3Ur9ltP5q47lbguipa/ncNMyyGuqPk44FxbScWAeEO+k5fSQ8WekdAK4mWqNs1rADDAiN5xQ== +caniuse-lite@^1.0.30001579: + version "1.0.30001649" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001649.tgz#3ec700309ca0da2b0d3d5fb03c411b191761c992" + integrity sha512-fJegqZZ0ZX8HOWr6rcafGr72+xcgJKI9oWfDW5DrD7ExUtgZC7a7R7ZYmZqplh7XDocFdGeIFn7roAxhOeYrPQ== ccount@^1.0.0: version "1.1.0" @@ -3162,6 +3168,11 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0: resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96" integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== +graceful-fs@^4.2.11: + version "4.2.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" + integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== + gray-matter@^4.0.2: version "4.0.3" resolved "https://registry.yarnpkg.com/gray-matter/-/gray-matter-4.0.3.tgz#e893c064825de73ea1f5f7d88c7a9f7274288798" @@ -4676,11 +4687,6 @@ nanoid@^3.2.0: resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== -nanoid@^3.3.4: - version "3.3.4" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab" - integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw== - nanoid@^3.3.6: version "3.3.6" resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c" @@ -4712,28 +4718,28 @@ next-tick@^1.1.0: resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb" integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ== -next@^13.4.1: - version "13.4.1" - resolved "https://registry.yarnpkg.com/next/-/next-13.4.1.tgz#8d23f94c81b3f9cc8b34165ad528457e5befd726" - integrity sha512-JBw2kAIyhKDpjhEWvNVoFeIzNp9xNxg8wrthDOtMctfn3EpqGCmW0FSviNyGgOSOSn6zDaX48pmvbdf6X2W9xA== +next@^14.2.5: + version "14.2.5" + resolved "https://registry.yarnpkg.com/next/-/next-14.2.5.tgz#afe4022bb0b752962e2205836587a289270efbea" + integrity sha512-0f8aRfBVL+mpzfBjYfQuLWh2WyAwtJXCRfkPF4UJ5qd2YwrHczsrSzXU4tRMV0OAxR8ZJZWPFn6uhSC56UTsLA== dependencies: - "@next/env" "13.4.1" - "@swc/helpers" "0.5.1" + "@next/env" "14.2.5" + "@swc/helpers" "0.5.5" busboy "1.6.0" - caniuse-lite "^1.0.30001406" - postcss "8.4.14" + caniuse-lite "^1.0.30001579" + graceful-fs "^4.2.11" + postcss "8.4.31" styled-jsx "5.1.1" - zod "3.21.4" optionalDependencies: - "@next/swc-darwin-arm64" "13.4.1" - "@next/swc-darwin-x64" "13.4.1" - "@next/swc-linux-arm64-gnu" "13.4.1" - "@next/swc-linux-arm64-musl" "13.4.1" - "@next/swc-linux-x64-gnu" "13.4.1" - "@next/swc-linux-x64-musl" "13.4.1" - "@next/swc-win32-arm64-msvc" "13.4.1" - "@next/swc-win32-ia32-msvc" "13.4.1" - "@next/swc-win32-x64-msvc" "13.4.1" + "@next/swc-darwin-arm64" "14.2.5" + "@next/swc-darwin-x64" "14.2.5" + "@next/swc-linux-arm64-gnu" "14.2.5" + "@next/swc-linux-arm64-musl" "14.2.5" + "@next/swc-linux-x64-gnu" "14.2.5" + "@next/swc-linux-x64-musl" "14.2.5" + "@next/swc-win32-arm64-msvc" "14.2.5" + "@next/swc-win32-ia32-msvc" "14.2.5" + "@next/swc-win32-x64-msvc" "14.2.5" nice-try@^1.0.4: version "1.0.5" @@ -5471,12 +5477,12 @@ postcss-values-parser@^2.0.0, postcss-values-parser@^2.0.1: indexes-of "^1.0.1" uniq "^1.0.1" -postcss@8.4.14: - version "8.4.14" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.14.tgz#ee9274d5622b4858c1007a74d76e42e56fd21caf" - integrity sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig== +postcss@8.4.31: + version "8.4.31" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.31.tgz#92b451050a9f914da6755af352bdc0192508656d" + integrity sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ== dependencies: - nanoid "^3.3.4" + nanoid "^3.3.6" picocolors "^1.0.0" source-map-js "^1.0.2" @@ -7042,11 +7048,6 @@ yaml@^2.1.1: resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.3.1.tgz#02fe0975d23cd441242aa7204e09fc28ac2ac33b" integrity sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ== -zod@3.21.4: - version "3.21.4" - resolved "https://registry.yarnpkg.com/zod/-/zod-3.21.4.tgz#10882231d992519f0a10b5dd58a38c9dabbb64db" - integrity sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw== - zwitch@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/zwitch/-/zwitch-2.0.2.tgz#91f8d0e901ffa3d66599756dde7f57b17c95dce1" From 95c73eca6f58340e911ed665b1c9b68339d3b0ff Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Tue, 6 Aug 2024 03:19:58 +0900 Subject: [PATCH 2/7] chore: add root layout --- src/app/layout.tsx | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/app/layout.tsx diff --git a/src/app/layout.tsx b/src/app/layout.tsx new file mode 100644 index 00000000000..342f2adf8ae --- /dev/null +++ b/src/app/layout.tsx @@ -0,0 +1,7 @@ +export default function RootLayout({children}: {children: React.ReactNode}) { + return ( + + {children} + + ); +} From 0e27131c81ecf0fd8ea567fd07059ab2f7b0a127 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Tue, 6 Aug 2024 11:41:15 +0900 Subject: [PATCH 3/7] move catch all to app/page --- src/app/[[...markdownPath]]/client.tsx | 98 +++++++++++++ src/app/[[...markdownPath]]/page.tsx | 97 +++++++++++++ src/pages/[[...markdownPath]].js | 183 ------------------------- src/utils/compileMDX.ts | 2 +- 4 files changed, 196 insertions(+), 184 deletions(-) create mode 100644 src/app/[[...markdownPath]]/client.tsx create mode 100644 src/app/[[...markdownPath]]/page.tsx delete mode 100644 src/pages/[[...markdownPath]].js diff --git a/src/app/[[...markdownPath]]/client.tsx b/src/app/[[...markdownPath]]/client.tsx new file mode 100644 index 00000000000..130cf83200b --- /dev/null +++ b/src/app/[[...markdownPath]]/client.tsx @@ -0,0 +1,98 @@ +'use client'; + +import {Fragment, useMemo} from 'react'; +import {useRouter} from 'next/router'; +import {Page} from 'components/Layout/Page'; +import {MDXComponents} from 'components/MDX/MDXComponents'; +import sidebarHome from '../../sidebarHome.json'; +import sidebarLearn from '../../sidebarLearn.json'; +import sidebarReference from '../../sidebarReference.json'; +import sidebarCommunity from '../../sidebarCommunity.json'; +import sidebarBlog from '../../sidebarBlog.json'; + +function useActiveSection() { + const {asPath} = useRouter(); + const cleanedPath = asPath.split(/[\?\#]/)[0]; + if (cleanedPath === '/') { + return 'home'; + } else if (cleanedPath.startsWith('/reference')) { + return 'reference'; + } else if (asPath.startsWith('/learn')) { + return 'learn'; + } else if (asPath.startsWith('/community')) { + return 'community'; + } else if (asPath.startsWith('/blog')) { + return 'blog'; + } else { + return 'unknown'; + } +} + +// Deserialize a client React tree from JSON. +function reviveNodeOnClient(key: any, val: any) { + if (Array.isArray(val) && val[0] == '$r') { + // Assume it's a React element. + let type = val[1]; + let key = val[2]; + let props = val[3]; + if (type === 'wrapper') { + type = Fragment; + props = {children: props.children}; + } + if (MDXComponents[type as keyof typeof MDXComponents]) { + type = MDXComponents[type as keyof typeof MDXComponents]; + } + if (!type) { + console.error('Unknown type: ' + type); + type = Fragment; + } + return { + $$typeof: Symbol.for('react.element'), + type: type, + key: key, + ref: null, + props: props, + _owner: null, + }; + } else { + return val; + } +} + +export function Client({content, toc, meta, languages}: any) { + const parsedContent = useMemo( + () => JSON.parse(content, reviveNodeOnClient), + [content] + ); + const parsedToc = useMemo(() => JSON.parse(toc, reviveNodeOnClient), [toc]); + const section = useActiveSection(); + let routeTree: any; + switch (section) { + case 'home': + case 'unknown': + routeTree = sidebarHome; + break; + case 'learn': + routeTree = sidebarLearn; + break; + case 'reference': + routeTree = sidebarReference; + break; + case 'community': + routeTree = sidebarCommunity; + break; + case 'blog': + routeTree = sidebarBlog; + break; + } + return ( + + {parsedContent} + + ); +} diff --git a/src/app/[[...markdownPath]]/page.tsx b/src/app/[[...markdownPath]]/page.tsx new file mode 100644 index 00000000000..fee5426fddf --- /dev/null +++ b/src/app/[[...markdownPath]]/page.tsx @@ -0,0 +1,97 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + */ + +import compileMDX from 'utils/compileMDX'; +import {generateRssFeed} from '../../utils/rss'; +import {Client} from './client'; + +export default async function Layout({ + params: {markdownPath}, +}: { + params: {markdownPath: string[]}; +}) { + const {toc, content, meta, languages} = await getData({markdownPath}); + return ( + + ); +} + +// Put MDX output into JSON for client. +export async function getData({markdownPath}: {markdownPath: string[]}) { + generateRssFeed(); + const fs = require('fs'); + const rootDir = process.cwd() + '/src/content/'; + + // Read MDX from the file. + let path = (markdownPath || []).join('/') || 'index'; + let mdx; + try { + mdx = fs.readFileSync(rootDir + path + '.md', 'utf8'); + } catch { + mdx = fs.readFileSync(rootDir + path + '/index.md', 'utf8'); + } + + const {toc, content, meta, languages} = await compileMDX(mdx, path, {}); + return { + toc, + content, + meta, + languages, + }; +} + +// Collect all MDX files for static generation. +export async function getStaticPaths() { + const {promisify} = require('util'); + const {resolve} = require('path'); + const fs = require('fs'); + const readdir = promisify(fs.readdir); + const stat = promisify(fs.stat); + const rootDir = process.cwd() + '/src/content'; + + // Find all MD files recursively. + async function getFiles(dir: string) { + const subdirs = await readdir(dir); + const files = await Promise.all( + subdirs.map(async (subdir: string) => { + const res = resolve(dir, subdir); + return (await stat(res)).isDirectory() + ? getFiles(res) + : res.slice(rootDir.length + 1); + }) + ); + return ( + files + .flat() + // ignores `errors/*.md`, they will be handled by `pages/errors/[errorCode].tsx` + .filter((file) => file.endsWith('.md') && !file.startsWith('errors/')) + ); + } + + // 'foo/bar/baz.md' -> ['foo', 'bar', 'baz'] + // 'foo/bar/qux/index.md' -> ['foo', 'bar', 'qux'] + function getSegments(file: string) { + let segments = file.slice(0, -3).replace(/\\/g, '/').split('/'); + if (segments[segments.length - 1] === 'index') { + segments.pop(); + } + return segments; + } + + const files = await getFiles(rootDir); + + const paths = files.map((file) => ({ + params: { + markdownPath: getSegments(file), + // ^^^ CAREFUL HERE. + // If you rename markdownPath, update patches/next-remote-watch.patch too. + // Otherwise you'll break Fast Refresh for all MD files. + }, + })); + + return { + paths: paths, + fallback: false, + }; +} diff --git a/src/pages/[[...markdownPath]].js b/src/pages/[[...markdownPath]].js deleted file mode 100644 index 63fcfcc8152..00000000000 --- a/src/pages/[[...markdownPath]].js +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - */ - -import {Fragment, useMemo} from 'react'; -import {useRouter} from 'next/router'; -import {Page} from 'components/Layout/Page'; -import sidebarHome from '../sidebarHome.json'; -import sidebarLearn from '../sidebarLearn.json'; -import sidebarReference from '../sidebarReference.json'; -import sidebarCommunity from '../sidebarCommunity.json'; -import sidebarBlog from '../sidebarBlog.json'; -import {MDXComponents} from 'components/MDX/MDXComponents'; -import compileMDX from 'utils/compileMDX'; -import {generateRssFeed} from '../utils/rss'; - -export default function Layout({content, toc, meta, languages}) { - const parsedContent = useMemo( - () => JSON.parse(content, reviveNodeOnClient), - [content] - ); - const parsedToc = useMemo(() => JSON.parse(toc, reviveNodeOnClient), [toc]); - const section = useActiveSection(); - let routeTree; - switch (section) { - case 'home': - case 'unknown': - routeTree = sidebarHome; - break; - case 'learn': - routeTree = sidebarLearn; - break; - case 'reference': - routeTree = sidebarReference; - break; - case 'community': - routeTree = sidebarCommunity; - break; - case 'blog': - routeTree = sidebarBlog; - break; - } - return ( - - {parsedContent} - - ); -} - -function useActiveSection() { - const {asPath} = useRouter(); - const cleanedPath = asPath.split(/[\?\#]/)[0]; - if (cleanedPath === '/') { - return 'home'; - } else if (cleanedPath.startsWith('/reference')) { - return 'reference'; - } else if (asPath.startsWith('/learn')) { - return 'learn'; - } else if (asPath.startsWith('/community')) { - return 'community'; - } else if (asPath.startsWith('/blog')) { - return 'blog'; - } else { - return 'unknown'; - } -} - -// Deserialize a client React tree from JSON. -function reviveNodeOnClient(key, val) { - if (Array.isArray(val) && val[0] == '$r') { - // Assume it's a React element. - let type = val[1]; - let key = val[2]; - let props = val[3]; - if (type === 'wrapper') { - type = Fragment; - props = {children: props.children}; - } - if (MDXComponents[type]) { - type = MDXComponents[type]; - } - if (!type) { - console.error('Unknown type: ' + type); - type = Fragment; - } - return { - $$typeof: Symbol.for('react.element'), - type: type, - key: key, - ref: null, - props: props, - _owner: null, - }; - } else { - return val; - } -} - -// Put MDX output into JSON for client. -export async function getStaticProps(context) { - generateRssFeed(); - const fs = require('fs'); - const rootDir = process.cwd() + '/src/content/'; - - // Read MDX from the file. - let path = (context.params.markdownPath || []).join('/') || 'index'; - let mdx; - try { - mdx = fs.readFileSync(rootDir + path + '.md', 'utf8'); - } catch { - mdx = fs.readFileSync(rootDir + path + '/index.md', 'utf8'); - } - - const {toc, content, meta, languages} = await compileMDX(mdx, path, {}); - return { - props: { - toc, - content, - meta, - languages, - }, - }; -} - -// Collect all MDX files for static generation. -export async function getStaticPaths() { - const {promisify} = require('util'); - const {resolve} = require('path'); - const fs = require('fs'); - const readdir = promisify(fs.readdir); - const stat = promisify(fs.stat); - const rootDir = process.cwd() + '/src/content'; - - // Find all MD files recursively. - async function getFiles(dir) { - const subdirs = await readdir(dir); - const files = await Promise.all( - subdirs.map(async (subdir) => { - const res = resolve(dir, subdir); - return (await stat(res)).isDirectory() - ? getFiles(res) - : res.slice(rootDir.length + 1); - }) - ); - return ( - files - .flat() - // ignores `errors/*.md`, they will be handled by `pages/errors/[errorCode].tsx` - .filter((file) => file.endsWith('.md') && !file.startsWith('errors/')) - ); - } - - // 'foo/bar/baz.md' -> ['foo', 'bar', 'baz'] - // 'foo/bar/qux/index.md' -> ['foo', 'bar', 'qux'] - function getSegments(file) { - let segments = file.slice(0, -3).replace(/\\/g, '/').split('/'); - if (segments[segments.length - 1] === 'index') { - segments.pop(); - } - return segments; - } - - const files = await getFiles(rootDir); - - const paths = files.map((file) => ({ - params: { - markdownPath: getSegments(file), - // ^^^ CAREFUL HERE. - // If you rename markdownPath, update patches/next-remote-watch.patch too. - // Otherwise you'll break Fast Refresh for all MD files. - }, - })); - - return { - paths: paths, - fallback: false, - }; -} diff --git a/src/utils/compileMDX.ts b/src/utils/compileMDX.ts index 4c5ee15b72a..b402603c3a9 100644 --- a/src/utils/compileMDX.ts +++ b/src/utils/compileMDX.ts @@ -10,7 +10,7 @@ export default async function compileMDX( mdx: string, path: string | string[], params: {[key: string]: any} -): Promise<{content: string; toc: string; meta: any}> { +): Promise<{content: string; toc: string; meta: any; languages: any}> { const fs = require('fs'); const { prepareMDX, From a0bc41e3ee9f3244743cd1d4b37f2d754bb21914 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Wed, 7 Aug 2024 03:47:33 +0900 Subject: [PATCH 4/7] add use client --- src/components/MDX/Challenges/Challenges.tsx | 1 + src/components/MDX/ErrorDecoder.tsx | 1 + src/components/MDX/ExpandableExample.tsx | 1 + src/components/MDX/LanguagesContext.tsx | 1 + src/components/MDX/MDXComponents.tsx | 1 + src/components/MDX/Sandpack/CustomPreset.tsx | 1 + src/components/MDX/TerminalBlock.tsx | 1 + src/components/MDX/TocContext.tsx | 1 + 8 files changed, 8 insertions(+) diff --git a/src/components/MDX/Challenges/Challenges.tsx b/src/components/MDX/Challenges/Challenges.tsx index 661269f0ede..633dc76652f 100644 --- a/src/components/MDX/Challenges/Challenges.tsx +++ b/src/components/MDX/Challenges/Challenges.tsx @@ -1,3 +1,4 @@ +'use client'; /* * Copyright (c) Facebook, Inc. and its affiliates. */ diff --git a/src/components/MDX/ErrorDecoder.tsx b/src/components/MDX/ErrorDecoder.tsx index 198aa939d7b..4faedbd592c 100644 --- a/src/components/MDX/ErrorDecoder.tsx +++ b/src/components/MDX/ErrorDecoder.tsx @@ -1,3 +1,4 @@ +'use client'; import {useEffect, useState} from 'react'; import {useErrorDecoderParams} from '../ErrorDecoderContext'; import cn from 'classnames'; diff --git a/src/components/MDX/ExpandableExample.tsx b/src/components/MDX/ExpandableExample.tsx index 1e709e4839c..d73bcefb65a 100644 --- a/src/components/MDX/ExpandableExample.tsx +++ b/src/components/MDX/ExpandableExample.tsx @@ -1,3 +1,4 @@ +'use client'; /* * Copyright (c) Facebook, Inc. and its affiliates. */ diff --git a/src/components/MDX/LanguagesContext.tsx b/src/components/MDX/LanguagesContext.tsx index 776a11c0d95..b4486e7b022 100644 --- a/src/components/MDX/LanguagesContext.tsx +++ b/src/components/MDX/LanguagesContext.tsx @@ -1,3 +1,4 @@ +'use client'; /* * Copyright (c) Facebook, Inc. and its affiliates. */ diff --git a/src/components/MDX/MDXComponents.tsx b/src/components/MDX/MDXComponents.tsx index 6f99121f7f8..ebaa06f6777 100644 --- a/src/components/MDX/MDXComponents.tsx +++ b/src/components/MDX/MDXComponents.tsx @@ -1,3 +1,4 @@ +'use client'; /* * Copyright (c) Facebook, Inc. and its affiliates. */ diff --git a/src/components/MDX/Sandpack/CustomPreset.tsx b/src/components/MDX/Sandpack/CustomPreset.tsx index c133e2a8304..279d7788126 100644 --- a/src/components/MDX/Sandpack/CustomPreset.tsx +++ b/src/components/MDX/Sandpack/CustomPreset.tsx @@ -1,3 +1,4 @@ +'use client'; /* * Copyright (c) Facebook, Inc. and its affiliates. */ diff --git a/src/components/MDX/TerminalBlock.tsx b/src/components/MDX/TerminalBlock.tsx index fc13af33891..1294d2322b0 100644 --- a/src/components/MDX/TerminalBlock.tsx +++ b/src/components/MDX/TerminalBlock.tsx @@ -1,3 +1,4 @@ +'use client'; /* * Copyright (c) Facebook, Inc. and its affiliates. */ diff --git a/src/components/MDX/TocContext.tsx b/src/components/MDX/TocContext.tsx index 8aeead370e9..7743d2155bd 100644 --- a/src/components/MDX/TocContext.tsx +++ b/src/components/MDX/TocContext.tsx @@ -1,3 +1,4 @@ +'use client'; /* * Copyright (c) Facebook, Inc. and its affiliates. */ From a234251a02c3cc3575083793a53159e45957c713 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Sun, 11 Aug 2024 13:40:38 +0900 Subject: [PATCH 5/7] remove unsupported experimental next config --- next.config.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/next.config.js b/next.config.js index 61ff1944a6c..302705d11dc 100644 --- a/next.config.js +++ b/next.config.js @@ -9,10 +9,7 @@ const nextConfig = { pageExtensions: ['jsx', 'js', 'ts', 'tsx', 'mdx', 'md'], reactStrictMode: true, experimental: { - // TODO: Remove after https://github.com/vercel/next.js/issues/49355 is fixed - appDir: false, scrollRestoration: true, - legacyBrowsers: false, }, env: {}, webpack: (config, {dev, isServer, ...options}) => { From 16a5b8398ea4a7884b5e360b779da194eb170f3e Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Mon, 12 Aug 2024 03:59:52 +0900 Subject: [PATCH 6/7] cleanedPath to usePathname --- src/app/[[...markdownPath]]/client.tsx | 15 +++++++-------- src/components/Layout/Feedback.tsx | 7 +++---- .../Layout/Sidebar/SidebarRouteTree.tsx | 6 +++--- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/app/[[...markdownPath]]/client.tsx b/src/app/[[...markdownPath]]/client.tsx index 130cf83200b..0c7ddda07cd 100644 --- a/src/app/[[...markdownPath]]/client.tsx +++ b/src/app/[[...markdownPath]]/client.tsx @@ -1,7 +1,7 @@ 'use client'; import {Fragment, useMemo} from 'react'; -import {useRouter} from 'next/router'; +import {usePathname} from 'next/navigation'; import {Page} from 'components/Layout/Page'; import {MDXComponents} from 'components/MDX/MDXComponents'; import sidebarHome from '../../sidebarHome.json'; @@ -11,17 +11,16 @@ import sidebarCommunity from '../../sidebarCommunity.json'; import sidebarBlog from '../../sidebarBlog.json'; function useActiveSection() { - const {asPath} = useRouter(); - const cleanedPath = asPath.split(/[\?\#]/)[0]; - if (cleanedPath === '/') { + const pathname = usePathname() ?? '/'; + if (pathname === '/') { return 'home'; - } else if (cleanedPath.startsWith('/reference')) { + } else if (pathname.startsWith('/reference')) { return 'reference'; - } else if (asPath.startsWith('/learn')) { + } else if (pathname.startsWith('/learn')) { return 'learn'; - } else if (asPath.startsWith('/community')) { + } else if (pathname.startsWith('/community')) { return 'community'; - } else if (asPath.startsWith('/blog')) { + } else if (pathname.startsWith('/blog')) { return 'blog'; } else { return 'unknown'; diff --git a/src/components/Layout/Feedback.tsx b/src/components/Layout/Feedback.tsx index 34db728ced2..215881d019f 100644 --- a/src/components/Layout/Feedback.tsx +++ b/src/components/Layout/Feedback.tsx @@ -3,14 +3,13 @@ */ import {useState} from 'react'; -import {useRouter} from 'next/router'; +import {usePathname} from 'next/navigation'; import cn from 'classnames'; export function Feedback({onSubmit = () => {}}: {onSubmit?: () => void}) { - const {asPath} = useRouter(); - const cleanedPath = asPath.split(/[\?\#]/)[0]; + const pathname = usePathname() ?? '/'; // Reset on route changes. - return ; + return ; } const thumbsUpIcon = ( diff --git a/src/components/Layout/Sidebar/SidebarRouteTree.tsx b/src/components/Layout/Sidebar/SidebarRouteTree.tsx index 3f058073cbe..2c4be262962 100644 --- a/src/components/Layout/Sidebar/SidebarRouteTree.tsx +++ b/src/components/Layout/Sidebar/SidebarRouteTree.tsx @@ -5,7 +5,7 @@ import {useRef, useLayoutEffect, Fragment} from 'react'; import cn from 'classnames'; -import {useRouter} from 'next/router'; +import {usePathname} from 'next/navigation'; import {SidebarLink} from './SidebarLink'; import {useCollapse} from 'react-collapsed'; import usePendingRoute from 'hooks/usePendingRoute'; @@ -76,7 +76,7 @@ export function SidebarRouteTree({ routeTree, level = 0, }: SidebarRouteTreeProps) { - const slug = useRouter().asPath.split(/[\?\#]/)[0]; + const pathname = usePathname() ?? '/'; const pendingRoute = usePendingRoute(); const currentRoutes = routeTree.routes as RouteItem[]; return ( @@ -94,7 +94,7 @@ export function SidebarRouteTree({ }, index ) => { - const selected = slug === path; + const selected = pathname === path; let listItem = null; if (!path || heading) { // if current route item has no path and children treat it as an API sidebar heading From 9fad26ffed2dd61943145f94c10a01d926411b5d Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Mon, 12 Aug 2024 04:00:28 +0900 Subject: [PATCH 7/7] require plugins --- src/utils/compileMDX.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/compileMDX.ts b/src/utils/compileMDX.ts index b402603c3a9..944f2e4f86a 100644 --- a/src/utils/compileMDX.ts +++ b/src/utils/compileMDX.ts @@ -90,8 +90,8 @@ export default async function compileMDX( }); const {transform} = require('@babel/core'); const jsCode = await transform(jsxCode, { - plugins: ['@babel/plugin-transform-modules-commonjs'], - presets: ['@babel/preset-react'], + plugins: [require('@babel/plugin-transform-modules-commonjs')], + presets: [require('@babel/preset-react')], }).code; // Prepare environment for MDX.