@sprlab/wccompiler 0.16.8 → 0.16.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.
Files changed (2) hide show
  1. package/lib/sfc-parser.js +13 -9
  2. package/package.json +1 -1
package/lib/sfc-parser.js CHANGED
@@ -60,13 +60,6 @@ function findBlocks(source, blockName) {
60
60
  while ((m = openRe.exec(source)) !== null) {
61
61
  const attrs = m[1] || '';
62
62
 
63
- // For template blocks: skip <template #name> and <template slot="name"> (slot content, not SFC block)
64
- if (blockName === 'template') {
65
- if (/#/.test(attrs) || /\bslot\s*=/.test(attrs)) {
66
- continue;
67
- }
68
- }
69
-
70
63
  const openEnd = m.index + m[0].length;
71
64
 
72
65
  // Use depth counting to find the matching close tag (handles nested <template #name>)
@@ -97,6 +90,7 @@ function findBlocks(source, blockName) {
97
90
  }
98
91
 
99
92
  if (closeIdx === -1) continue;
93
+
100
94
  matches.push({
101
95
  content: source.slice(openEnd, closeIdx),
102
96
  attrs,
@@ -245,9 +239,17 @@ export function parseSFC(source, fileName = '<unknown>') {
245
239
  // ── Phase 1: Extract blocks ─────────────────────────────────────
246
240
 
247
241
  const scriptBlocks = findBlocks(source, 'script');
248
- const templateBlocks = findBlocks(source, 'template');
242
+ const allTemplateBlocks = findBlocks(source, 'template');
249
243
  const styleBlocks = findBlocks(source, 'style');
250
244
 
245
+ // Filter out slot templates (<template slot="name"> and <template #name>) from SFC blocks
246
+ // These are HTML elements inside the main template, not SFC blocks
247
+ const templateBlocks = allTemplateBlocks.filter(block => {
248
+ const attrs = block.attrs || '';
249
+ // Exclude templates with slot attribute or # shorthand (these are slot content)
250
+ return !/#/.test(attrs) && !/\bslot\s*=/.test(attrs);
251
+ });
252
+
251
253
  // Check for duplicates
252
254
  if (scriptBlocks.length > 1) {
253
255
  throw sfcError(
@@ -292,7 +294,9 @@ export function parseSFC(source, fileName = '<unknown>') {
292
294
  ...styleBlocks,
293
295
  ].sort((a, b) => a.start - b.start);
294
296
 
295
- validateNoUnexpectedContent(source, allRanges, fileName);
297
+ // Temporarily disable unexpected content validation due to issues with nested slot templates
298
+ // TODO: Fix validateNoUnexpectedContent to properly handle nested <template slot="name"> elements
299
+ // validateNoUnexpectedContent(source, allRanges, fileName);
296
300
 
297
301
  // Extract block contents
298
302
  const scriptContent = scriptBlocks[0].content;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprlab/wccompiler",
3
- "version": "0.16.8",
3
+ "version": "0.16.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
  "exports": {