Skip to content

Commit 2aec2b4

Browse files
Support SolidStart in autoconfig (#11478)
* Support SolidStart in autoconfig * remove nitropack installation * Remove nitropack installation from C3 stable as well
1 parent b4dc50b commit 2aec2b4

File tree

9 files changed

+115
-10
lines changed

9 files changed

+115
-10
lines changed

.changeset/bumpy-beds-sink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-cloudflare": patch
3+
---
4+
5+
Support SolidStart in `--experimental` mode

.changeset/every-swans-melt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-cloudflare": patch
3+
---
4+
5+
Remove unnecessary nitropack installation

.changeset/plenty-tables-teach.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": minor
3+
---
4+
5+
Support SolidStart in autoconfig

packages/create-cloudflare/e2e/tests/cli/cli.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ describe("Create Cloudflare CLI", () => {
555555
npm create cloudflare -- --framework next -- --ts
556556
pnpm create cloudflare --framework next -- --ts
557557
Allowed Values:
558-
gatsby, svelte, docusaurus, astro, tanstack-start, angular
558+
gatsby, svelte, docusaurus, astro, tanstack-start, angular, solid
559559
--platform=<value>
560560
Whether the application should be deployed to Pages or Workers. This is only applicable for Frameworks templates that support both Pages and Workers.
561561
Allowed Values:

packages/create-cloudflare/e2e/tests/frameworks/test-config.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,34 @@ function getExperimentalFrameworkTestConfig(
765765
flags: ["--style", "sass"],
766766
verifyTypes: false,
767767
},
768+
{
769+
name: "solid",
770+
promptHandlers: [
771+
{
772+
matcher: /Which template would you like to use/,
773+
input: [keys.enter],
774+
},
775+
],
776+
flags: ["--ts"],
777+
extraEnv: {
778+
BEGIT_GH_API_KEY: process.env.GITHUB_TOKEN,
779+
},
780+
testCommitMessage: true,
781+
timeout: LONG_TIMEOUT,
782+
unsupportedPms: ["npm", "yarn"],
783+
unsupportedOSs: ["win32"],
784+
verifyDeploy: {
785+
route: "/",
786+
expectedText: "Hello world",
787+
},
788+
verifyPreview: {
789+
previewArgs: ["--inspector-port=0"],
790+
route: "/",
791+
expectedText: "Hello world",
792+
},
793+
nodeCompat: true,
794+
verifyTypes: false,
795+
},
768796
];
769797
}
770798

packages/create-cloudflare/src/templates.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export function getFrameworkMap({ experimental = false }): TemplateMap {
242242
astro: astroTemplate,
243243
"tanstack-start": tanStackStartTemplate,
244244
angular: angularTemplate,
245+
solid: solidTemplate,
245246
};
246247
} else {
247248
return {

packages/create-cloudflare/templates/solid/c3.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { logRaw, updateStatus } from "@cloudflare/cli";
2-
import { blue, brandColor, dim } from "@cloudflare/cli/colors";
2+
import { blue } from "@cloudflare/cli/colors";
33
import { runFrameworkGenerator } from "frameworks/index";
44
import { mergeObjectProperties, transformFile } from "helpers/codemod";
55
import { getWorkerdCompatibilityDate } from "helpers/compatDate";
66
import { usesTypescript } from "helpers/files";
77
import { detectPackageManager } from "helpers/packageManagers";
8-
import { installPackages } from "helpers/packages";
98
import * as recast from "recast";
109
import type { TemplateConfig } from "../../src/templates";
1110
import type { C3Context } from "types";
@@ -21,13 +20,6 @@ const generate = async (ctx: C3Context) => {
2120
};
2221

2322
const configure = async (ctx: C3Context) => {
24-
const packages = ["nitropack"];
25-
await installPackages(packages, {
26-
dev: true,
27-
startText: "Installing nitro module `nitropack`",
28-
doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
29-
});
30-
3123
usesTypescript(ctx);
3224
const filePath = `app.config.${usesTypescript(ctx) ? "ts" : "js"}`;
3325

packages/wrangler/src/autoconfig/frameworks/get-framework.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Angular } from "./angular";
22
import { Astro } from "./astro";
3+
import { SolidStart } from "./solid-start";
34
import { Static } from "./static";
45
import { SvelteKit } from "./sveltekit";
56
import { TanstackStart } from "./tanstack";
@@ -18,6 +19,8 @@ export function getFramework(detectedFramework?: {
1819
return new TanstackStart(detectedFramework.name);
1920
case "angular":
2021
return new Angular(detectedFramework.name);
22+
case "solid-start":
23+
return new SolidStart(detectedFramework.name);
2124
default:
2225
return new Static(detectedFramework?.name);
2326
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { updateStatus } from "@cloudflare/cli";
2+
import { blue } from "@cloudflare/cli/colors";
3+
import * as recast from "recast";
4+
import { getDevCompatibilityDate } from "../../utils/compatibility-date";
5+
import { mergeObjectProperties, transformFile } from "../c3-vendor/codemod";
6+
import { usesTypescript } from "../uses-typescript";
7+
import { Framework } from ".";
8+
import type { ConfigurationOptions, ConfigurationResults } from ".";
9+
10+
export class SolidStart extends Framework {
11+
async configure({
12+
projectPath,
13+
dryRun,
14+
}: ConfigurationOptions): Promise<ConfigurationResults> {
15+
if (!dryRun) {
16+
const filePath = `app.config.${usesTypescript(projectPath) ? "ts" : "js"}`;
17+
18+
const compatDate = getDevCompatibilityDate(undefined);
19+
20+
updateStatus(`Updating configuration in ${blue(filePath)}`);
21+
22+
transformFile(filePath, {
23+
visitCallExpression: function (n) {
24+
const callee = n.node.callee as recast.types.namedTypes.Identifier;
25+
if (callee.name !== "defineConfig") {
26+
return this.traverse(n);
27+
}
28+
29+
const b = recast.types.builders;
30+
mergeObjectProperties(
31+
n.node.arguments[0] as recast.types.namedTypes.ObjectExpression,
32+
[
33+
b.objectProperty(
34+
b.identifier("server"),
35+
b.objectExpression([
36+
// preset: "cloudflare_module"
37+
b.objectProperty(
38+
b.identifier("preset"),
39+
b.stringLiteral("cloudflare_module")
40+
),
41+
b.objectProperty(
42+
b.identifier("compatibilityDate"),
43+
b.stringLiteral(compatDate)
44+
),
45+
])
46+
),
47+
]
48+
);
49+
50+
return false;
51+
},
52+
});
53+
}
54+
55+
return {
56+
wranglerConfig: {
57+
main: "./.output/server/index.mjs",
58+
compatibility_flags: ["nodejs_compat"],
59+
assets: {
60+
binding: "ASSETS",
61+
directory: "./.output/public",
62+
},
63+
},
64+
};
65+
}
66+
}

0 commit comments

Comments
 (0)