Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions compiler/scripts/release/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function main() {
.option('tag', {
description: 'Tag to publish to npm',
type: 'choices',
choices: ['experimental', 'beta', 'rc'],
choices: ['experimental', 'beta', 'rc', 'latest'],
default: 'experimental',
})
.option('tag-version', {
Expand Down Expand Up @@ -145,10 +145,15 @@ async function main() {
files: {exclude: ['.DS_Store']},
});
const truncatedHash = hash.slice(0, 7);
let newVersion =
argv.tagVersion == null || argv.tagVersion === ''
? `${argv.versionName}-${argv.tag}`
: `${argv.versionName}-${argv.tag}.${argv.tagVersion}`;
let newVersion;
if (argv.tag === 'latest') {
newVersion = argv.versionName;
} else {
newVersion =
argv.tagVersion == null || argv.tagVersion === ''
? `${argv.versionName}-${argv.tag}`
: `${argv.versionName}-${argv.tag}.${argv.tagVersion}`;
}
if (argv.tag === 'experimental' || argv.tag === 'beta') {
newVersion = `${newVersion}-${truncatedHash}-${dateString}`;
}
Expand Down Expand Up @@ -181,21 +186,9 @@ async function main() {
if (otp != null) {
opts.push(`--otp=${otp}`);
}
/**
* Typically, the `latest` tag is reserved for stable package versions. Since the the compiler
* is still pre-release, until we have a stable release let's only add the
* `latest` tag to non-experimental releases.
*
* `latest` is added by default, so we only override it for experimental releases so that
* those don't get the `latest` tag.
*
* TODO: Update this when we have a stable release.
*/
if (argv.tag === 'experimental') {
opts.push('--tag=experimental');
} else {
opts.push('--tag=latest');
}

opts.push(`--tag=${argv.tag}`);

try {
await spawnHelper(
'npm',
Expand Down
89 changes: 74 additions & 15 deletions packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,49 @@ export function resolveRequest(): null | Request {
return null;
}

function isTypedArray(value: any): boolean {
if (value instanceof ArrayBuffer) {
return true;
}
if (value instanceof Int8Array) {
return true;
}
if (value instanceof Uint8Array) {
return true;
}
if (value instanceof Uint8ClampedArray) {
return true;
}
if (value instanceof Int16Array) {
return true;
}
if (value instanceof Uint16Array) {
return true;
}
if (value instanceof Int32Array) {
return true;
}
if (value instanceof Uint32Array) {
return true;
}
if (value instanceof Float32Array) {
return true;
}
if (value instanceof Float64Array) {
return true;
}
if (value instanceof BigInt64Array) {
return true;
}
if (value instanceof BigUint64Array) {
return true;
}
if (value instanceof DataView) {
return true;
}
return false;
}

function serializeDebugThenable(
request: Request,
counter: {objectLimit: number},
Expand Down Expand Up @@ -906,6 +949,17 @@ function serializeDebugThenable(
enqueueFlush(request);
return;
}
if (
(isArray(value) && value.length > 200) ||
(isTypedArray(value) && value.byteLength > 1000)
) {
// If this should be deferred, but we don't have a debug channel installed
// it would get omitted. We can't omit outlined models but we can avoid
// resolving the Promise at all by halting it.
emitDebugHaltChunk(request, id);
enqueueFlush(request);
return;
}
emitOutlinedDebugModelChunk(request, id, counter, value);
enqueueFlush(request);
},
Expand Down Expand Up @@ -3066,6 +3120,10 @@ function serializeDebugTypedArray(
tag: string,
typedArray: $ArrayBufferView,
): string {
if (typedArray.byteLength > 1000 && !doNotLimit.has(typedArray)) {
// Defer large typed arrays.
return serializeDeferredObject(request, typedArray);
}
request.pendingDebugChunks++;
const bufferId = request.nextChunkId++;
emitTypedArrayChunk(request, bufferId, tag, typedArray, true);
Expand Down Expand Up @@ -4820,9 +4878,17 @@ function renderDebugModel(
}

if (isArray(value)) {
if (value.length > 200 && !doNotLimit.has(value)) {
// Defer large arrays. They're heavy to serialize.
// TODO: Consider doing the same for objects with many properties too.
return serializeDeferredObject(request, value);
}
return value;
}

if (value instanceof Date) {
return serializeDate(value);
}
if (value instanceof Map) {
return serializeDebugMap(request, counter, value);
}
Expand Down Expand Up @@ -4930,15 +4996,6 @@ function renderDebugModel(
}

if (typeof value === 'string') {
if (value[value.length - 1] === 'Z') {
// Possibly a Date, whose toJSON automatically calls toISOString
// Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
// $FlowFixMe[incompatible-use]
const originalValue = parent[parentPropertyName];
if (originalValue instanceof Date) {
return serializeDateFromDateJSON(value);
}
}
if (value.length >= 1024) {
// Large strings are counted towards the object limit.
if (counter.objectLimit <= 0) {
Expand Down Expand Up @@ -5036,10 +5093,6 @@ function renderDebugModel(
return serializeBigInt(value);
}

if (value instanceof Date) {
return serializeDate(value);
}

return 'unknown type ' + typeof value;
}

Expand All @@ -5058,12 +5111,15 @@ function serializeDebugModel(
value: ReactClientValue,
): ReactJSONValue {
try {
// By-pass toJSON and use the original value.
// $FlowFixMe[incompatible-use]
const originalValue = this[parentPropertyName];
return renderDebugModel(
request,
counter,
this,
parentPropertyName,
value,
originalValue,
);
} catch (x) {
return (
Expand Down Expand Up @@ -5114,12 +5170,15 @@ function emitOutlinedDebugModelChunk(
value: ReactClientValue,
): ReactJSONValue {
try {
// By-pass toJSON and use the original value.
// $FlowFixMe[incompatible-use]
const originalValue = this[parentPropertyName];
return renderDebugModel(
request,
counter,
this,
parentPropertyName,
value,
originalValue,
);
} catch (x) {
return (
Expand Down
Loading
Loading