Migrate from Solid · @pyreon/solid-compat
Your Solid components run on day one.
@pyreon/solid-compat runs Solid's API on Pyreon: signals, memos, effects, stores, resources and the control-flow components. Solid and Pyreon already share the model, so the final move is mostly a change of signal shape.
npm install @pyreon/solid-compat @pyreon/core @pyreon/reactivity @pyreon/runtime-dom
npm install -D @pyreon/vite-plugin before and after
The same Solid code, on Pyreon.
coverage
What @pyreon/solid-compat covers, and what it does not.
covers
- Signals:
createSignal,createMemo,createEffect,createComputed,createRenderEffect,createRoot,on,batch,untrack. onMount,onCleanup;mergeProps,splitProps,children;createContext,useContext;getOwner,runWithOwner.createResourcewithloading,error,latestand Solid's fivestatevalues.- Stores:
createStore,reconcile,unwrap,produce;createSelector. - Control flow:
<For>,<Index>,<Show>,<Switch>,<Match>,<Dynamic>,<Portal>,<ErrorBoundary>,<Suspense>;mapArray,indexArray. observable,from,lazy,createDeferred,createReaction,catchError,createUniqueId,render,hydrate.
does not cover
- Fine-grained updates inside compat components: a setter re-runs the whole component body (output and lifecycle stay correct). Converted Pyreon components get per-node updates back.
- Mutable stores (
createMutable,modifyMutable),onErrorandisServer: not exported, so an import fails loudly. - Solid's SSR entry points (
renderToString,renderToStream,HydrationScript,NoHydration,Assets): use Pyreon's own SSR. dom-expressionshelpers (template,insert,spread,classList,delegateEvents): Pyreon's compiler replaces Solid's Babel plugin.startTransitionanduseTransitionrun synchronously;isPendingis alwaysfalse.
setup
Install it, point the config at it.
npm install @pyreon/solid-compat @pyreon/core @pyreon/reactivity @pyreon/runtime-dom
npm install -D @pyreon/vite-plugin vite.config.ts
// vite.config.ts
import { defineConfig } from 'vite'
import pyreon from '@pyreon/vite-plugin'
export default defineConfig({
plugins: [pyreon({ compat: 'solid' })],
})Use it in place of vite-plugin-solid. Aliases solid-js and its JSX runtime.
tsconfig.json
// tsconfig.json
{
"compilerOptions": {
"jsx": "preserve",
"jsxImportSource": "@pyreon/solid-compat"
}
}As given in the package README.
or start from a scaffold
npm create @pyreon/zero@latest my-app -- --compat solid port it
Then, one component at a time
Solid (runs as-is on solid-compat) · Counter.tsx
import { createMemo, createSignal } from 'solid-js'
export function Counter(props: { step: number }) {
const [count, setCount] = createSignal(0)
const doubled = createMemo(() => count() * 2)
return (
<button class="counter" onClick={() => setCount((c) => c + props.step)}>
{count()} / {doubled()}
</button>
)
}Pyreon · Counter.tsx
import { computed, signal } from '@pyreon/reactivity'
export function Counter(props: { step: number }) {
const count = signal(0)
const doubled = computed(() => count() * 2)
return (
<button class="counter" onClick={() => count.update((c) => c + props.step)}>
{count()} / {doubled()}
</button>
)
}The read stays count(); the write moves from setCount to count.set / count.update. Lists keep <For each={rows()}> and add a key: <For each={rows()} by={(r) => r.id}>.
read more