Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 22
feat: Solid 2.0 template support#82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| "create-solid": minor | ||
| "@solid-cli/create": minor | ||
| --- | ||
| Solid 2.0 template support | ||
| - New "Solid 2.0" top-level project type scaffolding the `solid-v2/*` templates from solidjs/templates (basic, bare, fullstack, fullstack-tanstack, with-\*). Listed first but not preselected while Solid 2.0 core is in beta; existing flags (`-s`, `-v`, `-l`, `--v2`) keep their meaning, plus new `--solid` and `--ssr` flags. | ||
| - 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`). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { join } from "node:path"; | ||
| import { existsSync, writeFileSync } from "node:fs"; | ||
| import { readFile, writeFile } from "node:fs/promises"; | ||
| import { handleTSConversion } from "./utils/ts-conversion"; | ||
| import { GIT_IGNORE, JS_CONFIG_SOLID_V2, SolidV2Template } from "./utils/constants"; | ||
| import { downloadTemplate } from "./utils/download"; | ||
| import { applySsrFlip } from "./utils/ssr-flip"; | ||
| export type CreateSolidV2Args = { | ||
| template: SolidV2Template | (string & {}); | ||
| destination: string; | ||
| /** Subdir prefix inside the templates repo (from templates.json), defaults to "solid-v2" */ | ||
| path?: string; | ||
| }; | ||
| export const createSolidV2 = (args: CreateSolidV2Args, transpile?: boolean, ssr?: boolean) => { | ||
| if (transpile) { | ||
| return createSolidV2JS(args, ssr); | ||
| } | ||
| return createSolidV2TS(args, ssr); | ||
| }; | ||
| export const createSolidV2TS = async ({ template, destination, path = "solid-v2" }: CreateSolidV2Args, ssr?: boolean) => { | ||
| await downloadTemplate(`${path}/${template}`, destination); | ||
| if (ssr) await applySsrFlip(destination); | ||
| }; | ||
| export const createSolidV2JS = async (args: CreateSolidV2Args, ssr?: boolean) => { | ||
| // Create typescript project in `<destination>/.project` | ||
| // then transpile this to javascript and clean up. | ||
| // The SSR flip runs inside the temp dir, before conversion, so the config | ||
| // edit happens on the `.ts` source (server.js is already plain JS). | ||
| const tempDir = join(args.destination, ".project"); | ||
| await createSolidV2TS({ ...args, destination: tempDir }, ssr); | ||
| await handleTSConversion(tempDir, args.destination, JS_CONFIG_SOLID_V2); | ||
| // Solid 2.0 templates have no `index.html` (turnkey entries), but their vite | ||
| // config references `.ts`/`.tsx` files by path (setup files, middleware, test | ||
| // globs) — retarget those to the transpiled `.js`/`.jsx` output | ||
| const viteConfigPath = join(args.destination, "vite.config.js"); | ||
| if (existsSync(viteConfigPath)) { | ||
| const viteConfig = (await readFile(viteConfigPath)) | ||
| .toString() | ||
| .replace(/\.tsx(?=['"])/g, ".jsx") | ||
| .replace(/\.ts(?=['"])/g, ".js"); | ||
| await writeFile(viteConfigPath, viteConfig); | ||
| } | ||
| // Add .gitignore | ||
| writeFileSync(join(args.destination, ".gitignore"), GIT_IGNORE); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 solidtemplate 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 viaSOLID_CLI_TEMPLATES_REF).There was a problem hiding this comment.
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
templatesas appropriate testing should be done there. I'll release a version without version pinning later so the CLI will always pull the latest templatesUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.