@sprlab/wccompiler 0.16.7 → 0.16.9
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/sfc-parser.js +9 -6
- package/package.json +1 -1
package/lib/sfc-parser.js
CHANGED
|
@@ -60,11 +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> (slot content, not SFC block)
|
|
64
|
-
if (blockName === 'template' && /#/.test(attrs)) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
63
|
const openEnd = m.index + m[0].length;
|
|
69
64
|
|
|
70
65
|
// Use depth counting to find the matching close tag (handles nested <template #name>)
|
|
@@ -243,9 +238,17 @@ export function parseSFC(source, fileName = '<unknown>') {
|
|
|
243
238
|
// ── Phase 1: Extract blocks ─────────────────────────────────────
|
|
244
239
|
|
|
245
240
|
const scriptBlocks = findBlocks(source, 'script');
|
|
246
|
-
const
|
|
241
|
+
const allTemplateBlocks = findBlocks(source, 'template');
|
|
247
242
|
const styleBlocks = findBlocks(source, 'style');
|
|
248
243
|
|
|
244
|
+
// Filter out slot templates (<template slot="name"> and <template #name>) from SFC blocks
|
|
245
|
+
// These are HTML elements inside the main template, not SFC blocks
|
|
246
|
+
const templateBlocks = allTemplateBlocks.filter(block => {
|
|
247
|
+
const attrs = block.attrs || '';
|
|
248
|
+
// Exclude templates with slot attribute or # shorthand (these are slot content)
|
|
249
|
+
return !/#/.test(attrs) && !/\bslot\s*=/.test(attrs);
|
|
250
|
+
});
|
|
251
|
+
|
|
249
252
|
// Check for duplicates
|
|
250
253
|
if (scriptBlocks.length > 1) {
|
|
251
254
|
throw sfcError(
|
package/package.json
CHANGED