feat: Solid 2.0 template support - #82
Conversation
- New "Solid 2.0" project type (--solid) scaffolding the solid-v2/* templates; listed first but not preselected while core is in beta - Optional streaming-SSR flip (--ssr / prompt, default No) on templates that support it: ssr: true in vite.config.ts, the generic production server.js (verbatim from solid-v2/fullstack), and a matching start script - JS variants via the existing sucrase conversion, adapted for turnkey templates (no index.html rewrite, .ts refs in vite.config retargeted, .d.ts dropped, minimal jsconfig) - templates.json manifest read from the templates repo HEAD (2s timeout, silent fallback to the baked-in lists) now drives template names, subdir paths and per-template flags, so template additions/reorganizations no longer require a CLI release - Template downloads can be pinned to a templates-repo ref per release (TEMPLATES_REF, SOLID_CLI_TEMPLATES_REF override) Co-authored-by: Cursor <cursoragent@cursor.com>
…2 + templates.json Co-authored-by: Cursor <cursoragent@cursor.com>
| export const JS_CONFIG_SOLID_V2 = { | ||
| compilerOptions: { | ||
| jsx: "preserve", | ||
| jsxImportSource: "solid-js", |
There was a problem hiding this comment.
does this need to be @solidjs/web?
There was a problem hiding this comment.
Good catch — you're right. The solid-v2 templates' tsconfig.json all declare "jsxImportSource": "@solidjs/web" (Solid 2.0's JSX runtime lives in @solidjs/web, and vite-plugin-solid 3.x compiles against it), so the jsconfig written for the JS variants should match. Fixed in #83.
…e fixes Picks up two template fixes: solid-v2/with-vitest-browser-mode sets environment: 'node' explicitly so `pnpm test` exits 0, and vanilla/with-vitest-browser-mode's corrupted import specifier is repaired. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Bumped |
The JS variants of the Solid 2.0 templates were getting a jsconfig.json with jsxImportSource "solid-js", but the templates' own tsconfig.json declares "@solidjs/web" (Solid 2.0's JSX runtime lives there, and vite-plugin-solid 3.x compiles against it). Match the templates. Raised by @brenelz in #82 review. Co-authored-by: Cursor <cursoragent@cursor.com>
| - Optional streaming SSR on templates that support it (currently `basic`): a scaffold-time flip that sets `ssr: true` in `vite.config.ts`, adds the generic production `server.js`, and points the `start` script at it. Defaults to No. | ||
| - JavaScript variants of the Solid 2.0 templates via the existing sucrase TS→JS conversion (no `index.html` rewrite; `.ts`/`.tsx` references inside `vite.config` are retargeted, `.d.ts` files dropped, minimal `jsconfig.json`). | ||
| - Template lists, subdir paths and per-template flags are now read from a `templates.json` manifest at the templates repo HEAD (2s timeout), with silent fallback to the baked-in lists — so new templates and future repo reorganizations no longer require a CLI release. | ||
| - Template tarball downloads can be pinned to a templates-repo ref per CLI release (`TEMPLATES_REF`, overridable via `SOLID_CLI_TEMPLATES_REF`). |
There was a problem hiding this comment.
@ryansolid this pinning part might have caused that we now can't update templates without shipping new cli versions. The tempaltes are on solid v2 rc.0, but the npm create solid template cloning still get beta.34. We typically update the templates more frequent than the cli.
- Template tarball downloads can be pinned to a templates-repo ref per CLI release (TEMPLATES_REF, overridable via SOLID_CLI_TEMPLATES_REF).
There was a problem hiding this comment.
Yeah, I think the CLI should just pull the latest from templates as appropriate testing should be done there. I'll release a version without version pinning later so the CLI will always pull the latest templates
There was a problem hiding this comment.
i reckon the intention is to make it useful with a fork, and to allow any older CLI version to keep working, which would also enable reorganizing the templates without breaking anything. but with a 24h delay, that flow is likely gonna be too inert.
feat: Solid 2.0 template support
Adds first-class scaffolding for the Solid 2.0 (
solid-v2/*) templates from solidjs/templates, plus the two mechanisms that keep the CLI honest as that repo evolves: atemplates.jsonmanifest read from the repo, and per-release ref-pinning of template downloads.What's new
"Solid 2.0" project type
A new top-level project type alongside SolidStart / SolidJS + Vite / Library, backed by the
solid-v2/templates:basic(default),bare,fullstack,fullstack-tanstack,with-bootstrap,with-sass,with-tailwindcss,with-tanstack-router,with-unocss,with-vitest-browser-mode.--solidflag for scripts. Existing flags (-s,-v,-l,--v2,--ts,--js,-p,-t) keep their exact meaning; the vanilla and Start flows are unchanged.Optional streaming SSR (
--ssr/ prompt)Solid 2.0 templates flagged
ssrToggle(currentlybasic) get one extra confirm after template selection — "Enable server-side rendering (streaming SSR)?", default No. Saying yes applies a three-file flip at scaffold time (the exact delta betweensolid-v2/basicandsolid-v2/fullstack's server posture):vite.config.ts:ssr: trueadded to thesolid({ start: true, ... })call (and the "addssr: true" hint comment dropped)server.js: the generic production node server, embedded verbatim fromsolid-v2/fullstack/server.js(regenerate withscripts/gen-ssr-flip-server.mjs)package.json:"start": "node --env-file-if-exists=.env server.js"If the config anchor is ever missing (template drift), the flip aborts with a warning and leaves a working client-mode app.
--ssr/--no-ssrskip the prompt for non-interactive use.JavaScript variants
The existing sucrase TS→JS machinery now covers Solid 2.0 templates, with turnkey-mode adjustments: no
index.htmlrewrite (there is none),.ts/.tsxreferences insidevite.config(setup files, middleware, test globs) retargeted to the transpiled output,.d.tsfiles dropped instead of transpiled to junk (also improves vanilla/Start JS output), and a minimaljsconfig.jsonwithout the~/*alias these templates don't use.templates.jsonmanifest (with baked-in fallback)At startup the CLI fetches
templates.jsonfrom the templates repo HEAD (single small file, 2s timeout). On success it is the source of truth for template names, subdir paths, the default selection, and per-template flags (ssrToggle). On any failure — offline, 404, malformed, unknown major version — the CLI silently falls back to the baked-in lists inconstants.ts, behaving exactly as today. New templates or flag flips (e.g. enablingssrToggleon more templates) then ship without a CLI release. The manifest is live on templatesmain(templates.json).Honest caveat: this protects manifest-aware CLIs onward. Already-published versions still hardcode paths against live HEAD, so any relocation of
vanilla//solid-start-*still needs the deprecation choreography discussed separately — this PR only builds the mechanism that makes it possible.Ref-pinned template downloads
All template tarball downloads go through one helper that passes an optional ref to begit (
repo.hash).TEMPLATES_REFinutils/download.tsis set at release time (tag or sha) so a published CLI keeps scaffolding exactly what it was tested against. This PR ships it pinned to templatesmaincommitc3032d9— the merge that landedsolid-v2/andtemplates.json.SOLID_CLI_TEMPLATES_REFoverrides it for testing against branches/forks. The manifest fetch intentionally stays on HEAD for freshness.Version
Changeset included: minor on
create-solidand@solid-cli/create→ 0.9.0.Verification
Scaffolded via the built bin against the templates repo
nexttree (local tarball through begit's cache,SOLID_CLI_TEMPLATES_REF); every app thenpnpm install && pnpm build:basicTSvite.config.tsuntouched (client mode)basicTS + SSRnode server.jsserves/with streamed SSR HTML (HTTP 200);server.jsbyte-identical tosolid-v2/fullstack/server.jsbasicJS.jsxsources,jsconfig.json, config refs rewrittenbasicJS + SSR/vianode server.js;server.jsbyte-identicalbareTSfullstackTSbasic-vTS/JS,basic-s --v2index.htmlrewriteManifest paths exercised end-to-end: real manifest served locally (drives the lists — a restricted manifest correctly rejects
basicand acceptsbare), and unreachable-URL runs falling back to baked lists. Unit tests: SSR flip (incl. drift abort), manifest parse/validate/fallback,solid-v2/basicdownload.With
solid-v2/andtemplates.jsonnow on templatesmain, re-verified against live GitHub at the pinned ref: rootpnpm testgreen (16 tests / 5 files, including both live download tests), plus a live-network scaffold ofbasicTS + SSR via the built bin with no cache override (correct file tree,solid-js 2.0.0-beta.34).Merge gating
Done — landed insolid-v2/(all ten templates, incl. the fullstack tier) andtemplates.jsonmust be on templatesmainbefore this merges/releasesc3032d9, andTEMPLATES_REFis pinned to it.