Skip to content

feat: Solid 2.0 template support - #82

Merged
Tommypop2 merged 3 commits into
mainfrom
feat/solid-v2-templates
Aug 12, 2026
Merged

feat: Solid 2.0 template support#82
Tommypop2 merged 3 commits into
mainfrom
feat/solid-v2-templates

Conversation

@ryansolid

Copy link
Copy Markdown
Contributor

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: a templates.json manifest 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.

  • Listed first in the prompt but not preselected — SolidStart stays the default while Solid 2.0 core is in beta.
  • New --solid flag 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 (currently basic) 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 between solid-v2/basic and solid-v2/fullstack's server posture):

  1. vite.config.ts: ssr: true added to the solid({ start: true, ... }) call (and the "add ssr: true" hint comment dropped)
  2. server.js: the generic production node server, embedded verbatim from solid-v2/fullstack/server.js (regenerate with scripts/gen-ssr-flip-server.mjs)
  3. 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-ssr skip 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.html rewrite (there is none), .ts/.tsx references inside vite.config (setup files, middleware, test globs) retargeted to the transpiled output, .d.ts files dropped instead of transpiled to junk (also improves vanilla/Start JS output), and a minimal jsconfig.json without the ~/* alias these templates don't use.

templates.json manifest (with baked-in fallback)

At startup the CLI fetches templates.json from 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 in constants.ts, behaving exactly as today. New templates or flag flips (e.g. enabling ssrToggle on more templates) then ship without a CLI release. The manifest is live on templates main (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_REF in utils/download.ts is 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 templates main commit c3032d9 — the merge that landed solid-v2/ and templates.json. SOLID_CLI_TEMPLATES_REF overrides it for testing against branches/forks. The manifest fetch intentionally stays on HEAD for freshness.

Version

Changeset included: minor on create-solid and @solid-cli/create0.9.0.

Verification

Scaffolded via the built bin against the templates repo next tree (local tarball through begit's cache, SOLID_CLI_TEMPLATES_REF); every app then pnpm install && pnpm build:

Scaffold Result
basic TS builds; vite.config.ts untouched (client mode)
basic TS + SSR builds; node server.js serves / with streamed SSR HTML (HTTP 200); server.js byte-identical to solid-v2/fullstack/server.js
basic JS builds; .jsx sources, jsconfig.json, config refs rewritten
basic JS + SSR builds; serves / via node server.js; server.js byte-identical
bare TS builds
fullstack TS builds (prod build unaffected by the known beta.33 dev-SSR issue)
basic -v TS/JS, basic -s --v2 regression: unchanged behavior incl. index.html rewrite

Manifest paths exercised end-to-end: real manifest served locally (drives the lists — a restricted manifest correctly rejects basic and accepts bare), and unreachable-URL runs falling back to baked lists. Unit tests: SSR flip (incl. drift abort), manifest parse/validate/fallback, solid-v2/basic download.

With solid-v2/ and templates.json now on templates main, re-verified against live GitHub at the pinned ref: root pnpm test green (16 tests / 5 files, including both live download tests), plus a live-network scaffold of basic TS + SSR via the built bin with no cache override (correct file tree, solid-js 2.0.0-beta.34).

Merge gating

  • solid-v2/ (all ten templates, incl. the fullstack tier) and templates.json must be on templates main before this merges/releases Done — landed in c3032d9, and TEMPLATES_REF is pinned to it.

ryansolid and others added 2 commits August 11, 2026 14:25
- 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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be @solidjs/web?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@ryansolid

Copy link
Copy Markdown
Contributor Author

Bumped TEMPLATES_REF to templates main b3d888d to pick up the browser-mode template fixes (explicit environment: 'node' so pnpm test exits 0 in solid-v2/with-vitest-browser-mode, plus the vanilla variant's corrupted-import repair).

@Tommypop2
Tommypop2 merged commit 048ca92 into main Aug 12, 2026
3 checks passed
ryansolid added a commit that referenced this pull request Aug 12, 2026
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`).

@birkskyum birkskyum Aug 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@birkskyum birkskyum Aug 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants