Skip to content

Commit

Permalink
Update precompiled react (#43288)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
huozhi committed Nov 23, 2022
1 parent 369d6b7 commit e901fef
Show file tree
Hide file tree
Showing 28 changed files with 15,413 additions and 5,800 deletions.
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -180,11 +180,11 @@
"random-seed": "0.3.0",
"react": "18.2.0",
"react-17": "npm:react@17.0.2",
"react-builtin": "npm:react@18.3.0-next-4bd245e9e-20221104",
"react-builtin": "npm:react@18.3.0-next-2655c9354-20221121",
"react-dom": "18.2.0",
"react-dom-17": "npm:react-dom@17.0.2",
"react-dom-builtin": "npm:react-dom@18.3.0-next-4bd245e9e-20221104",
"react-server-dom-webpack": "18.3.0-next-4bd245e9e-20221104",
"react-dom-builtin": "npm:react-dom@18.3.0-next-2655c9354-20221121",
"react-server-dom-webpack": "18.3.0-next-2655c9354-20221121",
"react-ssr-prepass": "1.0.8",
"react-virtualized": "9.22.3",
"relay-compiler": "13.0.2",
Expand Down
Expand Up @@ -17,7 +17,7 @@ if (process.env.NODE_ENV !== "production") {
var React = require('react');
var ReactDOM = require('react-dom');

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

var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;

Expand Down Expand Up @@ -94,6 +94,9 @@ function stringToChunk(content) {
function stringToPrecomputedChunk(content) {
return content;
}
function clonePrecomputedChunk(chunk) {
return chunk;
}
function closeWithError(destination, error) {
// $FlowFixMe: This is an Error object or the destination accepts other types.
destination.destroy(error);
Expand Down Expand Up @@ -4572,7 +4575,7 @@ function writeCompletedBoundaryInstruction(destination, responseState, boundaryI
if (!responseState.sentCompleteBoundaryFunction) {
responseState.sentCompleteBoundaryFunction = true;
responseState.sentStyleInsertionFunction = true;
writeChunk(destination, completeBoundaryWithStylesScript1FullBoth);
writeChunk(destination, clonePrecomputedChunk(completeBoundaryWithStylesScript1FullBoth));
} else if (!responseState.sentStyleInsertionFunction) {
responseState.sentStyleInsertionFunction = true;
writeChunk(destination, completeBoundaryWithStylesScript1FullPartial);
Expand Down Expand Up @@ -7709,6 +7712,7 @@ var didWarnAboutModulePatternComponent = {};
var didWarnAboutContextTypeOnFunctionComponent = {};
var didWarnAboutGetDerivedStateOnFunctionComponent = {};
var didWarnAboutReassigningProps = false;
var didWarnAboutDefaultPropsOnFunctionComponent = {};
var didWarnAboutGenerators = false;
var didWarnAboutMaps = false;
var hasWarnedAboutUsingContextAsConsumer = false; // This would typically be a function component but we still support module pattern
Expand Down Expand Up @@ -7804,6 +7808,16 @@ function validateFunctionComponentInDev(Component) {
}
}

if ( Component.defaultProps !== undefined) {
var componentName = getComponentNameFromType(Component) || 'Unknown';

if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
error('%s: Support for defaultProps will be removed from function components ' + 'in a future major release. Use JavaScript default parameters instead.', componentName);

didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true;
}
}

if (typeof Component.getDerivedStateFromProps === 'function') {
var _componentName3 = getComponentNameFromType(Component) || 'Unknown';

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -18,7 +18,7 @@ var React = require('react');
var ReactDOM = require('react-dom');
var stream = require('stream');

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

var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;

Expand Down Expand Up @@ -95,6 +95,9 @@ function stringToChunk(content) {
function stringToPrecomputedChunk(content) {
return content;
}
function clonePrecomputedChunk(chunk) {
return chunk;
}
function closeWithError(destination, error) {
// $FlowFixMe: This is an Error object or the destination accepts other types.
destination.destroy(error);
Expand Down Expand Up @@ -4573,7 +4576,7 @@ function writeCompletedBoundaryInstruction(destination, responseState, boundaryI
if (!responseState.sentCompleteBoundaryFunction) {
responseState.sentCompleteBoundaryFunction = true;
responseState.sentStyleInsertionFunction = true;
writeChunk(destination, completeBoundaryWithStylesScript1FullBoth);
writeChunk(destination, clonePrecomputedChunk(completeBoundaryWithStylesScript1FullBoth));
} else if (!responseState.sentStyleInsertionFunction) {
responseState.sentStyleInsertionFunction = true;
writeChunk(destination, completeBoundaryWithStylesScript1FullPartial);
Expand Down Expand Up @@ -7710,6 +7713,7 @@ var didWarnAboutModulePatternComponent = {};
var didWarnAboutContextTypeOnFunctionComponent = {};
var didWarnAboutGetDerivedStateOnFunctionComponent = {};
var didWarnAboutReassigningProps = false;
var didWarnAboutDefaultPropsOnFunctionComponent = {};
var didWarnAboutGenerators = false;
var didWarnAboutMaps = false;
var hasWarnedAboutUsingContextAsConsumer = false; // This would typically be a function component but we still support module pattern
Expand Down Expand Up @@ -7805,6 +7809,16 @@ function validateFunctionComponentInDev(Component) {
}
}

if ( Component.defaultProps !== undefined) {
var componentName = getComponentNameFromType(Component) || 'Unknown';

if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
error('%s: Support for defaultProps will be removed from function components ' + 'in a future major release. Use JavaScript default parameters instead.', componentName);

didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true;
}
}

if (typeof Component.getDerivedStateFromProps === 'function') {
var _componentName3 = getComponentNameFromType(Component) || 'Unknown';

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -14,7 +14,7 @@ if (process.env.NODE_ENV !== "production") {
(function() {
'use strict';

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

var Internals = {
usingClientEntryPoint: false,
Expand Down
Expand Up @@ -8,4 +8,4 @@
* LICENSE file in the root directory of this source tree.
*/
'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;
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";
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";
Expand Up @@ -17,7 +17,7 @@ if (process.env.NODE_ENV !== "production") {
var React = require('react');
var ReactDOM = require('react-dom');

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

var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;

Expand Down Expand Up @@ -94,9 +94,15 @@ function writeChunk(destination, chunk) {
}

if (chunk.length > VIEW_SIZE) {
// this chunk may overflow a single view which implies it was not
{
if (precomputedChunkSet.has(chunk)) {
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.');
}
} // this chunk may overflow a single view which implies it was not
// one that is cached by the streaming renderer. We will enqueu
// it directly and expect it is not re-used


if (writtenBytes > 0) {
destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes));
currentView = new Uint8Array(VIEW_SIZE);
Expand Down Expand Up @@ -151,8 +157,18 @@ var textEncoder = new TextEncoder();
function stringToChunk(content) {
return textEncoder.encode(content);
}
var precomputedChunkSet = new Set() ;
function stringToPrecomputedChunk(content) {
return textEncoder.encode(content);
var precomputedChunk = textEncoder.encode(content);

{
precomputedChunkSet.add(precomputedChunk);
}

return precomputedChunk;
}
function clonePrecomputedChunk(precomputedChunk) {
return precomputedChunk.length > VIEW_SIZE ? precomputedChunk.slice() : precomputedChunk;
}
function closeWithError(destination, error) {
// $FlowFixMe[method-unbinding]
Expand Down Expand Up @@ -4648,7 +4664,7 @@ function writeCompletedBoundaryInstruction(destination, responseState, boundaryI
if (!responseState.sentCompleteBoundaryFunction) {
responseState.sentCompleteBoundaryFunction = true;
responseState.sentStyleInsertionFunction = true;
writeChunk(destination, completeBoundaryWithStylesScript1FullBoth);
writeChunk(destination, clonePrecomputedChunk(completeBoundaryWithStylesScript1FullBoth));
} else if (!responseState.sentStyleInsertionFunction) {
responseState.sentStyleInsertionFunction = true;
writeChunk(destination, completeBoundaryWithStylesScript1FullPartial);
Expand Down Expand Up @@ -7709,6 +7725,7 @@ var didWarnAboutModulePatternComponent = {};
var didWarnAboutContextTypeOnFunctionComponent = {};
var didWarnAboutGetDerivedStateOnFunctionComponent = {};
var didWarnAboutReassigningProps = false;
var didWarnAboutDefaultPropsOnFunctionComponent = {};
var didWarnAboutGenerators = false;
var didWarnAboutMaps = false;
var hasWarnedAboutUsingContextAsConsumer = false; // This would typically be a function component but we still support module pattern
Expand Down Expand Up @@ -7804,6 +7821,16 @@ function validateFunctionComponentInDev(Component) {
}
}

if ( Component.defaultProps !== undefined) {
var componentName = getComponentNameFromType(Component) || 'Unknown';

if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
error('%s: Support for defaultProps will be removed from function components ' + 'in a future major release. Use JavaScript default parameters instead.', componentName);

didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true;
}
}

if (typeof Component.getDerivedStateFromProps === 'function') {
var _componentName3 = getComponentNameFromType(Component) || 'Unknown';

Expand Down

0 comments on commit e901fef

Please sign in to comment.