From d1a4caa0fa5941eac53bf3d10f178654291889d2 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Sat, 22 Oct 2022 14:06:41 -0700 Subject: [PATCH] Update react-is for module reference detection --- .../react-is/cjs/react-is.development.js | 97 +++++++++---------- .../react-is/cjs/react-is.production.min.js | 14 +-- packages/next/compiled/react-is/package.json | 5 +- .../react-is/umd/react-is.development.js | 97 +++++++++---------- .../react-is/umd/react-is.production.min.js | 13 +-- packages/next/package.json | 2 +- packages/next/server/app-render.tsx | 14 ++- pnpm-lock.yaml | 11 ++- 8 files changed, 128 insertions(+), 125 deletions(-) diff --git a/packages/next/compiled/react-is/cjs/react-is.development.js b/packages/next/compiled/react-is/cjs/react-is.development.js index b2e388eb12403..6ed9c03dad95b 100644 --- a/packages/next/compiled/react-is/cjs/react-is.development.js +++ b/packages/next/compiled/react-is/cjs/react-is.development.js @@ -1,4 +1,5 @@ -/** @license React v17.0.2 +/** + * @license React * react-is.development.js * * Copyright (c) Facebook, Inc. and its affiliates. @@ -16,56 +17,39 @@ if (process.env.NODE_ENV !== "production") { // ATTENTION // When adding new symbols to this file, // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' -// The Symbol used to tag the ReactElement-like types. If there is no native Symbol -// nor polyfill, then a plain number is used for performance. -var REACT_ELEMENT_TYPE = 0xeac7; -var REACT_PORTAL_TYPE = 0xeaca; -var REACT_FRAGMENT_TYPE = 0xeacb; -var REACT_STRICT_MODE_TYPE = 0xeacc; -var REACT_PROFILER_TYPE = 0xead2; -var REACT_PROVIDER_TYPE = 0xeacd; -var REACT_CONTEXT_TYPE = 0xeace; -var REACT_FORWARD_REF_TYPE = 0xead0; -var REACT_SUSPENSE_TYPE = 0xead1; -var REACT_SUSPENSE_LIST_TYPE = 0xead8; -var REACT_MEMO_TYPE = 0xead3; -var REACT_LAZY_TYPE = 0xead4; -var REACT_BLOCK_TYPE = 0xead9; -var REACT_SERVER_BLOCK_TYPE = 0xeada; -var REACT_FUNDAMENTAL_TYPE = 0xead5; -var REACT_SCOPE_TYPE = 0xead7; -var REACT_OPAQUE_ID_TYPE = 0xeae0; -var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; -var REACT_OFFSCREEN_TYPE = 0xeae2; -var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; - -if (typeof Symbol === 'function' && Symbol.for) { - var symbolFor = Symbol.for; - REACT_ELEMENT_TYPE = symbolFor('react.element'); - REACT_PORTAL_TYPE = symbolFor('react.portal'); - REACT_FRAGMENT_TYPE = symbolFor('react.fragment'); - REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode'); - REACT_PROFILER_TYPE = symbolFor('react.profiler'); - REACT_PROVIDER_TYPE = symbolFor('react.provider'); - REACT_CONTEXT_TYPE = symbolFor('react.context'); - REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref'); - REACT_SUSPENSE_TYPE = symbolFor('react.suspense'); - REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'); - REACT_MEMO_TYPE = symbolFor('react.memo'); - REACT_LAZY_TYPE = symbolFor('react.lazy'); - REACT_BLOCK_TYPE = symbolFor('react.block'); - REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block'); - REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental'); - REACT_SCOPE_TYPE = symbolFor('react.scope'); - REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'); - REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'); - REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen'); - REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); -} - -// Filter certain DOM attributes (e.g. src, href) if their values are empty strings. +// The Symbol used to tag the ReactElement-like types. +var REACT_ELEMENT_TYPE = Symbol.for('react.element'); +var REACT_PORTAL_TYPE = Symbol.for('react.portal'); +var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment'); +var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode'); +var REACT_PROFILER_TYPE = Symbol.for('react.profiler'); +var REACT_PROVIDER_TYPE = Symbol.for('react.provider'); +var REACT_CONTEXT_TYPE = Symbol.for('react.context'); +var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context'); +var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref'); +var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense'); +var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list'); +var REACT_MEMO_TYPE = Symbol.for('react.memo'); +var REACT_LAZY_TYPE = Symbol.for('react.lazy'); +var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen'); + +// ----------------------------------------------------------------------------- var enableScopeAPI = false; // Experimental Create Event Handle API. +var enableCacheElement = false; +var enableTransitionTracing = false; // No known bugs, but needs performance testing + +var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber +// stuff. Intended to enable React core members to more easily debug scheduling +// issues in DEV builds. + +var enableDebugTracing = false; // Track which Fiber(s) schedule render work. + +var REACT_MODULE_REFERENCE; + +{ + REACT_MODULE_REFERENCE = Symbol.for('react.module.reference'); +} function isValidElementType(type) { if (typeof type === 'string' || typeof type === 'function') { @@ -73,12 +57,16 @@ function isValidElementType(type) { } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). - if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) { + if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) { return true; } if (typeof type === 'object' && type !== null) { - if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) { + if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object + // types supported by any Flight configuration anywhere since + // we don't know which Flight build this will end up being used + // with. + type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) { return true; } } @@ -106,6 +94,7 @@ function typeOf(object) { var $$typeofType = type && type.$$typeof; switch ($$typeofType) { + case REACT_SERVER_CONTEXT_TYPE: case REACT_CONTEXT_TYPE: case REACT_FORWARD_REF_TYPE: case REACT_LAZY_TYPE: @@ -137,6 +126,7 @@ var Portal = REACT_PORTAL_TYPE; var Profiler = REACT_PROFILER_TYPE; var StrictMode = REACT_STRICT_MODE_TYPE; var Suspense = REACT_SUSPENSE_TYPE; +var SuspenseList = REACT_SUSPENSE_LIST_TYPE; var hasWarnedAboutDeprecatedIsAsyncMode = false; var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated @@ -195,6 +185,9 @@ function isStrictMode(object) { function isSuspense(object) { return typeOf(object) === REACT_SUSPENSE_TYPE; } +function isSuspenseList(object) { + return typeOf(object) === REACT_SUSPENSE_LIST_TYPE; +} exports.ContextConsumer = ContextConsumer; exports.ContextProvider = ContextProvider; @@ -207,6 +200,7 @@ exports.Portal = Portal; exports.Profiler = Profiler; exports.StrictMode = StrictMode; exports.Suspense = Suspense; +exports.SuspenseList = SuspenseList; exports.isAsyncMode = isAsyncMode; exports.isConcurrentMode = isConcurrentMode; exports.isContextConsumer = isContextConsumer; @@ -220,6 +214,7 @@ exports.isPortal = isPortal; exports.isProfiler = isProfiler; exports.isStrictMode = isStrictMode; exports.isSuspense = isSuspense; +exports.isSuspenseList = isSuspenseList; exports.isValidElementType = isValidElementType; exports.typeOf = typeOf; })(); diff --git a/packages/next/compiled/react-is/cjs/react-is.production.min.js b/packages/next/compiled/react-is/cjs/react-is.production.min.js index b416090425d66..f2322cbb2f1f0 100644 --- a/packages/next/compiled/react-is/cjs/react-is.production.min.js +++ b/packages/next/compiled/react-is/cjs/react-is.production.min.js @@ -1,4 +1,5 @@ -/** @license React v17.0.2 +/** + * @license React * react-is.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. @@ -6,9 +7,8 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -'use strict';var b=60103,c=60106,d=60107,e=60108,f=60114,g=60109,h=60110,k=60112,l=60113,m=60120,n=60115,p=60116,q=60121,r=60122,u=60117,v=60129,w=60131; -if("function"===typeof Symbol&&Symbol.for){var x=Symbol.for;b=x("react.element");c=x("react.portal");d=x("react.fragment");e=x("react.strict_mode");f=x("react.profiler");g=x("react.provider");h=x("react.context");k=x("react.forward_ref");l=x("react.suspense");m=x("react.suspense_list");n=x("react.memo");p=x("react.lazy");q=x("react.block");r=x("react.server.block");u=x("react.fundamental");v=x("react.debug_trace_mode");w=x("react.legacy_hidden")} -function y(a){if("object"===typeof a&&null!==a){var t=a.$$typeof;switch(t){case b:switch(a=a.type,a){case d:case f:case e:case l:case m:return a;default:switch(a=a&&a.$$typeof,a){case h:case k:case p:case n:case g:return a;default:return t}}case c:return t}}}var z=g,A=b,B=k,C=d,D=p,E=n,F=c,G=f,H=e,I=l;exports.ContextConsumer=h;exports.ContextProvider=z;exports.Element=A;exports.ForwardRef=B;exports.Fragment=C;exports.Lazy=D;exports.Memo=E;exports.Portal=F;exports.Profiler=G;exports.StrictMode=H; -exports.Suspense=I;exports.isAsyncMode=function(){return!1};exports.isConcurrentMode=function(){return!1};exports.isContextConsumer=function(a){return y(a)===h};exports.isContextProvider=function(a){return y(a)===g};exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===b};exports.isForwardRef=function(a){return y(a)===k};exports.isFragment=function(a){return y(a)===d};exports.isLazy=function(a){return y(a)===p};exports.isMemo=function(a){return y(a)===n}; -exports.isPortal=function(a){return y(a)===c};exports.isProfiler=function(a){return y(a)===f};exports.isStrictMode=function(a){return y(a)===e};exports.isSuspense=function(a){return y(a)===l};exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===d||a===f||a===v||a===e||a===l||a===m||a===w||"object"===typeof a&&null!==a&&(a.$$typeof===p||a.$$typeof===n||a.$$typeof===g||a.$$typeof===h||a.$$typeof===k||a.$$typeof===u||a.$$typeof===q||a[0]===r)?!0:!1}; -exports.typeOf=y; +'use strict';var b=Symbol.for("react.element"),c=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),e=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),h=Symbol.for("react.context"),k=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),n=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),t=Symbol.for("react.offscreen"),u;u=Symbol.for("react.module.reference"); +function v(a){if("object"===typeof a&&null!==a){var r=a.$$typeof;switch(r){case b:switch(a=a.type,a){case d:case f:case e:case m:case n:return a;default:switch(a=a&&a.$$typeof,a){case k:case h:case l:case q:case p:case g:return a;default:return r}}case c:return r}}}exports.ContextConsumer=h;exports.ContextProvider=g;exports.Element=b;exports.ForwardRef=l;exports.Fragment=d;exports.Lazy=q;exports.Memo=p;exports.Portal=c;exports.Profiler=f;exports.StrictMode=e;exports.Suspense=m; +exports.SuspenseList=n;exports.isAsyncMode=function(){return!1};exports.isConcurrentMode=function(){return!1};exports.isContextConsumer=function(a){return v(a)===h};exports.isContextProvider=function(a){return v(a)===g};exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===b};exports.isForwardRef=function(a){return v(a)===l};exports.isFragment=function(a){return v(a)===d};exports.isLazy=function(a){return v(a)===q};exports.isMemo=function(a){return v(a)===p}; +exports.isPortal=function(a){return v(a)===c};exports.isProfiler=function(a){return v(a)===f};exports.isStrictMode=function(a){return v(a)===e};exports.isSuspense=function(a){return v(a)===m};exports.isSuspenseList=function(a){return v(a)===n}; +exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===d||a===f||a===e||a===m||a===n||a===t||"object"===typeof a&&null!==a&&(a.$$typeof===q||a.$$typeof===p||a.$$typeof===g||a.$$typeof===h||a.$$typeof===l||a.$$typeof===u||void 0!==a.getModuleId)?!0:!1};exports.typeOf=v; diff --git a/packages/next/compiled/react-is/package.json b/packages/next/compiled/react-is/package.json index 1a6567dcff5e9..4cd3c3bcbadad 100644 --- a/packages/next/compiled/react-is/package.json +++ b/packages/next/compiled/react-is/package.json @@ -1,6 +1,6 @@ { "name": "react-is", - "version": "17.0.2", + "version": "18.2.0", "description": "Brand checking of React Elements.", "main": "index.js", "repository": { @@ -19,9 +19,8 @@ "files": [ "LICENSE", "README.md", - "build-info.json", "index.js", "cjs/", "umd/" ] -} +} \ No newline at end of file diff --git a/packages/next/compiled/react-is/umd/react-is.development.js b/packages/next/compiled/react-is/umd/react-is.development.js index cc44c5bf49c3b..1257aef164e91 100644 --- a/packages/next/compiled/react-is/umd/react-is.development.js +++ b/packages/next/compiled/react-is/umd/react-is.development.js @@ -1,4 +1,5 @@ -/** @license React v17.0.2 +/** + * @license React * react-is.development.js * * Copyright (c) Facebook, Inc. and its affiliates. @@ -15,56 +16,39 @@ // ATTENTION // When adding new symbols to this file, // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' - // The Symbol used to tag the ReactElement-like types. If there is no native Symbol - // nor polyfill, then a plain number is used for performance. - var REACT_ELEMENT_TYPE = 0xeac7; - var REACT_PORTAL_TYPE = 0xeaca; - var REACT_FRAGMENT_TYPE = 0xeacb; - var REACT_STRICT_MODE_TYPE = 0xeacc; - var REACT_PROFILER_TYPE = 0xead2; - var REACT_PROVIDER_TYPE = 0xeacd; - var REACT_CONTEXT_TYPE = 0xeace; - var REACT_FORWARD_REF_TYPE = 0xead0; - var REACT_SUSPENSE_TYPE = 0xead1; - var REACT_SUSPENSE_LIST_TYPE = 0xead8; - var REACT_MEMO_TYPE = 0xead3; - var REACT_LAZY_TYPE = 0xead4; - var REACT_BLOCK_TYPE = 0xead9; - var REACT_SERVER_BLOCK_TYPE = 0xeada; - var REACT_FUNDAMENTAL_TYPE = 0xead5; - var REACT_SCOPE_TYPE = 0xead7; - var REACT_OPAQUE_ID_TYPE = 0xeae0; - var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; - var REACT_OFFSCREEN_TYPE = 0xeae2; - var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; - - if (typeof Symbol === 'function' && Symbol.for) { - var symbolFor = Symbol.for; - REACT_ELEMENT_TYPE = symbolFor('react.element'); - REACT_PORTAL_TYPE = symbolFor('react.portal'); - REACT_FRAGMENT_TYPE = symbolFor('react.fragment'); - REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode'); - REACT_PROFILER_TYPE = symbolFor('react.profiler'); - REACT_PROVIDER_TYPE = symbolFor('react.provider'); - REACT_CONTEXT_TYPE = symbolFor('react.context'); - REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref'); - REACT_SUSPENSE_TYPE = symbolFor('react.suspense'); - REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'); - REACT_MEMO_TYPE = symbolFor('react.memo'); - REACT_LAZY_TYPE = symbolFor('react.lazy'); - REACT_BLOCK_TYPE = symbolFor('react.block'); - REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block'); - REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental'); - REACT_SCOPE_TYPE = symbolFor('react.scope'); - REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'); - REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'); - REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen'); - REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); - } - - // Filter certain DOM attributes (e.g. src, href) if their values are empty strings. + // The Symbol used to tag the ReactElement-like types. + var REACT_ELEMENT_TYPE = Symbol.for('react.element'); + var REACT_PORTAL_TYPE = Symbol.for('react.portal'); + var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment'); + var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode'); + var REACT_PROFILER_TYPE = Symbol.for('react.profiler'); + var REACT_PROVIDER_TYPE = Symbol.for('react.provider'); + var REACT_CONTEXT_TYPE = Symbol.for('react.context'); + var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context'); + var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref'); + var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense'); + var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list'); + var REACT_MEMO_TYPE = Symbol.for('react.memo'); + var REACT_LAZY_TYPE = Symbol.for('react.lazy'); + var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen'); + + // ----------------------------------------------------------------------------- var enableScopeAPI = false; // Experimental Create Event Handle API. + var enableCacheElement = false; + var enableTransitionTracing = false; // No known bugs, but needs performance testing + + var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber + // stuff. Intended to enable React core members to more easily debug scheduling + // issues in DEV builds. + + var enableDebugTracing = false; // Track which Fiber(s) schedule render work. + + var REACT_MODULE_REFERENCE; + + { + REACT_MODULE_REFERENCE = Symbol.for('react.module.reference'); + } function isValidElementType(type) { if (typeof type === 'string' || typeof type === 'function') { @@ -72,12 +56,16 @@ } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). - if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) { + if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) { return true; } if (typeof type === 'object' && type !== null) { - if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) { + if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object + // types supported by any Flight configuration anywhere since + // we don't know which Flight build this will end up being used + // with. + type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) { return true; } } @@ -105,6 +93,7 @@ var $$typeofType = type && type.$$typeof; switch ($$typeofType) { + case REACT_SERVER_CONTEXT_TYPE: case REACT_CONTEXT_TYPE: case REACT_FORWARD_REF_TYPE: case REACT_LAZY_TYPE: @@ -136,6 +125,7 @@ var Profiler = REACT_PROFILER_TYPE; var StrictMode = REACT_STRICT_MODE_TYPE; var Suspense = REACT_SUSPENSE_TYPE; + var SuspenseList = REACT_SUSPENSE_LIST_TYPE; var hasWarnedAboutDeprecatedIsAsyncMode = false; var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated @@ -194,6 +184,9 @@ function isSuspense(object) { return typeOf(object) === REACT_SUSPENSE_TYPE; } + function isSuspenseList(object) { + return typeOf(object) === REACT_SUSPENSE_LIST_TYPE; + } exports.ContextConsumer = ContextConsumer; exports.ContextProvider = ContextProvider; @@ -206,6 +199,7 @@ exports.Profiler = Profiler; exports.StrictMode = StrictMode; exports.Suspense = Suspense; + exports.SuspenseList = SuspenseList; exports.isAsyncMode = isAsyncMode; exports.isConcurrentMode = isConcurrentMode; exports.isContextConsumer = isContextConsumer; @@ -219,6 +213,7 @@ exports.isProfiler = isProfiler; exports.isStrictMode = isStrictMode; exports.isSuspense = isSuspense; + exports.isSuspenseList = isSuspenseList; exports.isValidElementType = isValidElementType; exports.typeOf = typeOf; diff --git a/packages/next/compiled/react-is/umd/react-is.production.min.js b/packages/next/compiled/react-is/umd/react-is.production.min.js index 126d595e09069..84a9cdeed2cde 100644 --- a/packages/next/compiled/react-is/umd/react-is.production.min.js +++ b/packages/next/compiled/react-is/umd/react-is.production.min.js @@ -1,4 +1,5 @@ -/** @license React v17.0.2 +/** + * @license React * react-is.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. @@ -6,9 +7,9 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -(function(){'use strict';(function(b,d){"object"===typeof exports&&"undefined"!==typeof module?d(exports):"function"===typeof define&&define.amd?define(["exports"],d):(b=b||self,d(b.ReactIs={}))})(this,function(b){function d(a){if("object"===typeof a&&null!==a){var b=a.$$typeof;switch(b){case q:switch(a=a.type,a){case e:case f:case g:case h:case t:return a;default:switch(a=a&&a.$$typeof,a){case k:case l:case m:case n:case p:return a;default:return b}}case r:return b}}}var q=60103,r=60106,e=60107,g=60108,f=60114, -p=60109,k=60110,l=60112,h=60113,t=60120,n=60115,m=60116,u=60121,v=60122,w=60117,x=60129,y=60131;if("function"===typeof Symbol&&Symbol.for){var c=Symbol.for;q=c("react.element");r=c("react.portal");e=c("react.fragment");g=c("react.strict_mode");f=c("react.profiler");p=c("react.provider");k=c("react.context");l=c("react.forward_ref");h=c("react.suspense");t=c("react.suspense_list");n=c("react.memo");m=c("react.lazy");u=c("react.block");v=c("react.server.block");w=c("react.fundamental");x=c("react.debug_trace_mode"); -y=c("react.legacy_hidden")}b.ContextConsumer=k;b.ContextProvider=p;b.Element=q;b.ForwardRef=l;b.Fragment=e;b.Lazy=m;b.Memo=n;b.Portal=r;b.Profiler=f;b.StrictMode=g;b.Suspense=h;b.isAsyncMode=function(a){return!1};b.isConcurrentMode=function(a){return!1};b.isContextConsumer=function(a){return d(a)===k};b.isContextProvider=function(a){return d(a)===p};b.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===q};b.isForwardRef=function(a){return d(a)===l};b.isFragment=function(a){return d(a)=== -e};b.isLazy=function(a){return d(a)===m};b.isMemo=function(a){return d(a)===n};b.isPortal=function(a){return d(a)===r};b.isProfiler=function(a){return d(a)===f};b.isStrictMode=function(a){return d(a)===g};b.isSuspense=function(a){return d(a)===h};b.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===e||a===f||a===x||a===g||a===h||a===t||a===y||"object"===typeof a&&null!==a&&(a.$$typeof===m||a.$$typeof===n||a.$$typeof===p||a.$$typeof===k||a.$$typeof===l||a.$$typeof=== -w||a.$$typeof===u||a[0]===v)?!0:!1};b.typeOf=d}); +(function(){'use strict';(function(b,c){"object"===typeof exports&&"undefined"!==typeof module?c(exports):"function"===typeof define&&define.amd?define(["exports"],c):(b=b||self,c(b.ReactIs={}))})(this,function(b){function c(a){if("object"===typeof a&&null!==a){var b=a.$$typeof;switch(b){case q:switch(a=a.type,a){case d:case e:case f:case g:case h:return a;default:switch(a=a&&a.$$typeof,a){case t:case k:case l:case m:case n:case p:return a;default:return b}}case r:return b}}}var q=Symbol.for("react.element"), +r=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),e=Symbol.for("react.profiler"),p=Symbol.for("react.provider"),k=Symbol.for("react.context"),t=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),n=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),u=Symbol.for("react.offscreen");var v=Symbol.for("react.module.reference");b.ContextConsumer=k;b.ContextProvider=p;b.Element= +q;b.ForwardRef=l;b.Fragment=d;b.Lazy=m;b.Memo=n;b.Portal=r;b.Profiler=e;b.StrictMode=f;b.Suspense=g;b.SuspenseList=h;b.isAsyncMode=function(a){return!1};b.isConcurrentMode=function(a){return!1};b.isContextConsumer=function(a){return c(a)===k};b.isContextProvider=function(a){return c(a)===p};b.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===q};b.isForwardRef=function(a){return c(a)===l};b.isFragment=function(a){return c(a)===d};b.isLazy=function(a){return c(a)===m};b.isMemo= +function(a){return c(a)===n};b.isPortal=function(a){return c(a)===r};b.isProfiler=function(a){return c(a)===e};b.isStrictMode=function(a){return c(a)===f};b.isSuspense=function(a){return c(a)===g};b.isSuspenseList=function(a){return c(a)===h};b.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===d||a===e||a===f||a===g||a===h||a===u||"object"===typeof a&&null!==a&&(a.$$typeof===m||a.$$typeof===n||a.$$typeof===p||a.$$typeof===k||a.$$typeof===l||a.$$typeof===v||void 0!== +a.getModuleId)?!0:!1};b.typeOf=c}); })(); diff --git a/packages/next/package.json b/packages/next/package.json index 38c14bcc0ad44..7bc45965947f7 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -252,7 +252,7 @@ "punycode": "2.1.1", "querystring-es3": "0.2.1", "raw-body": "2.4.1", - "react-is": "17.0.2", + "react-is": "18.2.0", "react-refresh": "0.12.0", "regenerator-runtime": "0.13.4", "sass-loader": "12.4.0", diff --git a/packages/next/server/app-render.tsx b/packages/next/server/app-render.tsx index 1fab5b58f7fc3..466fc878aaf10 100644 --- a/packages/next/server/app-render.tsx +++ b/packages/next/server/app-render.tsx @@ -995,25 +995,31 @@ export async function renderToHTMLOrFlight( if (dev) { const { isValidElementType } = require('next/dist/compiled/react-is') - if (!isValidElementType(Component)) { + if ( + typeof Component !== 'undefined' && + !isValidElementType(Component) + ) { throw new Error( `The default export is not a React Component in page: "${pathname}"` ) } - if (ErrorComponent && !isValidElementType(ErrorComponent)) { + if ( + typeof ErrorComponent !== 'undefined' && + !isValidElementType(ErrorComponent) + ) { throw new Error( `The default export of error is not a React Component in page: ${segment}` ) } - if (Loading && !isValidElementType(Loading)) { + if (typeof Loading !== 'undefined' && !isValidElementType(Loading)) { throw new Error( `The default export of loading is not a React Component in ${segment}` ) } - if (NotFound && !isValidElementType(NotFound)) { + if (typeof NotFound !== 'undefined' && !isValidElementType(NotFound)) { throw new Error( `The default export of notFound is not a React Component in ${segment}` ) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ccbfb88e7e826..e01863ac693b9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -598,7 +598,7 @@ importers: punycode: 2.1.1 querystring-es3: 0.2.1 raw-body: 2.4.1 - react-is: 17.0.2 + react-is: 18.2.0 react-refresh: 0.12.0 regenerator-runtime: 0.13.4 sass-loader: 12.4.0 @@ -795,7 +795,7 @@ importers: punycode: 2.1.1 querystring-es3: 0.2.1 raw-body: 2.4.1 - react-is: 17.0.2 + react-is: 18.2.0 react-refresh: 0.12.0 regenerator-runtime: 0.13.4 sass-loader: 12.4.0_webpack@5.74.0 @@ -25410,6 +25410,13 @@ packages: } dev: true + /react-is/18.2.0: + resolution: + { + integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==, + } + dev: true + /react-lifecycles-compat/3.0.4: resolution: {