Skip to content
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

C3 - fix and update solid #5135

Merged
merged 8 commits into from
Mar 4, 2024
5 changes: 5 additions & 0 deletions .changeset/cuddly-worms-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-cloudflare": patch
---

fix: update solid preview and deploy scripts to be aligned with the rest of the frameworks
5 changes: 5 additions & 0 deletions .changeset/wet-suns-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-cloudflare": patch
---

fix: update solid C3 template to write an `app.config.(js/ts)` file instead of `vite.config.(js/ts)`
1 change: 1 addition & 0 deletions packages/create-cloudflare/e2e-tests/frameworks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ const frameworkTests: Record<string, FrameworkTestConfig> = {
],
testCommitMessage: true,
timeout: LONG_TIMEOUT,
unsupportedPms: ["npm"],
unsupportedOSs: ["win32"],
verifyDeploy: {
route: "/",
Expand Down
63 changes: 52 additions & 11 deletions packages/create-cloudflare/templates/solid/c3.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { logRaw } from "@cloudflare/cli";
import { logRaw, updateStatus } from "@cloudflare/cli";
import { blue } from "@cloudflare/cli/colors";
import { transformFile } from "helpers/codemod";
import { runFrameworkGenerator } from "helpers/command";
import { compatDateFlag } from "helpers/files";
import { compatDateFlag, usesTypescript } from "helpers/files";
import { detectPackageManager } from "helpers/packages";
import * as recast from "recast";
import type { TemplateConfig } from "../../src/templates";
import type { C3Context } from "types";

Expand All @@ -14,26 +17,64 @@ const generate = async (ctx: C3Context) => {
logRaw("");
};

const configure = async (ctx: C3Context) => {
usesTypescript(ctx);
const filePath = `app.config.${usesTypescript(ctx) ? "ts" : "js"}`;

updateStatus(`Updating configuration in ${blue(filePath)}`);

transformFile(filePath, {
visitCallExpression: function (n) {
const callee = n.node.callee as recast.types.namedTypes.Identifier;
if (callee.name !== "defineConfig") {
return this.traverse(n);
}

const b = recast.types.builders;
n.node.arguments = [
b.objectExpression([
b.objectProperty(
b.identifier("server"),
b.objectExpression([
b.objectProperty(
b.identifier("preset"),
b.stringLiteral("cloudflare-pages")
),
b.objectProperty(
b.identifier("rollupConfig"),
b.objectExpression([
b.objectProperty(
b.identifier("external"),
b.arrayExpression([b.stringLiteral("node:async_hooks")])
),
])
),
])
),
]),
];

return false;
},
});
};

const config: TemplateConfig = {
configVersion: 1,
id: "solid",
displayName: "Solid",
platform: "pages",
copyFiles: {
variants: {
js: { path: "./js" },
ts: { path: "./ts" },
},
},
generate,
configure,
transformPackageJson: async () => ({
scripts: {
"pages:preview": `${npm} run build && npx wrangler pages dev dist ${await compatDateFlag()} --compatibility-flag nodejs_compat`,
"pages:deploy": `${npm} run build && wrangler pages deploy ./dist`,
preview: `${npm} run build && npx wrangler pages dev dist ${await compatDateFlag()} --compatibility-flag nodejs_compat`,
deploy: `${npm} run build && wrangler pages deploy ./dist`,
},
}),
devScript: "dev",
previewScript: "pages:preview",
deployScript: "deploy",
previewScript: "preview",
compatibilityFlags: ["nodejs_compat"],
};
export default config;
12 changes: 0 additions & 12 deletions packages/create-cloudflare/templates/solid/js/vite.config.js

This file was deleted.

12 changes: 0 additions & 12 deletions packages/create-cloudflare/templates/solid/ts/vite.config.ts

This file was deleted.

Loading