@sprlab/wccompiler 0.5.10 → 0.5.12

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
@@ -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
 
@@ -67,11 +67,16 @@ function __effect(fn) {
67
67
  let _active = true;
68
68
  const run = () => {
69
69
  if (!_active) return;
70
- if (typeof _cleanup === 'function') _cleanup();
71
- const prev = __currentEffect;
72
- __currentEffect = run;
73
- _cleanup = fn();
74
- __currentEffect = prev;
70
+ try {
71
+ if (typeof _cleanup === 'function') _cleanup();
72
+ const prev = __currentEffect;
73
+ __currentEffect = run;
74
+ _cleanup = fn();
75
+ __currentEffect = prev;
76
+ } catch (e) {
77
+ console.error('[wcc] Effect error:', e);
78
+ _active = false;
79
+ }
75
80
  };
76
81
  run();
77
82
  return () => { _active = false; if (typeof _cleanup === 'function') _cleanup(); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprlab/wccompiler",
3
- "version": "0.5.10",
3
+ "version": "0.5.12",
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": {