From 78b17351fb9265dc80329d3e331022f6ebc7d0ff Mon Sep 17 00:00:00 2001 From: Ikko Ashimine Date: Tue, 18 May 2021 19:26:22 +0900 Subject: [PATCH 1/4] Fix typo in dev-build-watcher.js (#25196) transtion -> transition --- packages/next/client/dev/dev-build-watcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/client/dev/dev-build-watcher.js b/packages/next/client/dev/dev-build-watcher.js index 75e5f68cb423b..589550d877174 100644 --- a/packages/next/client/dev/dev-build-watcher.js +++ b/packages/next/client/dev/dev-build-watcher.js @@ -66,7 +66,7 @@ export default function initializeBuildWatcher(toggleCallback) { case 'built': case 'sync': isBuilding = false - // Wait for the fade out transtion to complete + // Wait for the fade out transition to complete timeoutId = setTimeout(() => { isVisible = false updateContainer() From ac7c8f3585e10be7a24c71516b38adbab61eb8bc Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 18 May 2021 14:24:22 -0500 Subject: [PATCH 2/4] Ensure default params are detected after rewrite (#25205) * Ensure default params are detected after rewrite * Add test case * bump --- .../loaders/next-serverless-loader/utils.ts | 16 ++++++++-------- .../required-server-files/test/index.test.js | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/packages/next/build/webpack/loaders/next-serverless-loader/utils.ts b/packages/next/build/webpack/loaders/next-serverless-loader/utils.ts index 2619b5a4f1142..b8f7fdb4f14ad 100644 --- a/packages/next/build/webpack/loaders/next-serverless-loader/utils.ts +++ b/packages/next/build/webpack/loaders/next-serverless-loader/utils.ts @@ -280,7 +280,7 @@ export function getUtils({ function normalizeDynamicRouteParams(params: ParsedUrlQuery) { let hasValidParams = true - if (!defaultRouteRegex) return { params, hasValidParams } + if (!defaultRouteRegex) return { params, hasValidParams: false } params = Object.keys(defaultRouteRegex.groups).reduce((prev, key) => { let value: string | string[] | undefined = params[key] @@ -288,15 +288,15 @@ export function getUtils({ // if the value matches the default value we can't rely // on the parsed params, this is used to signal if we need // to parse x-now-route-matches or not - const isDefaultValue = Array.isArray(value) - ? value.some((val) => { - const defaultValue = defaultRouteMatches![key] + const defaultValue = defaultRouteMatches![key] - return Array.isArray(defaultValue) - ? defaultValue.includes(val) - : defaultValue === val + const isDefaultValue = Array.isArray(defaultValue) + ? defaultValue.some((defaultVal) => { + return Array.isArray(value) + ? value.some((val) => val.includes(defaultVal)) + : value?.includes(defaultVal) }) - : value === defaultRouteMatches![key] + : value?.includes(defaultValue as string) if (isDefaultValue || typeof value === 'undefined') { hasValidParams = false diff --git a/test/integration/required-server-files/test/index.test.js b/test/integration/required-server-files/test/index.test.js index 72ba6a93fae0c..2c3d59d365019 100644 --- a/test/integration/required-server-files/test/index.test.js +++ b/test/integration/required-server-files/test/index.test.js @@ -216,6 +216,20 @@ describe('Required Server Files', () => { expect($2('#slug').text()).toBe('second') expect(isNaN(data2.random)).toBe(false) expect(data2.random).not.toBe(data.random) + + const html3 = await renderViaHTTP(appPort, '/some-other-path', undefined, { + headers: { + 'x-matched-path': '/dynamic/[slug]?slug=%5Bslug%5D.json', + 'x-now-route-matches': '1=second&slug=second', + }, + }) + const $3 = cheerio.load(html3) + const data3 = JSON.parse($3('#props').text()) + + expect($3('#dynamic').text()).toBe('dynamic page') + expect($3('#slug').text()).toBe('second') + expect(isNaN(data3.random)).toBe(false) + expect(data3.random).not.toBe(data.random) }) it('should render fallback page correctly with x-matched-path and routes-matches', async () => { From fa5d41b34695b6774d2574b4a451c7ae6a6698b4 Mon Sep 17 00:00:00 2001 From: Jamie <5964236+jamsinclair@users.noreply.github.com> Date: Wed, 19 May 2021 05:18:57 +0900 Subject: [PATCH 3/4] fix: replace usage of `fromEntries` in browser bundled `resolve-rewrites.ts` (#25208) ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added Fixes #25207 Currently rewritten routes that use a `has` condition throw an `Object.fromEntries is not a function` error in older browsers. ## Documentation / Examples - [x] Make sure the linting passes ## Solution As mentioned in issue #25207, looks like last year the team decided not to include the `fromEntries` polyfill https://github.com/vercel/next.js/pull/15772#discussion_r463957221. As such, we should avoid using non-polyfilled methods in core next.js code bundled in the browser. This PR's changes should result in the same object being returned, without using `fromEntries`. --- .../next-server/lib/router/utils/resolve-rewrites.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/next/next-server/lib/router/utils/resolve-rewrites.ts b/packages/next/next-server/lib/router/utils/resolve-rewrites.ts index 647055525ad48..c2bef108c98d1 100644 --- a/packages/next/next-server/lib/router/utils/resolve-rewrites.ts +++ b/packages/next/next-server/lib/router/utils/resolve-rewrites.ts @@ -43,12 +43,13 @@ export default function resolveRewrites( headers: { host: document.location.hostname, }, - cookies: Object.fromEntries( - document.cookie.split('; ').map((item) => { + cookies: document.cookie + .split('; ') + .reduce>((acc, item) => { const [key, ...value] = item.split('=') - return [key, value.join('=')] - }) - ), + acc[key] = value.join('=') + return acc + }, {}), } as any, rewrite.has, parsedAs.query From 5f30df2f061b4aad8199ea019990f4a1450acc75 Mon Sep 17 00:00:00 2001 From: Ananta Bastola Date: Wed, 19 May 2021 02:55:01 +0545 Subject: [PATCH 4/4] docs(readme.md): add good first issue section to readme (#25085) Co-authored-by: JJ Kasper --- packages/next/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/next/README.md b/packages/next/README.md index 2296f8df4ffce..c91a22e8393da 100644 --- a/packages/next/README.md +++ b/packages/next/README.md @@ -44,6 +44,10 @@ Our [Code of Conduct](https://github.com/vercel/next.js/blob/canary/CODE_OF_COND Please see our [contributing.md](/contributing.md). +### Good First Issues + +We have a list of [good first issues](https://github.com/vercel/next.js/labels/good%20first%20issue) that contain bugs which have a relatively limited scope. This is a great place to get started, gain experience, and get familiar with our contribution process. + ## Authors - Tim Neutkens ([@timneutkens](https://twitter.com/timneutkens)) – [Vercel](https://vercel.com/about/timneutkens)