@sprlab/wccompiler 0.5.5 → 0.5.7
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/bin/wcc.js +1 -1
- package/lib/codegen.js +9 -4
- package/lib/reactive-runtime.js +7 -0
- package/lib/tree-walker.js +8 -0
- package/package.json +1 -1
package/bin/wcc.js
CHANGED
|
@@ -19,7 +19,7 @@ async function build(config, cwd) {
|
|
|
19
19
|
const __filename = fileURLToPath(import.meta.url);
|
|
20
20
|
const __dirname = dirname(__filename);
|
|
21
21
|
const { reactiveRuntime } = await import('../lib/reactive-runtime.js');
|
|
22
|
-
const signalsContent = reactiveRuntime.trim().replace(/^/gm, '') + '\nexport { __signal, __computed, __effect, __batch };\n';
|
|
22
|
+
const signalsContent = reactiveRuntime.trim().replace(/^/gm, '') + '\nexport { __signal, __computed, __effect, __batch, __untrack };\n';
|
|
23
23
|
const signalsDest = join(outputDir, '__wcc-signals.js');
|
|
24
24
|
writeFileSync(signalsDest, signalsContent);
|
|
25
25
|
|
package/lib/codegen.js
CHANGED
|
@@ -541,6 +541,7 @@ export function generateComponent(parseResult, options = {}) {
|
|
|
541
541
|
const usedRuntime = new Set(['__signal']); // always need __signal
|
|
542
542
|
if (computeds.length > 0) usedRuntime.add('__computed');
|
|
543
543
|
if (effects.length > 0 || bindings.length > 0 || showBindings.length > 0 || modelBindings.length > 0 || attrBindings.length > 0 || ifBlocks.length > 0 || forBlocks.length > 0 || watchers.length > 0 || childComponents.length > 0 || slots.some(s => s.slotProps.length > 0)) usedRuntime.add('__effect');
|
|
544
|
+
if (watchers.length > 0) usedRuntime.add('__untrack');
|
|
544
545
|
const imports = [...usedRuntime].join(', ');
|
|
545
546
|
lines.push(`import { ${imports} } from '${options.runtimeImportPath}';`);
|
|
546
547
|
} else {
|
|
@@ -848,10 +849,12 @@ export function generateComponent(parseResult, options = {}) {
|
|
|
848
849
|
lines.push(` const ${w.newParam} = ${watchRef};`);
|
|
849
850
|
lines.push(` if (this.__prev_${w.target} !== undefined) {`);
|
|
850
851
|
lines.push(` const ${w.oldParam} = this.__prev_${w.target};`);
|
|
852
|
+
lines.push(' __untrack(() => {');
|
|
851
853
|
const bodyLines = body.split('\n');
|
|
852
854
|
for (const line of bodyLines) {
|
|
853
|
-
lines.push(`
|
|
855
|
+
lines.push(` ${line}`);
|
|
854
856
|
}
|
|
857
|
+
lines.push(' });');
|
|
855
858
|
lines.push(' }');
|
|
856
859
|
lines.push(` this.__prev_${w.target} = ${w.newParam};`);
|
|
857
860
|
lines.push(' }));');
|
|
@@ -863,10 +866,12 @@ export function generateComponent(parseResult, options = {}) {
|
|
|
863
866
|
lines.push(` const ${w.newParam} = ${getterExpr};`);
|
|
864
867
|
lines.push(` if (this.${prevName} !== undefined) {`);
|
|
865
868
|
lines.push(` const ${w.oldParam} = this.${prevName};`);
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
+
lines.push(' __untrack(() => {');
|
|
870
|
+
const bodyLines2 = body.split('\n');
|
|
871
|
+
for (const line of bodyLines2) {
|
|
872
|
+
lines.push(` ${line}`);
|
|
869
873
|
}
|
|
874
|
+
lines.push(' });');
|
|
870
875
|
lines.push(' }');
|
|
871
876
|
lines.push(` this.${prevName} = ${w.newParam};`);
|
|
872
877
|
lines.push(' }));');
|
package/lib/reactive-runtime.js
CHANGED
package/lib/tree-walker.js
CHANGED
|
@@ -74,6 +74,14 @@ export function walkTree(rootEl, signalNames, computedNames, propNames = new Set
|
|
|
74
74
|
if (node.nodeType === 1) {
|
|
75
75
|
const el = /** @type {Element} */ (node);
|
|
76
76
|
|
|
77
|
+
// Skip <template #name> elements — they are slot content passed to child components
|
|
78
|
+
// Their interpolations are resolved by the provider, not the consumer
|
|
79
|
+
if (el.tagName === 'TEMPLATE') {
|
|
80
|
+
for (const attr of Array.from(el.attributes)) {
|
|
81
|
+
if (attr.name.startsWith('#')) return;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
77
85
|
// Detect <slot> elements — replace with <span data-slot="..."> placeholder
|
|
78
86
|
if (el.tagName === 'SLOT') {
|
|
79
87
|
const slotName = el.getAttribute('name') || '';
|
package/package.json
CHANGED