Skip to content

Commit 76861e4

Browse files
matej21claude
andcommitted
fix(repeater): collect block JSX into array to survive Rolldown DCE
Rolldown aggressively eliminates code where function call results are only passed to other functions whose results are unused. Build a JSX array, pass it to collectNested, store the result, and merge it into the returned nestedSelection — making the entire chain non-eliminable. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 35dffb1 commit 76861e4

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

packages/bindx-repeater/src/components/BlockRepeater.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,17 @@ blockRepeaterWithSelection.getSelection = (
245245
const jsxSelection = collectNested(syntheticChildren)
246246

247247
// Call block render/form functions so the collector proxy records field accesses.
248-
// Collect JSX selections from block render/form output and merge into jsxSelection.
248+
// Collect JSX from block definitions and pass to collectNested alongside children.
249+
const blockJsx: ReactNode[] = []
249250
for (const blockDef of Object.values(props.blocks) as BlockDefinition[]) {
250-
if (blockDef.render) mergeSelections(jsxSelection, collectNested(blockDef.render(collectorEntity as EntityAccessor<object>)))
251-
if (blockDef.form) mergeSelections(jsxSelection, collectNested(blockDef.form(collectorEntity as EntityAccessor<object>)))
251+
if (blockDef.render) blockJsx.push(blockDef.render(collectorEntity as EntityAccessor<object>))
252+
if (blockDef.form) blockJsx.push(blockDef.form(collectorEntity as EntityAccessor<object>))
252253
}
254+
const blockSelection = collectNested(blockJsx)
253255

254256
const nestedSelection = scope.toSelectionMeta()
255257
mergeSelections(nestedSelection, jsxSelection)
258+
mergeSelections(nestedSelection, blockSelection)
256259

257260
// Add discrimination field to selection
258261
nestedSelection.fields.set(props.discriminationField, {

0 commit comments

Comments
 (0)