From 9c2949a95021d95f8a661b0c4529c01ab64a2111 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Fri, 18 Mar 2022 02:44:56 -0700 Subject: [PATCH 1/4] fix(document): accepts nodearray for head's children (#35424) This PR attempts to amends #35390. There's new property 'children' in `OriginProps` : https://github.com/vercel/next.js/blob/canary/packages/next/pages/_document.tsx#L22 which overwrites default prop's children defined at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L504. Those 2 are incompatible, especially new one doesn't allow iterable children which results multiple children in head tag makes compilation fails. PR matches type of new property same as default, then apply some workaround to bend over internal check logics. I'm not sure if it's worth to apply strict types as much or just bend it via `any` casting, PR tried to be strict as much. ## Bug - closes https://github.com/vercel/next.js/issues/35390 - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint` --- packages/next/pages/_document.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/next/pages/_document.tsx b/packages/next/pages/_document.tsx index adc58bf357df..57a5f4a24af3 100644 --- a/packages/next/pages/_document.tsx +++ b/packages/next/pages/_document.tsx @@ -19,7 +19,7 @@ export { DocumentContext, DocumentInitialProps, DocumentProps } export type OriginProps = { nonce?: string crossOrigin?: string - children?: React.ReactElement + children?: React.ReactNode } type DocumentFiles = { @@ -72,6 +72,10 @@ function getPolyfillScripts(context: HtmlProps, props: OriginProps) { )) } +function hasComponentProps(child: any): child is React.ReactElement { + return !!child && !!child.props +} + function getPreNextWorkerScripts(context: HtmlProps, props: OriginProps) { const { assetPrefix, scriptLoader, crossOrigin, nextScriptWorkers } = context @@ -88,7 +92,8 @@ function getPreNextWorkerScripts(context: HtmlProps, props: OriginProps) { // Check to see if the user has defined their own Partytown configuration const userDefinedConfig = children.find( - (child: React.ReactElement) => + (child) => + hasComponentProps(child) && child?.props?.dangerouslySetInnerHTML?.__html.length && 'data-partytown-config' in child.props ) From 910c48f52b75cd0a6f6e1d219be1cd1a92dbf8f6 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Fri, 18 Mar 2022 11:19:55 +0100 Subject: [PATCH 2/4] test: add document head multi child prod test (#35426) Add production test for #35424 --- .../typescript-basic/app/pages/_document.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/production/typescript-basic/app/pages/_document.tsx diff --git a/test/production/typescript-basic/app/pages/_document.tsx b/test/production/typescript-basic/app/pages/_document.tsx new file mode 100644 index 000000000000..6916edcdf807 --- /dev/null +++ b/test/production/typescript-basic/app/pages/_document.tsx @@ -0,0 +1,16 @@ +import { Html, Head, Main, NextScript } from 'next/document' + +export default function Document() { + return ( + + + + + + +
+ + + + ) +} From 084e00016fd1080814c2244937adada30ae20edf Mon Sep 17 00:00:00 2001 From: Thibaut SABOT <9283289+thibautsabot@users.noreply.github.com> Date: Fri, 18 Mar 2022 11:20:20 +0100 Subject: [PATCH 3/4] use initial state for rootReducer in with-redux-saga example (#35406) --- examples/with-redux-saga/reducer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/with-redux-saga/reducer.js b/examples/with-redux-saga/reducer.js index 99f3fb2fff1f..bf6f733bd230 100644 --- a/examples/with-redux-saga/reducer.js +++ b/examples/with-redux-saga/reducer.js @@ -9,7 +9,7 @@ const initialState = { placeholderData: null, } -function reducer(state, action) { +function reducer(state = initialState, action) { switch (action.type) { case HYDRATE: { return { ...state, ...action.payload } From f62766f3641c62043ceaa7cdb60c23af9d550f3c Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Fri, 18 Mar 2022 11:25:16 +0100 Subject: [PATCH 4/4] v12.1.1-canary.15 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/eslint-config-next/package.json | 4 ++-- packages/eslint-plugin-next/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-codemod/package.json | 2 +- packages/next-env/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next-plugin-storybook/package.json | 2 +- packages/next-polyfill-module/package.json | 2 +- packages/next-polyfill-nomodule/package.json | 2 +- packages/next-swc/package.json | 2 +- packages/next/package.json | 14 +++++++------- packages/react-dev-overlay/package.json | 2 +- packages/react-refresh-utils/package.json | 2 +- 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lerna.json b/lerna.json index 5e8cd0b1971d..888c8ad79047 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "12.1.1-canary.14" + "version": "12.1.1-canary.15" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index d0e4f0d7d2a6..3292de58f087 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "12.1.1-canary.14", + "version": "12.1.1-canary.15", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index 5b3017880013..c08eec859989 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "12.1.1-canary.14", + "version": "12.1.1-canary.15", "description": "ESLint configuration used by NextJS.", "main": "index.js", "license": "MIT", @@ -9,7 +9,7 @@ "directory": "packages/eslint-config-next" }, "dependencies": { - "@next/eslint-plugin-next": "12.1.1-canary.14", + "@next/eslint-plugin-next": "12.1.1-canary.15", "@rushstack/eslint-patch": "1.0.8", "@typescript-eslint/parser": "5.10.1", "eslint-import-resolver-node": "0.3.4", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 690f94fef416..9f005b2cab54 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "12.1.1-canary.14", + "version": "12.1.1-canary.15", "description": "ESLint plugin for NextJS.", "main": "lib/index.js", "license": "MIT", diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index a9a59a5c1067..bcd5b9dd96b0 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "12.1.1-canary.14", + "version": "12.1.1-canary.15", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index e3565e5c5371..bd43d0da1b8c 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "12.1.1-canary.14", + "version": "12.1.1-canary.15", "license": "MIT", "dependencies": { "chalk": "4.1.0", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 3047335bfe99..7168ad6cbd21 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "12.1.1-canary.14", + "version": "12.1.1-canary.15", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index 1e157d63d80d..e4feca6513e1 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "12.1.1-canary.14", + "version": "12.1.1-canary.15", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 66f42c4541a2..11f9b2204826 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "12.1.1-canary.14", + "version": "12.1.1-canary.15", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index 01186936731e..f8ea6913c6bb 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "12.1.1-canary.14", + "version": "12.1.1-canary.15", "description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)", "main": "dist/polyfill-module.js", "license": "MIT", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index 07ce96320c47..05c9da6d4b0b 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "12.1.1-canary.14", + "version": "12.1.1-canary.15", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index 4e36d27fbd4c..fa54399ed19e 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "12.1.1-canary.14", + "version": "12.1.1-canary.15", "private": true, "scripts": { "build-native": "napi build --platform --cargo-name next_swc_napi native", diff --git a/packages/next/package.json b/packages/next/package.json index 91ce61279a02..e4e72d4c296a 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "12.1.1-canary.14", + "version": "12.1.1-canary.15", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -69,7 +69,7 @@ ] }, "dependencies": { - "@next/env": "12.1.1-canary.14", + "@next/env": "12.1.1-canary.15", "caniuse-lite": "^1.0.30001283", "postcss": "8.4.5", "styled-jsx": "5.0.1", @@ -118,11 +118,11 @@ "@hapi/accept": "5.0.2", "@napi-rs/cli": "2.4.4", "@napi-rs/triples": "1.1.0", - "@next/polyfill-module": "12.1.1-canary.14", - "@next/polyfill-nomodule": "12.1.1-canary.14", - "@next/react-dev-overlay": "12.1.1-canary.14", - "@next/react-refresh-utils": "12.1.1-canary.14", - "@next/swc": "12.1.1-canary.14", + "@next/polyfill-module": "12.1.1-canary.15", + "@next/polyfill-nomodule": "12.1.1-canary.15", + "@next/react-dev-overlay": "12.1.1-canary.15", + "@next/react-refresh-utils": "12.1.1-canary.15", + "@next/swc": "12.1.1-canary.15", "@peculiar/webcrypto": "1.3.1", "@taskr/clear": "1.1.0", "@taskr/esnext": "1.1.0", diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index 19af781d08e3..8fb6398b7134 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-dev-overlay", - "version": "12.1.1-canary.14", + "version": "12.1.1-canary.15", "description": "A development-only overlay for developing React applications.", "repository": { "url": "vercel/next.js", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index 5ce3467fc42e..db3894ececfb 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "12.1.1-canary.14", + "version": "12.1.1-canary.15", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js",