@sprlab/wccompiler 0.5.9 → 0.5.10

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/lib/compiler.js CHANGED
@@ -291,14 +291,31 @@ async function compileSFC(filePath, config) {
291
291
  }
292
292
  }
293
293
 
294
- // 18. Resolve child component imports
294
+ // 18. Resolve child component imports (from main template + if branches + each blocks)
295
295
  /** @type {import('./types.js').ChildComponentImport[]} */
296
296
  const childImports = [];
297
- if (childComponents.length > 0) {
298
- const uniqueTags = [...new Set(childComponents.map(c => c.tag))];
297
+ const allChildTags = new Set(childComponents.map(c => c.tag));
298
+
299
+ // Collect child tags from if branches
300
+ for (const ifBlock of ifBlocks) {
301
+ for (const branch of ifBlock.branches) {
302
+ if (branch.childComponents) {
303
+ for (const cc of branch.childComponents) allChildTags.add(cc.tag);
304
+ }
305
+ }
306
+ }
307
+
308
+ // Collect child tags from each blocks
309
+ for (const forBlock of forBlocks) {
310
+ if (forBlock.childComponents) {
311
+ for (const cc of forBlock.childComponents) allChildTags.add(cc.tag);
312
+ }
313
+ }
314
+
315
+ if (allChildTags.size > 0) {
299
316
  const sourceDir = dirname(filePath);
300
317
 
301
- for (const tag of uniqueTags) {
318
+ for (const tag of allChildTags) {
302
319
  const resolved = resolveChildComponent(tag, sourceDir, config);
303
320
  if (resolved) {
304
321
  childImports.push({ tag, importPath: resolved });
@@ -432,7 +432,7 @@ function buildIfBlock(chain, parent, parentPath, idx, signalNames, computedNames
432
432
  const templateHtml = clone.outerHTML;
433
433
 
434
434
  // Process internal bindings/events via partial walk
435
- const { bindings, events, showBindings, attrBindings, modelBindings, slots, processedHtml } = walkBranch(templateHtml, signalNames, computedNames, propNames);
435
+ const { bindings, events, showBindings, attrBindings, modelBindings, slots, childComponents, processedHtml } = walkBranch(templateHtml, signalNames, computedNames, propNames);
436
436
 
437
437
  return {
438
438
  type: branch.type,
@@ -444,6 +444,7 @@ function buildIfBlock(chain, parent, parentPath, idx, signalNames, computedNames
444
444
  attrBindings,
445
445
  modelBindings,
446
446
  slots,
447
+ childComponents,
447
448
  };
448
449
  });
449
450
 
@@ -762,7 +763,7 @@ export function processForBlocks(parent, parentPath, signalNames, computedNames,
762
763
  const templateHtml = clone.outerHTML;
763
764
 
764
765
  // Process internal bindings/events via partial walk
765
- const { bindings, events, showBindings, attrBindings, modelBindings, slots, processedHtml } = walkBranch(templateHtml, signalNames, computedNames, propNames);
766
+ const { bindings, events, showBindings, attrBindings, modelBindings, slots, childComponents: forChildComponents, processedHtml } = walkBranch(templateHtml, signalNames, computedNames, propNames);
766
767
 
767
768
  // Replace the original element with a comment node <!-- each -->
768
769
  const doc = node.ownerDocument;
@@ -790,6 +791,7 @@ export function processForBlocks(parent, parentPath, signalNames, computedNames,
790
791
  attrBindings,
791
792
  modelBindings,
792
793
  slots,
794
+ childComponents: forChildComponents,
793
795
  });
794
796
  } else {
795
797
  // Recurse into non-each elements to find nested each
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprlab/wccompiler",
3
- "version": "0.5.9",
3
+ "version": "0.5.10",
4
4
  "description": "Zero-runtime compiler that transforms .wcc single-file components into native web components with signals-based reactivity",
5
5
  "type": "module",
6
6
  "bin": {