(value: T): T;
// Auto imports
const $effect: typeof solid.createEffect;
const $computed: typeof solid.createComputed;
const $renderEffect: typeof solid.createRenderEffect;
const $useContext: typeof solid.useContext;
const $createContext: typeof solid.createContext;
const $uid: typeof solid.createUniqueId;
const $root: typeof solid.createRoot;
const $resource: typeof solid.createResource;
const $merge: typeof solid.mergeProps;
const $reaction: typeof solid.createReaction;
const $mount: typeof solid.onMount;
// @deprecated
const $error: typeof solid.onError;
const $cleanup: typeof solid.onCleanup;
const $catchError: typeof solid.catchError;
const $startTransition: typeof solid.startTransition;
const $useTransition: typeof solid.useTransition;
const $owner: typeof solid.getOwner;
const $runWithOwner: typeof solid.runWithOwner;
// store
const $store: typeof solidStore.createStore;
const $mutable: typeof solidStore.createMutable;
const $produce: typeof solidStore.produce;
const $reconcile: typeof solidStore.reconcile;
const $unwrap: typeof solidStore.unwrap;
// components
const For: typeof solid.For;
const Show: typeof solid.Show;
const Switch: typeof solid.Switch;
const Match: typeof solid.Match;
const Index: typeof solid.Index;
const ErrorBoundary: typeof solid.ErrorBoundary;
const Suspense: typeof solid.Suspense;
const SuspenseList: typeof solid.SuspenseList;
const Dynamic: typeof solidWeb.Dynamic;
const Portal: typeof solidWeb.Portal;
const Assets: typeof solidWeb.Assets;
const HydrationScript: typeof solidWeb.HydrationScript;
const NoHydration: typeof solidWeb.NoHydration;
function $component(
Comp: (props: P) => solid.JSX.Element,
): (props: P) => solid.JSX.Element;
}
type Props = T extends (props: infer P) => solid.JSX.Element ? P : never;
declare module 'solid-js' {
// biome-ignore lint/style/noNamespace:
namespace JSX {
interface IntrinsicElements {
'solid:error-boundary': Props;
'solid:suspense': Props;
'solid:suspense-list': Props;
'solid:portal': Props;
'solid:assets': Props;
'solid:hydration-script': Props;
'solid:no-hydration': Props;
}
}
}
================================================
FILE: packages/core/test/__snapshots__/ctf.test.ts.snap
================================================
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`ctf > $component > should transform $component 1`] = `
"import { splitProps as _splitProps } from "solid-js";
props_1 => {
const prop_1 = () => props_1.a,
prop_2 = () => prop_1().b,
prop_3 = () => prop_1().c,
other_2 = _splitProps(prop_1(), ["b", "c"])[1],
prop_4 = () => props_1.b,
def_1 = defaultD,
prop_5 = () => {
const value_1 = prop_4().d;
return value_1 === void 0 ? def_1 : value_1;
},
def_2 = defaultE,
prop_6 = () => {
const value_2 = prop_4().e;
return value_2 === void 0 ? def_2 : value_2;
},
other_3 = _splitProps(prop_4(), ["d", "e"])[1],
other_1 = _splitProps(props_1, ["a", "b"])[1];
};"
`;
exports[`ctf > $component > should transform $component bindings 1`] = `
"import { splitProps as _splitProps } from "solid-js";
import { createEffect as _createEffect } from "solid-js";
props_1 => {
const prop_1 = () => props_1.a,
prop_2 = () => prop_1().b,
prop_3 = () => prop_1().c,
other_2 = _splitProps(prop_1(), ["b", "c"])[1],
prop_4 = () => props_1.b,
def_1 = defaultD,
prop_5 = () => {
const value_1 = prop_4().d;
return value_1 === void 0 ? def_1 : value_1;
},
def_2 = defaultE,
prop_6 = () => {
const value_2 = prop_4().e;
return value_2 === void 0 ? def_2 : value_2;
},
other_3 = _splitProps(prop_4(), ["d", "e"])[1],
other_1 = _splitProps(props_1, ["a", "b"])[1];
_createEffect(() => {
console.log(prop_2(), prop_3());
});
_createEffect(() => {
console.log(prop_5(), prop_6());
});
_createEffect(() => {
console.log(other_1);
});
};"
`;
exports[`ctf > $component > should transform $component bindings 2`] = `
"import { splitProps as _splitProps } from "solid-js";
import { createEffect as _createEffect } from "solid-js";
props_1 => {
const prop_1 = () => props_1.a,
prop_2 = () => prop_1().b,
prop_3 = () => prop_1().c,
other_2 = _splitProps(prop_1(), ["b", "c"])[1],
prop_4 = () => props_1.b,
def_1 = defaultD,
prop_5 = () => {
const value_1 = prop_4().d;
return value_1 === void 0 ? def_1 : value_1;
},
def_2 = defaultE,
prop_6 = () => {
const value_2 = prop_4().e;
return value_2 === void 0 ? def_2 : value_2;
},
other_3 = _splitProps(prop_4(), ["d", "e"])[1],
other_1 = _splitProps(props_1, ["a", "b"])[1];
_createEffect(() => {
console.log({
b: prop_2()
}, {
c: prop_3()
});
});
_createEffect(() => {
console.log({
d: prop_5()
}, {
e: prop_6()
});
});
_createEffect(() => {
console.log(other_1);
});
};"
`;
exports[`ctf > $component > should transform $component bindings on $get 1`] = `
"import { splitProps as _splitProps } from "solid-js";
import { createEffect as _createEffect } from "solid-js";
props_1 => {
const prop_1 = () => props_1.a,
prop_2 = () => prop_1().b,
prop_3 = () => prop_1().c,
other_2 = _splitProps(prop_1(), ["b", "c"])[1],
prop_4 = () => props_1.b,
def_1 = defaultD,
prop_5 = () => {
const value_1 = prop_4().d;
return value_1 === void 0 ? def_1 : value_1;
},
def_2 = defaultE,
prop_6 = () => {
const value_2 = prop_4().e;
return value_2 === void 0 ? def_2 : value_2;
},
other_3 = _splitProps(prop_4(), ["d", "e"])[1],
other_1 = _splitProps(props_1, ["a", "b"])[1];
_createEffect(() => {
console.log(prop_2, prop_3);
});
_createEffect(() => {
console.log(prop_5, prop_6);
});
_createEffect(() => {
console.log(other_1);
});
};"
`;
exports[`ctf > $component > should transform $component bindings on $getter 1`] = `
"const proto_1 = {
get b() {
return this.__$get__b();
}
},
proto_2 = {
get c() {
return this.__$get__c();
}
},
proto_3 = {
get d() {
return this.__$get__d();
}
},
proto_4 = {
get e() {
return this.__$get__e();
}
};
import { splitProps as _splitProps } from "solid-js";
import { createEffect as _createEffect } from "solid-js";
props_1 => {
const prop_1 = () => props_1.a,
prop_2 = () => prop_1().b,
prop_3 = () => prop_1().c,
other_2 = _splitProps(prop_1(), ["b", "c"])[1],
prop_4 = () => props_1.b,
def_1 = defaultD,
prop_5 = () => {
const value_1 = prop_4().d;
return value_1 === void 0 ? def_1 : value_1;
},
def_2 = defaultE,
prop_6 = () => {
const value_2 = prop_4().e;
return value_2 === void 0 ? def_2 : value_2;
},
other_3 = _splitProps(prop_4(), ["d", "e"])[1],
other_1 = _splitProps(props_1, ["a", "b"])[1];
_createEffect(() => {
console.log({
__proto__: proto_1,
__$get__b: prop_2
}, {
__proto__: proto_2,
__$get__c: prop_3
});
});
_createEffect(() => {
console.log({
__proto__: proto_3,
__$get__d: prop_5
}, {
__proto__: proto_4,
__$get__e: prop_6
});
});
_createEffect(() => {
console.log(other_1);
});
};"
`;
exports[`ctf > $component > should transform $component bindings on $property 1`] = `
"const proto_1 = {
get b() {
return this.__$get__b();
}
},
proto_2 = {
get c() {
return this.__$get__c();
}
},
proto_3 = {
get d() {
return this.__$get__d();
}
},
proto_4 = {
get e() {
return this.__$get__e();
}
};
import { splitProps as _splitProps } from "solid-js";
import { createEffect as _createEffect } from "solid-js";
props_1 => {
const prop_1 = () => props_1.a,
prop_2 = () => prop_1().b,
prop_3 = () => prop_1().c,
other_2 = _splitProps(prop_1(), ["b", "c"])[1],
prop_4 = () => props_1.b,
def_1 = defaultD,
prop_5 = () => {
const value_1 = prop_4().d;
return value_1 === void 0 ? def_1 : value_1;
},
def_2 = defaultE,
prop_6 = () => {
const value_2 = prop_4().e;
return value_2 === void 0 ? def_2 : value_2;
},
other_3 = _splitProps(prop_4(), ["d", "e"])[1],
other_1 = _splitProps(props_1, ["a", "b"])[1];
_createEffect(() => {
console.log({
__proto__: proto_1,
__$get__b: prop_2
}, {
__proto__: proto_2,
__$get__c: prop_3
});
});
_createEffect(() => {
console.log({
__proto__: proto_3,
__$get__d: prop_5
}, {
__proto__: proto_4,
__$get__e: prop_6
});
});
_createEffect(() => {
console.log(other_1);
});
};"
`;
exports[`ctf > $component > should transform $component bindings on $refMemo 1`] = `
"import { splitProps as _splitProps } from "solid-js";
import { createEffect as _createEffect } from "solid-js";
props_1 => {
const prop_1 = () => props_1.a,
prop_2 = () => prop_1().b,
prop_3 = () => prop_1().c,
other_2 = _splitProps(prop_1(), ["b", "c"])[1],
prop_4 = () => props_1.b,
def_1 = defaultD,
prop_5 = () => {
const value_1 = prop_4().d;
return value_1 === void 0 ? def_1 : value_1;
},
def_2 = defaultE,
prop_6 = () => {
const value_2 = prop_4().e;
return value_2 === void 0 ? def_2 : value_2;
},
other_3 = _splitProps(prop_4(), ["d", "e"])[1],
other_1 = _splitProps(props_1, ["a", "b"])[1];
_createEffect(() => {
console.log(prop_2, prop_3);
});
_createEffect(() => {
console.log(prop_5, prop_6);
});
_createEffect(() => {
console.log(other_1);
});
};"
`;
exports[`ctf > $derefMemo > should transform $derefMemo 1`] = `"const message_1 = () => \`Count: \${count}\`;"`;
exports[`ctf > $derefMemo > should transform $derefMemo bindings 1`] = `
"const message_1 = () => \`Count: \${count}\`;
const value = message_1();"
`;
exports[`ctf > $derefMemo > should transform $derefMemo bindings 2`] = `
"const message_1 = () => \`Count: \${count}\`;
const value = {
message: message_1()
};"
`;
exports[`ctf > $derefMemo > should transform $derefMemo on $get 1`] = `
"const message_1 = () => \`Count: \${count}\`;
const value = message_1;"
`;
exports[`ctf > $derefMemo > should transform $derefMemo on $getter 1`] = `
"const proto_1 = {
get message() {
return this.__$get__message();
}
};
const message_1 = () => \`Count: \${count}\`;
const value = {
__proto__: proto_1,
__$get__message: message_1
};"
`;
exports[`ctf > $derefMemo > should transform $derefMemo on $property 1`] = `
"const proto_1 = {
get message() {
return this.__$get__message();
}
};
const message_1 = () => \`Count: \${count}\`;
const value = {
__proto__: proto_1,
__$get__message: message_1
};"
`;
exports[`ctf > $derefMemo > should transform $derefMemo on $refMemo 1`] = `
"const message_1 = () => \`Count: \${count}\`;
const value = message_1;"
`;
exports[`ctf > $derefSignal > should transform $derefSignal 1`] = `"const [count_1, setcount_1] = createSignal(0);"`;
exports[`ctf > $derefSignal > should transform $derefSignal bindings 1`] = `
"const [count_1, setcount_1] = createSignal(0);
const value = count_1();"
`;
exports[`ctf > $derefSignal > should transform $derefSignal bindings 2`] = `
"const [count_1, setcount_1] = createSignal(0);
const value = {
count: count_1()
};"
`;
exports[`ctf > $derefSignal > should transform $derefSignal bindings for $get 1`] = `
"const [count_1, setcount_1] = createSignal(0);
const value = count_1;"
`;
exports[`ctf > $derefSignal > should transform $derefSignal bindings for $getter 1`] = `
"const proto_1 = {
get count() {
return this.__$get__count();
}
};
const [count_1, setcount_1] = createSignal(0);
const value = {
__proto__: proto_1,
__$get__count: setcount_1
};"
`;
exports[`ctf > $derefSignal > should transform $derefSignal bindings for $property 1`] = `
"const proto_1 = {
get count() {
return this.__$get__count();
},
set count(param_1) {
this.__$set__count(() => param_1);
}
};
const [count_1, setcount_1] = createSignal(0);
const value = {
__proto__: proto_1,
__$get__count: count_1,
__$set__count: setcount_1
};"
`;
exports[`ctf > $derefSignal > should transform $derefSignal bindings for $refSignal 1`] = `
"const [count_1, setcount_1] = createSignal(0);
const value = [count_1, setcount_1];"
`;
exports[`ctf > $derefSignal > should transform $derefSignal bindings for $set 1`] = `
"const [count_1, setcount_1] = createSignal(0);
const value = setcount_1;"
`;
exports[`ctf > $derefSignal > should transform $derefSignal bindings for $setter 1`] = `
"const proto_1 = {
set count(param_1) {
this.__$set__count(() => param_1);
}
};
const [count_1, setcount_1] = createSignal(0);
const value = {
__proto__: proto_1,
__$set__count: setcount_1
};"
`;
exports[`ctf > $destructure > should transform $destructure 1`] = `
"import { splitProps as _splitProps } from "solid-js";
let prop_1 = () => x.a,
prop_2 = () => prop_1().b,
prop_3 = () => prop_1().c,
other_2 = _splitProps(prop_1(), ["b", "c"])[1],
prop_4 = () => x.b,
def_1 = defaultD,
prop_5 = () => {
const value_1 = prop_4().d;
return value_1 === void 0 ? def_1 : value_1;
},
def_2 = defaultE,
prop_6 = () => {
const value_2 = prop_4().e;
return value_2 === void 0 ? def_2 : value_2;
},
other_3 = _splitProps(prop_4(), ["d", "e"])[1],
other_1 = _splitProps(x, ["a", "b"])[1];"
`;
exports[`ctf > $destructure > should transform $destructure bindings 1`] = `
"import { splitProps as _splitProps } from "solid-js";
import { createEffect as _createEffect } from "solid-js";
let prop_1 = () => x.a,
prop_2 = () => prop_1().b,
prop_3 = () => prop_1().c,
other_2 = _splitProps(prop_1(), ["b", "c"])[1],
prop_4 = () => x.b,
def_1 = defaultD,
prop_5 = () => {
const value_1 = prop_4().d;
return value_1 === void 0 ? def_1 : value_1;
},
def_2 = defaultE,
prop_6 = () => {
const value_2 = prop_4().e;
return value_2 === void 0 ? def_2 : value_2;
},
other_3 = _splitProps(prop_4(), ["d", "e"])[1],
other_1 = _splitProps(x, ["a", "b"])[1];
_createEffect(() => {
console.log(prop_2(), prop_3());
});
_createEffect(() => {
console.log(prop_5(), prop_6());
});
_createEffect(() => {
console.log(other_1);
});"
`;
exports[`ctf > $destructure > should transform $destructure bindings 2`] = `
"import { splitProps as _splitProps } from "solid-js";
import { createEffect as _createEffect } from "solid-js";
let prop_1 = () => x.a,
prop_2 = () => prop_1().b,
prop_3 = () => prop_1().c,
other_2 = _splitProps(prop_1(), ["b", "c"])[1],
prop_4 = () => x.b,
def_1 = defaultD,
prop_5 = () => {
const value_1 = prop_4().d;
return value_1 === void 0 ? def_1 : value_1;
},
def_2 = defaultE,
prop_6 = () => {
const value_2 = prop_4().e;
return value_2 === void 0 ? def_2 : value_2;
},
other_3 = _splitProps(prop_4(), ["d", "e"])[1],
other_1 = _splitProps(x, ["a", "b"])[1];
_createEffect(() => {
console.log({
b: prop_2()
}, {
c: prop_3()
});
});
_createEffect(() => {
console.log({
d: prop_5()
}, {
e: prop_6()
});
});
_createEffect(() => {
console.log(other_1);
});"
`;
exports[`ctf > $destructure > should transform $destructure bindings on $get 1`] = `
"import { splitProps as _splitProps } from "solid-js";
import { createEffect as _createEffect } from "solid-js";
let prop_1 = () => x.a,
prop_2 = () => prop_1().b,
prop_3 = () => prop_1().c,
other_2 = _splitProps(prop_1(), ["b", "c"])[1],
prop_4 = () => x.b,
def_1 = defaultD,
prop_5 = () => {
const value_1 = prop_4().d;
return value_1 === void 0 ? def_1 : value_1;
},
def_2 = defaultE,
prop_6 = () => {
const value_2 = prop_4().e;
return value_2 === void 0 ? def_2 : value_2;
},
other_3 = _splitProps(prop_4(), ["d", "e"])[1],
other_1 = _splitProps(x, ["a", "b"])[1];
_createEffect(() => {
console.log(prop_2, prop_3);
});
_createEffect(() => {
console.log(prop_5, prop_6);
});
_createEffect(() => {
console.log(other_1);
});"
`;
exports[`ctf > $destructure > should transform $destructure bindings on $getter 1`] = `
"const proto_1 = {
get b() {
return this.__$get__b();
}
},
proto_2 = {
get c() {
return this.__$get__c();
}
},
proto_3 = {
get d() {
return this.__$get__d();
}
},
proto_4 = {
get e() {
return this.__$get__e();
}
};
import { splitProps as _splitProps } from "solid-js";
import { createEffect as _createEffect } from "solid-js";
let prop_1 = () => x.a,
prop_2 = () => prop_1().b,
prop_3 = () => prop_1().c,
other_2 = _splitProps(prop_1(), ["b", "c"])[1],
prop_4 = () => x.b,
def_1 = defaultD,
prop_5 = () => {
const value_1 = prop_4().d;
return value_1 === void 0 ? def_1 : value_1;
},
def_2 = defaultE,
prop_6 = () => {
const value_2 = prop_4().e;
return value_2 === void 0 ? def_2 : value_2;
},
other_3 = _splitProps(prop_4(), ["d", "e"])[1],
other_1 = _splitProps(x, ["a", "b"])[1];
_createEffect(() => {
console.log({
__proto__: proto_1,
__$get__b: prop_2
}, {
__proto__: proto_2,
__$get__c: prop_3
});
});
_createEffect(() => {
console.log({
__proto__: proto_3,
__$get__d: prop_5
}, {
__proto__: proto_4,
__$get__e: prop_6
});
});
_createEffect(() => {
console.log(other_1);
});"
`;
exports[`ctf > $destructure > should transform $destructure bindings on $property 1`] = `
"const proto_1 = {
get b() {
return this.__$get__b();
}
},
proto_2 = {
get c() {
return this.__$get__c();
}
},
proto_3 = {
get d() {
return this.__$get__d();
}
},
proto_4 = {
get e() {
return this.__$get__e();
}
};
import { splitProps as _splitProps } from "solid-js";
import { createEffect as _createEffect } from "solid-js";
let prop_1 = () => x.a,
prop_2 = () => prop_1().b,
prop_3 = () => prop_1().c,
other_2 = _splitProps(prop_1(), ["b", "c"])[1],
prop_4 = () => x.b,
def_1 = defaultD,
prop_5 = () => {
const value_1 = prop_4().d;
return value_1 === void 0 ? def_1 : value_1;
},
def_2 = defaultE,
prop_6 = () => {
const value_2 = prop_4().e;
return value_2 === void 0 ? def_2 : value_2;
},
other_3 = _splitProps(prop_4(), ["d", "e"])[1],
other_1 = _splitProps(x, ["a", "b"])[1];
_createEffect(() => {
console.log({
__proto__: proto_1,
__$get__b: prop_2
}, {
__proto__: proto_2,
__$get__c: prop_3
});
});
_createEffect(() => {
console.log({
__proto__: proto_3,
__$get__d: prop_5
}, {
__proto__: proto_4,
__$get__e: prop_6
});
});
_createEffect(() => {
console.log(other_1);
});"
`;
exports[`ctf > $destructure > should transform $destructure bindings on $refMemo 1`] = `
"import { splitProps as _splitProps } from "solid-js";
import { createEffect as _createEffect } from "solid-js";
let prop_1 = () => x.a,
prop_2 = () => prop_1().b,
prop_3 = () => prop_1().c,
other_2 = _splitProps(prop_1(), ["b", "c"])[1],
prop_4 = () => x.b,
def_1 = defaultD,
prop_5 = () => {
const value_1 = prop_4().d;
return value_1 === void 0 ? def_1 : value_1;
},
def_2 = defaultE,
prop_6 = () => {
const value_2 = prop_4().e;
return value_2 === void 0 ? def_2 : value_2;
},
other_3 = _splitProps(prop_4(), ["d", "e"])[1],
other_1 = _splitProps(x, ["a", "b"])[1];
_createEffect(() => {
console.log(prop_2, prop_3);
});
_createEffect(() => {
console.log(prop_5, prop_6);
});
_createEffect(() => {
console.log(other_1);
});"
`;
exports[`ctf > $effect, $renderEffect, $computed > should transform $effect, $renderEffect, $computed 1`] = `
"import { createRenderEffect as _createRenderEffect } from "solid-js";
import { createComputed as _createComputed } from "solid-js";
import { createEffect as _createEffect } from "solid-js";
import { createSignal as _createSignal } from "solid-js";
let [x_1, setx_1] = _createSignal(0);
_createEffect(() => {
console.log('Count', x_1());
});
_createComputed(() => {
console.log('Count', x_1());
});
_createRenderEffect(() => {
console.log('Count', x_1());
});"
`;
exports[`ctf > $memo > should transform $memo 1`] = `
"import { createMemo as _createMemo } from "solid-js";
const message_1 = _createMemo(() => \`Count: \${count}\`);"
`;
exports[`ctf > $memo > should transform $memo bindings 1`] = `
"import { createMemo as _createMemo } from "solid-js";
const message_1 = _createMemo(() => \`Count: \${count}\`);
const value = message_1();"
`;
exports[`ctf > $memo > should transform $memo bindings 2`] = `
"import { createMemo as _createMemo } from "solid-js";
const message_1 = _createMemo(() => \`Count: \${count}\`);
const value = {
message: message_1()
};"
`;
exports[`ctf > $memo > should transform $memo on $get 1`] = `
"import { createMemo as _createMemo } from "solid-js";
const message_1 = _createMemo(() => \`Count: \${count}\`);
const value = message_1;"
`;
exports[`ctf > $memo > should transform $memo on $getter 1`] = `
"const proto_1 = {
get message() {
return this.__$get__message();
}
};
import { createMemo as _createMemo } from "solid-js";
const message_1 = _createMemo(() => \`Count: \${count}\`);
const value = {
__proto__: proto_1,
__$get__message: message_1
};"
`;
exports[`ctf > $memo > should transform $memo on $property 1`] = `
"const proto_1 = {
get message() {
return this.__$get__message();
}
};
import { createMemo as _createMemo } from "solid-js";
const message_1 = _createMemo(() => \`Count: \${count}\`);
const value = {
__proto__: proto_1,
__$get__message: message_1
};"
`;
exports[`ctf > $memo > should transform $memo on $refMemo 1`] = `
"import { createMemo as _createMemo } from "solid-js";
const message_1 = _createMemo(() => \`Count: \${count}\`);
const value = message_1;"
`;
exports[`ctf > $signal > should transform $signal 1`] = `
"import { createSignal as _createSignal } from "solid-js";
let [count_1, setcount_1] = _createSignal(0);"
`;
exports[`ctf > $signal > should transform $signal bindings 1`] = `
"import { createSignal as _createSignal } from "solid-js";
let [count_1, setcount_1] = _createSignal(0);
const value = count_1();"
`;
exports[`ctf > $signal > should transform $signal bindings 2`] = `
"import { createSignal as _createSignal } from "solid-js";
let [count_1, setcount_1] = _createSignal(0);
const value = {
count: count_1()
};"
`;
exports[`ctf > $signal > should transform $signal bindings 3`] = `
"import { createSignal as _createSignal } from "solid-js";
let [count_1, setcount_1] = _createSignal(0);
async function exampleA() {
const tmp_1 = await asyncValue();
setcount_1(() => tmp_1);
}
function* exampleB() {
const tmp_2 = yield asyncValue();
setcount_1(() => tmp_2);
}
async function* exampleC() {
const tmp_3 = yield asyncValue();
setcount_1(() => tmp_3);
}
const example = async () => {
const tmp_4 = await asyncValue();
return setcount_1(() => tmp_4);
};"
`;
exports[`ctf > $signal > should transform $signal bindings for $get 1`] = `
"import { createSignal as _createSignal } from "solid-js";
let [count_1, setcount_1] = _createSignal(0);
const value = count_1;"
`;
exports[`ctf > $signal > should transform $signal bindings for $getter 1`] = `
"const proto_1 = {
get count() {
return this.__$get__count();
}
};
import { createSignal as _createSignal } from "solid-js";
let [count_1, setcount_1] = _createSignal(0);
const value = {
__proto__: proto_1,
__$get__count: setcount_1
};"
`;
exports[`ctf > $signal > should transform $signal bindings for $property 1`] = `
"const proto_1 = {
get count() {
return this.__$get__count();
},
set count(param_1) {
this.__$set__count(() => param_1);
}
};
import { createSignal as _createSignal } from "solid-js";
let [count_1, setcount_1] = _createSignal(0);
const value = {
__proto__: proto_1,
__$get__count: count_1,
__$set__count: setcount_1
};"
`;
exports[`ctf > $signal > should transform $signal bindings for $refSignal 1`] = `
"import { createSignal as _createSignal } from "solid-js";
let [count_1, setcount_1] = _createSignal(0);
const value = [count_1, setcount_1];"
`;
exports[`ctf > $signal > should transform $signal bindings for $set 1`] = `
"import { createSignal as _createSignal } from "solid-js";
let [count_1, setcount_1] = _createSignal(0);
const value = setcount_1;"
`;
exports[`ctf > $signal > should transform $signal bindings for $setter 1`] = `
"const proto_1 = {
set count(param_1) {
this.__$set__count(() => param_1);
}
};
import { createSignal as _createSignal } from "solid-js";
let [count_1, setcount_1] = _createSignal(0);
const value = {
__proto__: proto_1,
__$set__count: setcount_1
};"
`;
exports[`ctf > variable shadowing > should respect variable shadowing 1`] = `
"import { createSignal as _createSignal } from "solid-js";
const [selected_1, setselected_1] = _createSignal('root');
{
const selected = 'local';
console.log(selected); // 'local'
{
console.log(selected); // 'local'
{
const [selected_2, setselected_2] = _createSignal('inner');
console.log(selected_2()); // 'inner'
{
console.log(selected_2()); // 'inner'
}
}
}
}"
`;
================================================
FILE: packages/core/test/ctf.test.ts
================================================
import * as babel from '@babel/core';
import { describe, expect, it } from 'vitest';
import plugin from '../babel';
async function compile(code: string, dev?: boolean): Promise {
const result = await babel.transformAsync(code, {
plugins: [[plugin, { dev }]],
parserOpts: {
plugins: ['jsx'],
},
});
return result?.code ?? '';
}
describe('ctf', () => {
describe('$signal', () => {
it('should transform $signal', async () => {
expect(await compile('let count = $signal(0);')).toMatchSnapshot();
});
it('should transform $signal bindings', async () => {
let code = `
let count = $signal(0);
const value = count;
`;
expect(await compile(code)).toMatchSnapshot();
code = `
let count = $signal(0);
const value = { count };
`;
expect(await compile(code)).toMatchSnapshot();
code = `
let count = $signal(0);
async function exampleA() {
count = await asyncValue();
}
function* exampleB() {
count = yield asyncValue();
}
async function* exampleC() {
count = yield asyncValue();
}
const example = async () => (count = await asyncValue());
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $signal bindings for $set', async () => {
const code = `
let count = $signal(0);
const value = $set(count);
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $signal bindings for $get', async () => {
const code = `
let count = $signal(0);
const value = $get(count);
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $signal bindings for $refSignal', async () => {
const code = `
let count = $signal(0);
const value = $refSignal(count);
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $signal bindings for $getter', async () => {
const code = `
let count = $signal(0);
const value = { count: $getter(count) };
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $signal bindings for $setter', async () => {
const code = `
let count = $signal(0);
const value = { count: $setter(count) };
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $signal bindings for $property', async () => {
const code = `
let count = $signal(0);
const value = { count: $property(count) };
`;
expect(await compile(code)).toMatchSnapshot();
});
});
describe('$memo', () => {
it('should transform $memo', async () => {
const code = 'const message = $memo(`Count: ${count}`);';
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $memo bindings', async () => {
let code = `
const message = $memo(\`Count: \${count}\`)
const value = message;
`;
expect(await compile(code)).toMatchSnapshot();
code = `
const message = $memo(\`Count: \${count}\`)
const value = { message };
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $memo on $get', async () => {
const code = `
const message = $memo(\`Count: \${count}\`)
const value = $get(message);
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $memo on $refMemo', async () => {
const code = `
const message = $memo(\`Count: \${count}\`)
const value = $refMemo(message);
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $memo on $getter', async () => {
const code = `
const message = $memo(\`Count: \${count}\`)
const value = { message: $getter(message) };
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $memo on $property', async () => {
const code = `
const message = $memo(\`Count: \${count}\`)
const value = { message: $property(message) };
`;
expect(await compile(code)).toMatchSnapshot();
});
});
describe('$derefSignal', () => {
it('should transform $derefSignal', async () => {
const code = `
const count = $derefSignal(createSignal(0));
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $derefSignal bindings', async () => {
let code = `
const count = $derefSignal(createSignal(0));
const value = count;
`;
expect(await compile(code)).toMatchSnapshot();
code = `
const count = $derefSignal(createSignal(0));
const value = { count };
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $derefSignal bindings for $set', async () => {
const code = `
const count = $derefSignal(createSignal(0));
const value = $set(count);
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $derefSignal bindings for $get', async () => {
const code = `
const count = $derefSignal(createSignal(0));
const value = $get(count);
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $derefSignal bindings for $refSignal', async () => {
const code = `
const count = $derefSignal(createSignal(0));
const value = $refSignal(count);
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $derefSignal bindings for $getter', async () => {
const code = `
const count = $derefSignal(createSignal(0));
const value = { count: $getter(count) };
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $derefSignal bindings for $setter', async () => {
const code = `
const count = $derefSignal(createSignal(0));
const value = { count: $setter(count) };
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $derefSignal bindings for $property', async () => {
const code = `
const count = $derefSignal(createSignal(0));
const value = { count: $property(count) };
`;
expect(await compile(code)).toMatchSnapshot();
});
});
describe('$derefMemo', () => {
it('should transform $derefMemo', async () => {
const code = `
const message = $derefMemo(() => \`Count: \${count}\`);
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $derefMemo bindings', async () => {
let code = `
const message = $derefMemo(() => \`Count: \${count}\`);
const value = message;
`;
expect(await compile(code)).toMatchSnapshot();
code = `
const message = $derefMemo(() => \`Count: \${count}\`);
const value = { message };
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $derefMemo on $get', async () => {
const code = `
const message = $derefMemo(() => \`Count: \${count}\`);
const value = $get(message);
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $derefMemo on $refMemo', async () => {
const code = `
const message = $derefMemo(() => \`Count: \${count}\`);
const value = $refMemo(message);
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $derefMemo on $getter', async () => {
const code = `
const message = $derefMemo(() => \`Count: \${count}\`);
const value = { message: $getter(message) };
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $derefMemo on $property', async () => {
const code = `
const message = $derefMemo(() => \`Count: \${count}\`);
const value = { message: $property(message) };
`;
expect(await compile(code)).toMatchSnapshot();
});
});
describe('$destructure', () => {
it('should transform $destructure', async () => {
const code = `
let { a: { b, c }, b: { d = defaultD, e = defaultE }, ...f } = $destructure(x);
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $destructure bindings', async () => {
let code = `
let { a: { b, c }, b: { d = defaultD, e = defaultE }, ...f } = $destructure(x);
effect: {
console.log(b, c);
}
effect: {
console.log(d, e);
}
effect: {
console.log(f);
}
`;
expect(await compile(code)).toMatchSnapshot();
code = `
let { a: { b, c }, b: { d = defaultD, e = defaultE }, ...f } = $destructure(x);
effect: {
console.log({ b }, { c });
}
effect: {
console.log({ d }, { e });
}
effect: {
console.log(f);
}
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $destructure bindings on $get', async () => {
const code = `
let { a: { b, c }, b: { d = defaultD, e = defaultE }, ...f } = $destructure(x);
effect: {
console.log($get(b), $get(c));
}
effect: {
console.log($get(d), $get(e));
}
effect: {
console.log(f);
}
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $destructure bindings on $refMemo', async () => {
const code = `
let { a: { b, c }, b: { d = defaultD, e = defaultE }, ...f } = $destructure(x);
effect: {
console.log($refMemo(b), $refMemo(c));
}
effect: {
console.log($refMemo(d), $refMemo(e));
}
effect: {
console.log(f);
}
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $destructure bindings on $getter', async () => {
const code = `
let { a: { b, c }, b: { d = defaultD, e = defaultE }, ...f } = $destructure(x);
effect: {
console.log({ b: $getter(b) }, { c: $getter(c) });
}
effect: {
console.log({ d: $getter(d) }, { e: $getter(e) });
}
effect: {
console.log(f);
}
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $destructure bindings on $property', async () => {
const code = `
let { a: { b, c }, b: { d = defaultD, e = defaultE }, ...f } = $destructure(x);
effect: {
console.log({ b: $property(b) }, { c: $property(c) });
}
effect: {
console.log({ d: $property(d) }, { e: $property(e) });
}
effect: {
console.log(f);
}
`;
expect(await compile(code)).toMatchSnapshot();
});
});
describe('$component', () => {
it('should transform $component', async () => {
const code = `
$component(({ a: { b, c }, b: { d = defaultD, e = defaultE }, ...f }) => {
});
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $component bindings', async () => {
let code = `
$component(({ a: { b, c }, b: { d = defaultD, e = defaultE }, ...f }) => {
effect: {
console.log(b, c);
}
effect: {
console.log(d, e);
}
effect: {
console.log(f);
}
});
`;
expect(await compile(code)).toMatchSnapshot();
code = `
$component(({ a: { b, c }, b: { d = defaultD, e = defaultE }, ...f }) => {
effect: {
console.log({ b }, { c });
}
effect: {
console.log({ d }, { e });
}
effect: {
console.log(f);
}
});
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $component bindings on $get', async () => {
const code = `
$component(({ a: { b, c }, b: { d = defaultD, e = defaultE }, ...f }) => {
effect: {
console.log($get(b), $get(c));
}
effect: {
console.log($get(d), $get(e));
}
effect: {
console.log(f);
}
});
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $component bindings on $refMemo', async () => {
const code = `
$component(({ a: { b, c }, b: { d = defaultD, e = defaultE }, ...f }) => {
effect: {
console.log($refMemo(b), $refMemo(c));
}
effect: {
console.log($refMemo(d), $refMemo(e));
}
effect: {
console.log(f);
}
});
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $component bindings on $getter', async () => {
const code = `
$component(({ a: { b, c }, b: { d = defaultD, e = defaultE }, ...f }) => {
effect: {
console.log({ b: $getter(b) }, { c: $getter(c) });
}
effect: {
console.log({ d: $getter(d) }, { e: $getter(e) });
}
effect: {
console.log(f);
}
});
`;
expect(await compile(code)).toMatchSnapshot();
});
it('should transform $component bindings on $property', async () => {
const code = `
$component(({ a: { b, c }, b: { d = defaultD, e = defaultE }, ...f }) => {
effect: {
console.log({ b: $property(b) }, { c: $property(c) });
}
effect: {
console.log({ d: $property(d) }, { e: $property(e) });
}
effect: {
console.log(f);
}
});
`;
expect(await compile(code)).toMatchSnapshot();
});
});
describe('$effect, $renderEffect, $computed', () => {
it('should transform $effect, $renderEffect, $computed', async () => {
const code = `
let x = $signal(0);
$effect(() => {
console.log('Count', x);
});
$computed(() => {
console.log('Count', x);
});
$renderEffect(() => {
console.log('Count', x);
});
`;
expect(await compile(code)).toMatchSnapshot();
});
});
describe('variable shadowing', () => {
it('should respect variable shadowing', async () => {
const code = `
const selected = $signal('root');
{
const selected = 'local';
console.log(selected); // 'local'
{
console.log(selected); // 'local'
{
const selected = $signal('inner');
console.log(selected); // 'inner'
{
console.log(selected); // 'inner'
}
}
}
}
`;
expect(await compile(code)).toMatchSnapshot();
});
});
});
================================================
FILE: packages/core/tsconfig.json
================================================
{
"exclude": ["node_modules"],
"include": ["src", "types", "babel"],
"compilerOptions": {
"module": "ESNext",
"lib": ["ESNext", "DOM"],
"importHelpers": true,
"declaration": true,
"sourceMap": true,
"rootDir": "./",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "Bundler",
"jsx": "react",
"esModuleInterop": true,
"target": "ES2017",
"useDefineForClassFields": false,
"declarationMap": true
}
}
================================================
FILE: packages/rollup/.gitignore
================================================
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.production
.env.development
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
.npmrc
================================================
FILE: packages/rollup/README.md
================================================
# rollup-plugin-solid-labels
> Rollup plugin for [`solid-labels`](https://github.com/lxsmnsyc/solid-labels)
[](https://www.npmjs.com/package/rollup-plugin-solid-labels) [](https://github.com/airbnb/javascript)
## Install
```bash
npm install --D solid-labels rollup-plugin-solid-labels
```
```bash
yarn add -D solid-labels rollup-plugin-solid-labels
```
```bash
pnpm add -D solid-labels rollup-plugin-solid-labels
```
## Usage
```js
import solidLabels from 'rollup-plugin-solid-labels';
///...
solidLabels({
dev: true, // defaults to false
disabled: {
labels: {
signal: true,
},
pragma: {
'@signal': true,
},
ctf: {
$signal: true,
},
},
filter: {
include: 'src/**/*.{ts,js,tsx,jsx}',
exclude: 'node_modules/**/*.{ts,js,tsx,jsx}',
},
})
```
> [!INFO]
> When you are using a SolidJS Rollup plugin, make sure that solid-labels runs first.
## Sponsors

## License
MIT © [lxsmnsyc](https://github.com/lxsmnsyc)
================================================
FILE: packages/rollup/package.json
================================================
{
"version": "0.17.0",
"type": "module",
"types": "./dist/types/index.d.ts",
"main": "./dist/cjs/production/index.cjs",
"module": "./dist/esm/production/index.mjs",
"exports": {
".": {
"development": {
"require": "./dist/cjs/development/index.cjs",
"import": "./dist/esm/development/index.mjs"
},
"require": "./dist/cjs/production/index.cjs",
"import": "./dist/esm/production/index.mjs",
"types": "./dist/types/index.d.ts"
}
},
"files": [
"dist",
"src"
],
"engines": {
"node": ">=10"
},
"license": "MIT",
"keywords": [
"pridepack",
"babel",
"solid-js",
"labels",
"reactivity"
],
"name": "rollup-plugin-solid-labels",
"devDependencies": {
"@types/node": "^22.13.4",
"pridepack": "2.6.1",
"rollup": "^4.24.0",
"tslib": "^2.8.1",
"typescript": "^5.8.2"
},
"dependencies": {
"unplugin-solid-labels": "0.17.0"
},
"peerDependencies": {
"rollup": "^3 || ^4",
"solid-labels": "^0.16"
},
"scripts": {
"prepublish": "pridepack clean && pridepack build",
"build": "pridepack build",
"type-check": "pridepack check",
"lint": "pridepack lint",
"clean": "pridepack clean",
"watch": "pridepack watch"
},
"description": "Simple, reactive labels for SolidJS",
"repository": {
"url": "https://github.com/lxsmnsyc/solid-labels.git",
"type": "git"
},
"homepage": "https://github.com/lxsmnsyc/solid-labels/tree/main/packages/vite",
"bugs": {
"url": "https://github.com/lxsmnsyc/solid-labels/issues"
},
"publishConfig": {
"access": "public"
},
"author": "Alexis Munsayac",
"private": false,
"typesVersions": {
"*": {}
}
}
================================================
FILE: packages/rollup/pridepack.json
================================================
{
"target": "es2018"
}
================================================
FILE: packages/rollup/src/index.ts
================================================
import type { SolidLabelsPluginOptions } from 'unplugin-solid-labels';
import solidLabelsUnplugin from 'unplugin-solid-labels';
import type { Plugin } from 'rollup';
export type {
SolidLabelsPluginFilter,
SolidLabelsPluginOptions,
} from 'unplugin-solid-labels';
const solidLabelsPlugin = solidLabelsUnplugin.rollup as (
options: SolidLabelsPluginOptions,
) => Plugin;
export default solidLabelsPlugin;
================================================
FILE: packages/rollup/tsconfig.json
================================================
{
"exclude": ["node_modules"],
"include": ["src", "types"],
"compilerOptions": {
"module": "ESNext",
"lib": ["ESNext", "DOM"],
"importHelpers": true,
"declaration": true,
"sourceMap": true,
"rootDir": "./src",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "Bundler",
"jsx": "react",
"esModuleInterop": true,
"target": "ES2017",
"useDefineForClassFields": false,
"declarationMap": true
}
}
================================================
FILE: packages/unplugin/.gitignore
================================================
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.production
.env.development
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
.npmrc
================================================
FILE: packages/unplugin/README.md
================================================
# unplugin-solid-labels
> [Unplugin](https://github.com/unjs/unplugin) for [`solid-labels`](https://github.com/lxsmnsyc/solid-labels)
[](https://www.npmjs.com/package/unplugin-solid-labels) [](https://github.com/airbnb/javascript)
## Install
```bash
npm install --D solid-labels unplugin-solid-labels
```
```bash
yarn add -D solid-labels unplugin-solid-labels
```
```bash
pnpm add -D solid-labels unplugin-solid-labels
```
## Usage
```js
import solidLabels from 'unplugin-solid-labels';
///...
solidLabels.vite({
dev: true, // defaults to false
disabled: {
labels: {
signal: true,
},
pragma: {
'@signal': true,
},
ctf: {
$signal: true,
},
},
filter: {
include: 'src/**/*.{ts,js,tsx,jsx}',
exclude: 'node_modules/**/*.{ts,js,tsx,jsx}',
},
})
```
## Sponsors

## License
MIT © [lxsmnsyc](https://github.com/lxsmnsyc)
================================================
FILE: packages/unplugin/package.json
================================================
{
"name": "unplugin-solid-labels",
"version": "0.17.0",
"type": "module",
"files": [
"dist",
"babel",
"core"
],
"engines": {
"node": ">=10"
},
"license": "MIT",
"keywords": [
"pridepack"
],
"devDependencies": {
"@types/babel__core": "^7.20.5",
"@types/node": "^22.13.4",
"pridepack": "2.6.1",
"rollup": "^4.34.8",
"solid-labels": "0.17.0",
"tslib": "^2.8.1",
"typescript": "^5.8.2",
"vite": "^6.1.1"
},
"dependencies": {
"@babel/core": "^7.26.9",
"@rollup/pluginutils": "^5.1.4",
"unplugin": "^2.2.0"
},
"peerDependencies": {
"rollup": "^3 || 4",
"solid-labels": "^0.16",
"vite": "^3 || ^4 || ^5"
},
"peerDependenciesMeta": {
"vite": {
"optional": true
},
"rollup": {
"optional": true
}
},
"scripts": {
"prepublishOnly": "pridepack clean && pridepack build",
"build": "pridepack build",
"type-check": "pridepack check",
"lint": "pridepack lint",
"clean": "pridepack clean",
"watch": "pridepack watch",
"start": "pridepack start",
"dev": "pridepack dev"
},
"description": "Rollup plugin for solid-styled",
"repository": {
"url": "https://github.com/lxsmnsyc/solid-styled.git",
"type": "git"
},
"homepage": "https://github.com/lxsmnsyc/solid-styled/packages/rollup",
"bugs": {
"url": "https://github.com/lxsmnsyc/solid-styled/issues"
},
"publishConfig": {
"access": "public"
},
"author": "Alexis Munsayac",
"private": false,
"types": "./dist/types/index.d.ts",
"main": "./dist/cjs/production/index.cjs",
"module": "./dist/esm/production/index.mjs",
"exports": {
".": {
"development": {
"require": "./dist/cjs/development/index.cjs",
"import": "./dist/esm/development/index.mjs"
},
"require": "./dist/cjs/production/index.cjs",
"import": "./dist/esm/production/index.mjs",
"types": "./dist/types/index.d.ts"
}
},
"typesVersions": {
"*": {}
}
}
================================================
FILE: packages/unplugin/pridepack.json
================================================
{
"target": "es2018"
}
================================================
FILE: packages/unplugin/src/index.ts
================================================
import * as babel from '@babel/core';
import type { FilterPattern } from '@rollup/pluginutils';
import { createFilter } from '@rollup/pluginutils';
import path from 'node:path';
import type { Options } from 'solid-labels/babel';
import solidLabelsBabel from 'solid-labels/babel';
import type { TransformResult } from 'unplugin';
import { createUnplugin } from 'unplugin';
import type { Plugin } from 'vite';
export interface SolidLabelsPluginFilter {
include?: FilterPattern;
exclude?: FilterPattern;
}
export interface SolidLabelsPluginOptions extends Options {
filter?: SolidLabelsPluginFilter;
}
// From: https://github.com/bluwy/whyframe/blob/master/packages/jsx/src/index.js#L27-L37
function repushPlugin(
plugins: Plugin[],
pluginName: string,
pluginNames: string[],
): void {
const namesSet = new Set(pluginNames);
let baseIndex = -1;
let targetIndex = -1;
let targetPlugin: Plugin | undefined;
for (let i = 0, len = plugins.length; i < len; i += 1) {
const current = plugins[i];
if (namesSet.has(current.name) && baseIndex === -1) {
baseIndex = i;
}
if (current.name === pluginName) {
targetIndex = i;
targetPlugin = current;
}
}
if (
targetPlugin &&
baseIndex !== -1 &&
targetIndex !== -1 &&
baseIndex < targetIndex
) {
plugins.splice(targetIndex, 1);
plugins.splice(baseIndex, 0, targetPlugin);
}
}
const DEFAULT_INCLUDE = 'src/**/*.{jsx,tsx,ts,js,mjs,cjs}';
const DEFAULT_EXCLUDE = 'node_modules/**/*.{jsx,tsx,ts,js,mjs,cjs}';
const FILE_FILTER = /\.[mc]?tsx?$/i;
const solidLabelsPlugin = createUnplugin(
(options: SolidLabelsPluginOptions = {}) => {
const filter = createFilter(
options.filter?.include || DEFAULT_INCLUDE,
options.filter?.exclude || DEFAULT_EXCLUDE,
);
let env: string;
return {
name: 'solid-labels',
transformInclude(id): boolean {
return filter(id);
},
async transform(code, id): Promise {
const plugins: NonNullable<
NonNullable['plugins']
> = ['jsx'];
if (FILE_FILTER.test(id)) {
plugins.push('typescript');
}
const result = await babel.transformAsync(code, {
plugins: [
[
solidLabelsBabel,
{
disabled: options.disabled,
dev: env === 'development' || options.dev,
},
],
],
parserOpts: {
plugins,
},
filename: path.basename(id),
ast: false,
sourceMaps: true,
configFile: false,
babelrc: false,
sourceFileName: id,
});
if (result) {
return {
code: result.code || '',
map: result.map,
};
}
return undefined;
},
vite: {
enforce: 'pre',
configResolved(config): void {
env = config.mode !== 'production' ? 'development' : 'production';
// run our plugin before the following plugins:
repushPlugin(config.plugins as Plugin[], 'solid-labels', [
// https://github.com/withastro/astro/blob/main/packages/astro/src/vite-plugin-jsx/index.ts#L173
'astro:jsx',
// https://github.com/solidjs/vite-plugin-solid/blob/master/src/index.ts#L305
'solid',
// https://github.com/solidjs/solid-start/blob/main/packages/start/vite/plugin.js#L118
'solid-start-file-system-router',
]);
},
},
};
},
);
export default solidLabelsPlugin;
================================================
FILE: packages/unplugin/tsconfig.json
================================================
{
"exclude": ["node_modules"],
"include": ["src"],
"compilerOptions": {
"module": "ESNext",
"lib": ["ESNext", "DOM"],
"importHelpers": true,
"declaration": true,
"sourceMap": true,
"rootDir": "./src",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "Bundler",
"jsx": "react",
"esModuleInterop": true,
"target": "ES2017",
"useDefineForClassFields": false,
"declarationMap": true
}
}
================================================
FILE: packages/vite/.gitignore
================================================
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.production
.env.development
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
.npmrc
================================================
FILE: packages/vite/README.md
================================================
# vite-plugin-solid-labels
> Vite plugin for [`solid-labels`](https://github.com/lxsmnsyc/solid-labels)
[](https://www.npmjs.com/package/vite-plugin-solid-labels) [](https://github.com/airbnb/javascript)
## Install
```bash
npm install --D solid-labels vite-plugin-solid-labels
```
```bash
yarn add -D solid-labels vite-plugin-solid-labels
```
```bash
pnpm add -D solid-labels vite-plugin-solid-labels
```
## Usage
```js
import solidLabels from 'vite-plugin-solid-labels';
///...
solidLabels({
dev: true, // defaults to false
disabled: {
labels: {
signal: true,
},
pragma: {
'@signal': true,
},
ctf: {
$signal: true,
},
},
filter: {
include: 'src/**/*.{ts,js,tsx,jsx}',
exclude: 'node_modules/**/*.{ts,js,tsx,jsx}',
},
})
```
## Sponsors

## License
MIT © [lxsmnsyc](https://github.com/lxsmnsyc)
================================================
FILE: packages/vite/package.json
================================================
{
"version": "0.17.0",
"type": "module",
"types": "./dist/types/index.d.ts",
"main": "./dist/cjs/production/index.cjs",
"module": "./dist/esm/production/index.mjs",
"exports": {
".": {
"development": {
"require": "./dist/cjs/development/index.cjs",
"import": "./dist/esm/development/index.mjs"
},
"require": "./dist/cjs/production/index.cjs",
"import": "./dist/esm/production/index.mjs",
"types": "./dist/types/index.d.ts"
}
},
"files": [
"dist",
"src"
],
"engines": {
"node": ">=10"
},
"license": "MIT",
"keywords": [
"pridepack",
"babel",
"solid-js",
"labels",
"reactivity"
],
"name": "vite-plugin-solid-labels",
"devDependencies": {
"@types/node": "^22.13.4",
"pridepack": "2.6.0",
"rollup": "^4.34.8",
"solid-labels": "0.17.0",
"tslib": "^2.8.1",
"typescript": "^5.8.2",
"vite": "^6.1.1"
},
"dependencies": {
"unplugin-solid-labels": "0.17.0"
},
"peerDependencies": {
"solid-labels": "^0.16",
"vite": "^3 || ^4 || ^5"
},
"scripts": {
"prepublish": "pridepack clean && pridepack build",
"build": "pridepack build",
"type-check": "pridepack check",
"lint": "pridepack lint",
"clean": "pridepack clean",
"watch": "pridepack watch"
},
"description": "Simple, reactive labels for SolidJS",
"repository": {
"url": "https://github.com/lxsmnsyc/solid-labels.git",
"type": "git"
},
"homepage": "https://github.com/lxsmnsyc/solid-labels/tree/main/packages/vite",
"bugs": {
"url": "https://github.com/lxsmnsyc/solid-labels/issues"
},
"publishConfig": {
"access": "public"
},
"author": "Alexis Munsayac",
"private": false,
"typesVersions": {
"*": {}
}
}
================================================
FILE: packages/vite/pridepack.json
================================================
{
"target": "es2018"
}
================================================
FILE: packages/vite/src/index.ts
================================================
import type { SolidLabelsPluginOptions } from 'unplugin-solid-labels';
import solidLabelsUnplugin from 'unplugin-solid-labels';
import type { Plugin } from 'vite';
export type {
SolidLabelsPluginFilter,
SolidLabelsPluginOptions,
} from 'unplugin-solid-labels';
const solidLabelsPlugin = solidLabelsUnplugin.vite as (
options: SolidLabelsPluginOptions,
) => Plugin;
export default solidLabelsPlugin;
================================================
FILE: packages/vite/tsconfig.json
================================================
{
"exclude": ["node_modules"],
"include": ["src", "types"],
"compilerOptions": {
"module": "ESNext",
"lib": ["ESNext", "DOM"],
"importHelpers": true,
"declaration": true,
"sourceMap": true,
"rootDir": "./src",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "Bundler",
"jsx": "react",
"esModuleInterop": true,
"target": "ES2017",
"useDefineForClassFields": false,
"declarationMap": true
}
}
================================================
FILE: pnpm-workspace.yaml
================================================
packages:
- 'packages/**/*'
- 'examples/**/*'