Skip to content

Commit e901fef

Browse files
authored
Update precompiled react (#43288)
Update pre-compiled react to fix the streaming issue with node 18. x-ref: facebook/react#25645 Fixes: #42466 Manually tested locally works for the reproduction from the issue ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
1 parent 369d6b7 commit e901fef

28 files changed

+15413
-5800
lines changed

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@
180180
"random-seed": "0.3.0",
181181
"react": "18.2.0",
182182
"react-17": "npm:[email protected]",
183-
"react-builtin": "npm:[email protected]4bd245e9e-20221104",
183+
"react-builtin": "npm:[email protected]2655c9354-20221121",
184184
"react-dom": "18.2.0",
185185
"react-dom-17": "npm:[email protected]",
186-
"react-dom-builtin": "npm:[email protected]4bd245e9e-20221104",
187-
"react-server-dom-webpack": "18.3.0-next-4bd245e9e-20221104",
186+
"react-dom-builtin": "npm:[email protected]2655c9354-20221121",
187+
"react-server-dom-webpack": "18.3.0-next-2655c9354-20221121",
188188
"react-ssr-prepass": "1.0.8",
189189
"react-virtualized": "9.22.3",
190190
"relay-compiler": "13.0.2",

packages/next/compiled/react-dom/cjs/react-dom-server-legacy.browser.development.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (process.env.NODE_ENV !== "production") {
1717
var React = require('react');
1818
var ReactDOM = require('react-dom');
1919

20-
var ReactVersion = '18.3.0-next-4bd245e9e-20221104';
20+
var ReactVersion = '18.3.0-next-2655c9354-20221121';
2121

2222
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
2323

@@ -94,6 +94,9 @@ function stringToChunk(content) {
9494
function stringToPrecomputedChunk(content) {
9595
return content;
9696
}
97+
function clonePrecomputedChunk(chunk) {
98+
return chunk;
99+
}
97100
function closeWithError(destination, error) {
98101
// $FlowFixMe: This is an Error object or the destination accepts other types.
99102
destination.destroy(error);
@@ -4572,7 +4575,7 @@ function writeCompletedBoundaryInstruction(destination, responseState, boundaryI
45724575
if (!responseState.sentCompleteBoundaryFunction) {
45734576
responseState.sentCompleteBoundaryFunction = true;
45744577
responseState.sentStyleInsertionFunction = true;
4575-
writeChunk(destination, completeBoundaryWithStylesScript1FullBoth);
4578+
writeChunk(destination, clonePrecomputedChunk(completeBoundaryWithStylesScript1FullBoth));
45764579
} else if (!responseState.sentStyleInsertionFunction) {
45774580
responseState.sentStyleInsertionFunction = true;
45784581
writeChunk(destination, completeBoundaryWithStylesScript1FullPartial);
@@ -7709,6 +7712,7 @@ var didWarnAboutModulePatternComponent = {};
77097712
var didWarnAboutContextTypeOnFunctionComponent = {};
77107713
var didWarnAboutGetDerivedStateOnFunctionComponent = {};
77117714
var didWarnAboutReassigningProps = false;
7715+
var didWarnAboutDefaultPropsOnFunctionComponent = {};
77127716
var didWarnAboutGenerators = false;
77137717
var didWarnAboutMaps = false;
77147718
var hasWarnedAboutUsingContextAsConsumer = false; // This would typically be a function component but we still support module pattern
@@ -7804,6 +7808,16 @@ function validateFunctionComponentInDev(Component) {
78047808
}
78057809
}
78067810

7811+
if ( Component.defaultProps !== undefined) {
7812+
var componentName = getComponentNameFromType(Component) || 'Unknown';
7813+
7814+
if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
7815+
error('%s: Support for defaultProps will be removed from function components ' + 'in a future major release. Use JavaScript default parameters instead.', componentName);
7816+
7817+
didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true;
7818+
}
7819+
}
7820+
78077821
if (typeof Component.getDerivedStateFromProps === 'function') {
78087822
var _componentName3 = getComponentNameFromType(Component) || 'Unknown';
78097823

packages/next/compiled/react-dom/cjs/react-dom-server-legacy.browser.production.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/next/compiled/react-dom/cjs/react-dom-server-legacy.node.development.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var React = require('react');
1818
var ReactDOM = require('react-dom');
1919
var stream = require('stream');
2020

21-
var ReactVersion = '18.3.0-next-4bd245e9e-20221104';
21+
var ReactVersion = '18.3.0-next-2655c9354-20221121';
2222

2323
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
2424

@@ -95,6 +95,9 @@ function stringToChunk(content) {
9595
function stringToPrecomputedChunk(content) {
9696
return content;
9797
}
98+
function clonePrecomputedChunk(chunk) {
99+
return chunk;
100+
}
98101
function closeWithError(destination, error) {
99102
// $FlowFixMe: This is an Error object or the destination accepts other types.
100103
destination.destroy(error);
@@ -4573,7 +4576,7 @@ function writeCompletedBoundaryInstruction(destination, responseState, boundaryI
45734576
if (!responseState.sentCompleteBoundaryFunction) {
45744577
responseState.sentCompleteBoundaryFunction = true;
45754578
responseState.sentStyleInsertionFunction = true;
4576-
writeChunk(destination, completeBoundaryWithStylesScript1FullBoth);
4579+
writeChunk(destination, clonePrecomputedChunk(completeBoundaryWithStylesScript1FullBoth));
45774580
} else if (!responseState.sentStyleInsertionFunction) {
45784581
responseState.sentStyleInsertionFunction = true;
45794582
writeChunk(destination, completeBoundaryWithStylesScript1FullPartial);
@@ -7710,6 +7713,7 @@ var didWarnAboutModulePatternComponent = {};
77107713
var didWarnAboutContextTypeOnFunctionComponent = {};
77117714
var didWarnAboutGetDerivedStateOnFunctionComponent = {};
77127715
var didWarnAboutReassigningProps = false;
7716+
var didWarnAboutDefaultPropsOnFunctionComponent = {};
77137717
var didWarnAboutGenerators = false;
77147718
var didWarnAboutMaps = false;
77157719
var hasWarnedAboutUsingContextAsConsumer = false; // This would typically be a function component but we still support module pattern
@@ -7805,6 +7809,16 @@ function validateFunctionComponentInDev(Component) {
78057809
}
78067810
}
78077811

7812+
if ( Component.defaultProps !== undefined) {
7813+
var componentName = getComponentNameFromType(Component) || 'Unknown';
7814+
7815+
if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
7816+
error('%s: Support for defaultProps will be removed from function components ' + 'in a future major release. Use JavaScript default parameters instead.', componentName);
7817+
7818+
didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true;
7819+
}
7820+
}
7821+
78087822
if (typeof Component.getDerivedStateFromProps === 'function') {
78097823
var _componentName3 = getComponentNameFromType(Component) || 'Unknown';
78107824

packages/next/compiled/react-dom/cjs/react-dom-server-legacy.node.production.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/next/compiled/react-dom/cjs/react-dom-server-rendering-stub.development.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if (process.env.NODE_ENV !== "production") {
1414
(function() {
1515
'use strict';
1616

17-
var ReactVersion = '18.3.0-next-4bd245e9e-20221104';
17+
var ReactVersion = '18.3.0-next-2655c9354-20221121';
1818

1919
var Internals = {
2020
usingClientEntryPoint: false,

packages/next/compiled/react-dom/cjs/react-dom-server-rendering-stub.production.min.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
* LICENSE file in the root directory of this source tree.
99
*/
1010
'use strict';var b={usingClientEntryPoint:!1,Events:null,Dispatcher:{current:null}};function d(a){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;c<arguments.length;c++)e+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+a+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=b;
11-
exports.createPortal=function(){throw Error(d(448));};exports.flushSync=function(){throw Error(d(449));};exports.preinit=function(){var a=b.Dispatcher.current;a&&a.preinit.apply(this,arguments)};exports.preload=function(){var a=b.Dispatcher.current;a&&a.preload.apply(this,arguments)};exports.version="18.3.0-next-4bd245e9e-20221104";
11+
exports.createPortal=function(){throw Error(d(448));};exports.flushSync=function(){throw Error(d(449));};exports.preinit=function(){var a=b.Dispatcher.current;a&&a.preinit.apply(this,arguments)};exports.preload=function(){var a=b.Dispatcher.current;a&&a.preload.apply(this,arguments)};exports.version="18.3.0-next-2655c9354-20221121";

packages/next/compiled/react-dom/cjs/react-dom-server.browser.development.js

+31-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (process.env.NODE_ENV !== "production") {
1717
var React = require('react');
1818
var ReactDOM = require('react-dom');
1919

20-
var ReactVersion = '18.3.0-next-4bd245e9e-20221104';
20+
var ReactVersion = '18.3.0-next-2655c9354-20221121';
2121

2222
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
2323

@@ -94,9 +94,15 @@ function writeChunk(destination, chunk) {
9494
}
9595

9696
if (chunk.length > VIEW_SIZE) {
97-
// this chunk may overflow a single view which implies it was not
97+
{
98+
if (precomputedChunkSet.has(chunk)) {
99+
error('A large precomputed chunk was passed to writeChunk without being copied.' + ' Large chunks get enqueued directly and are not copied. This is incompatible with precomputed chunks because you cannot enqueue the same precomputed chunk twice.' + ' Use "cloneChunk" to make a copy of this large precomputed chunk before writing it. This is a bug in React.');
100+
}
101+
} // this chunk may overflow a single view which implies it was not
98102
// one that is cached by the streaming renderer. We will enqueu
99103
// it directly and expect it is not re-used
104+
105+
100106
if (writtenBytes > 0) {
101107
destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes));
102108
currentView = new Uint8Array(VIEW_SIZE);
@@ -151,8 +157,18 @@ var textEncoder = new TextEncoder();
151157
function stringToChunk(content) {
152158
return textEncoder.encode(content);
153159
}
160+
var precomputedChunkSet = new Set() ;
154161
function stringToPrecomputedChunk(content) {
155-
return textEncoder.encode(content);
162+
var precomputedChunk = textEncoder.encode(content);
163+
164+
{
165+
precomputedChunkSet.add(precomputedChunk);
166+
}
167+
168+
return precomputedChunk;
169+
}
170+
function clonePrecomputedChunk(precomputedChunk) {
171+
return precomputedChunk.length > VIEW_SIZE ? precomputedChunk.slice() : precomputedChunk;
156172
}
157173
function closeWithError(destination, error) {
158174
// $FlowFixMe[method-unbinding]
@@ -4648,7 +4664,7 @@ function writeCompletedBoundaryInstruction(destination, responseState, boundaryI
46484664
if (!responseState.sentCompleteBoundaryFunction) {
46494665
responseState.sentCompleteBoundaryFunction = true;
46504666
responseState.sentStyleInsertionFunction = true;
4651-
writeChunk(destination, completeBoundaryWithStylesScript1FullBoth);
4667+
writeChunk(destination, clonePrecomputedChunk(completeBoundaryWithStylesScript1FullBoth));
46524668
} else if (!responseState.sentStyleInsertionFunction) {
46534669
responseState.sentStyleInsertionFunction = true;
46544670
writeChunk(destination, completeBoundaryWithStylesScript1FullPartial);
@@ -7709,6 +7725,7 @@ var didWarnAboutModulePatternComponent = {};
77097725
var didWarnAboutContextTypeOnFunctionComponent = {};
77107726
var didWarnAboutGetDerivedStateOnFunctionComponent = {};
77117727
var didWarnAboutReassigningProps = false;
7728+
var didWarnAboutDefaultPropsOnFunctionComponent = {};
77127729
var didWarnAboutGenerators = false;
77137730
var didWarnAboutMaps = false;
77147731
var hasWarnedAboutUsingContextAsConsumer = false; // This would typically be a function component but we still support module pattern
@@ -7804,6 +7821,16 @@ function validateFunctionComponentInDev(Component) {
78047821
}
78057822
}
78067823

7824+
if ( Component.defaultProps !== undefined) {
7825+
var componentName = getComponentNameFromType(Component) || 'Unknown';
7826+
7827+
if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
7828+
error('%s: Support for defaultProps will be removed from function components ' + 'in a future major release. Use JavaScript default parameters instead.', componentName);
7829+
7830+
didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true;
7831+
}
7832+
}
7833+
78077834
if (typeof Component.getDerivedStateFromProps === 'function') {
78087835
var _componentName3 = getComponentNameFromType(Component) || 'Unknown';
78097836

0 commit comments

Comments
 (0)