@sprlab/wccompiler 0.5.10 → 0.5.11

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/compiler.js +16 -0
  2. package/package.json +1 -1
package/lib/compiler.js CHANGED
@@ -86,6 +86,15 @@ async function compileSFC(filePath, config) {
86
86
  // 2. Process script block — mirrors parser.js logic
87
87
  let source = stripMacroImport(descriptor.script);
88
88
 
89
+ // 2b. Extract manual .wcc imports (e.g. import './child.wcc') and strip them from source
90
+ const manualImports = [];
91
+ const wccImportRe = /import\s+['"]([^'"]+\.wcc)['"]\s*;?/g;
92
+ let wccImportMatch;
93
+ while ((wccImportMatch = wccImportRe.exec(source)) !== null) {
94
+ manualImports.push(wccImportMatch[1].replace(/\.wcc$/, '.js'));
95
+ }
96
+ source = source.replace(wccImportRe, '');
97
+
89
98
  // 3. Extract props/emits from generic forms BEFORE type stripping
90
99
  const propsFromGeneric = extractPropsGeneric(source);
91
100
  const propsObjectNameFromGeneric = extractPropsObjectName(source);
@@ -336,6 +345,13 @@ async function compileSFC(filePath, config) {
336
345
  parseResult.slots = slots;
337
346
  parseResult.refBindings = refBindings;
338
347
  parseResult.childComponents = childComponents;
348
+
349
+ // Add manual .wcc imports from script block
350
+ for (const imp of manualImports) {
351
+ if (!childImports.find(ci => ci.importPath === imp)) {
352
+ childImports.push({ tag: '', importPath: imp });
353
+ }
354
+ }
339
355
  parseResult.childImports = childImports;
340
356
  parseResult.processedTemplate = rootEl.innerHTML;
341
357
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprlab/wccompiler",
3
- "version": "0.5.10",
3
+ "version": "0.5.11",
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": {