@reckona/mreact-compiler 0.0.87 → 0.0.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/emit-server-stream.js +15 -14
- package/dist/emit-server-stream.js.map +1 -1
- package/dist/emit-server.js +1 -4
- package/dist/emit-server.js.map +1 -1
- package/dist/oxc-child-analysis.d.ts.map +1 -1
- package/dist/oxc-child-analysis.js +10 -0
- package/dist/oxc-child-analysis.js.map +1 -1
- package/dist/oxc-component-references.d.ts +2 -0
- package/dist/oxc-component-references.d.ts.map +1 -1
- package/dist/oxc-component-references.js +98 -0
- package/dist/oxc-component-references.js.map +1 -1
- package/dist/oxc.d.ts.map +1 -1
- package/dist/oxc.js +7 -1
- package/dist/oxc.js.map +1 -1
- package/package.json +2 -2
- package/src/emit-server-stream.ts +21 -14
- package/src/emit-server.ts +1 -5
- package/src/oxc-child-analysis.ts +14 -0
- package/src/oxc-component-references.ts +144 -0
- package/src/oxc.ts +9 -0
|
@@ -27,7 +27,7 @@ export function emitServerStream(ir, options = {}) {
|
|
|
27
27
|
const reactSuspenseOutOfOrderBoundaryHelperName = allocateHelperName(ir, "_renderReactSuspenseOutOfOrderBoundary");
|
|
28
28
|
const compatRenderToStringHelperName = allocateHelperName(ir, "_renderCompatToString");
|
|
29
29
|
const streamNodeHelperName = allocateHelperName(ir, "_renderStreamNode");
|
|
30
|
-
const clientBoundaryHelperName = usesClientBoundary(ir)
|
|
30
|
+
const clientBoundaryHelperName = usesClientBoundary(ir, options.serverHydration === true)
|
|
31
31
|
? allocateHelperName(ir, "_renderClientBoundary")
|
|
32
32
|
: undefined;
|
|
33
33
|
const spreadAttributesHelperName = allocateHelperName(ir, "_renderSpreadAttributes");
|
|
@@ -178,8 +178,8 @@ function hasReactNodeRender(ir) {
|
|
|
178
178
|
function hasRawJsxDynamicRender(ir) {
|
|
179
179
|
return ir.components.some((component) => containsRawJsxDynamicRender(component.root));
|
|
180
180
|
}
|
|
181
|
-
function usesClientBoundary(ir) {
|
|
182
|
-
return ir.components.some((component) => containsClientBoundary(component.root));
|
|
181
|
+
function usesClientBoundary(ir, serverHydration) {
|
|
182
|
+
return ir.components.some((component) => containsClientBoundary(component.root, serverHydration));
|
|
183
183
|
}
|
|
184
184
|
function emitClientBoundaryHelper(name) {
|
|
185
185
|
const propsHelperName = `${name}$hasNonSerializableProps`;
|
|
@@ -803,7 +803,7 @@ function collectHtmlParts(node, escapeHelperName, asyncBoundaryHelperName, outOf
|
|
|
803
803
|
},
|
|
804
804
|
];
|
|
805
805
|
}
|
|
806
|
-
if (isClientBoundaryPlaceholder(node)) {
|
|
806
|
+
if (isClientBoundaryPlaceholder(node, state.hydration)) {
|
|
807
807
|
const helperName = currentClientBoundaryHelperName;
|
|
808
808
|
if (helperName !== undefined) {
|
|
809
809
|
return [
|
|
@@ -1388,29 +1388,30 @@ function containsCompatComponent(node) {
|
|
|
1388
1388
|
}
|
|
1389
1389
|
return false;
|
|
1390
1390
|
}
|
|
1391
|
-
function containsClientBoundary(node) {
|
|
1392
|
-
if (node.kind === "component" && isClientBoundaryPlaceholder(node)) {
|
|
1391
|
+
function containsClientBoundary(node, serverHydration) {
|
|
1392
|
+
if (node.kind === "component" && isClientBoundaryPlaceholder(node, serverHydration)) {
|
|
1393
1393
|
return true;
|
|
1394
1394
|
}
|
|
1395
1395
|
if (node.kind === "component") {
|
|
1396
|
-
return (node.children.some(containsClientBoundary) ||
|
|
1397
|
-
node.props.some((prop) => prop.kind === "render-prop" &&
|
|
1396
|
+
return (node.children.some((child) => containsClientBoundary(child, serverHydration)) ||
|
|
1397
|
+
node.props.some((prop) => prop.kind === "render-prop" &&
|
|
1398
|
+
prop.children.some((child) => containsClientBoundary(child, serverHydration))));
|
|
1398
1399
|
}
|
|
1399
1400
|
if (node.kind === "conditional") {
|
|
1400
|
-
return [...node.whenTrue, ...node.whenFalse].some(containsClientBoundary);
|
|
1401
|
+
return [...node.whenTrue, ...node.whenFalse].some((child) => containsClientBoundary(child, serverHydration));
|
|
1401
1402
|
}
|
|
1402
1403
|
if (node.kind === "list") {
|
|
1403
|
-
return node.children.some(containsClientBoundary);
|
|
1404
|
+
return node.children.some((child) => containsClientBoundary(child, serverHydration));
|
|
1404
1405
|
}
|
|
1405
1406
|
if (node.kind === "element" || node.kind === "fragment") {
|
|
1406
|
-
return node.children.some(containsClientBoundary);
|
|
1407
|
+
return node.children.some((child) => containsClientBoundary(child, serverHydration));
|
|
1407
1408
|
}
|
|
1408
1409
|
if (node.kind === "async-boundary") {
|
|
1409
1410
|
return [
|
|
1410
1411
|
...node.children,
|
|
1411
1412
|
...(node.placeholderChildren ?? []),
|
|
1412
1413
|
...(node.catchChildren ?? []),
|
|
1413
|
-
].some(containsClientBoundary);
|
|
1414
|
+
].some((child) => containsClientBoundary(child, serverHydration));
|
|
1414
1415
|
}
|
|
1415
1416
|
return false;
|
|
1416
1417
|
}
|
|
@@ -1488,8 +1489,8 @@ function emitPropsObject(props, children = [], escapeHelperName = "_escapeHtml")
|
|
|
1488
1489
|
function emitPropName(name) {
|
|
1489
1490
|
return /^[A-Za-z_$][\w$]*$/.test(name) ? name : JSON.stringify(name);
|
|
1490
1491
|
}
|
|
1491
|
-
function isClientBoundaryPlaceholder(node) {
|
|
1492
|
-
return node.clientReference !== undefined && !isCompatClientReference(node);
|
|
1492
|
+
function isClientBoundaryPlaceholder(node, serverHydration = true) {
|
|
1493
|
+
return node.clientReference !== undefined && (!serverHydration || !isCompatClientReference(node));
|
|
1493
1494
|
}
|
|
1494
1495
|
function isCompatClientReference(node) {
|
|
1495
1496
|
return node.clientReference !== undefined && /\.(?:compat)\.[cm]?[jt]sx?$/.test(node.clientReference.moduleId);
|