Skip to content

Commit

Permalink
fix: C3 experimental template for Solid now uses correct preset (#7343)
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin authored Dec 4, 2024
1 parent 5e69799 commit a3d5aad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 52 deletions.
5 changes: 5 additions & 0 deletions .changeset/quick-bananas-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-cloudflare": patch
---

fix: C3 experimental template for Solid now uses correct preset
57 changes: 7 additions & 50 deletions packages/create-cloudflare/templates-experimental/solid/c3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { logRaw, updateStatus } from "@cloudflare/cli";
import { blue, brandColor, dim } from "@cloudflare/cli/colors";
import { runFrameworkGenerator } from "frameworks/index";
import { mergeObjectProperties, transformFile } from "helpers/codemod";
import { getWorkerdCompatibilityDate } from "helpers/compatDate";
import { usesTypescript } from "helpers/files";
import { detectPackageManager } from "helpers/packageManagers";
import { installPackages } from "helpers/packages";
Expand Down Expand Up @@ -30,6 +31,8 @@ const configure = async (ctx: C3Context) => {
usesTypescript(ctx);
const filePath = `app.config.${usesTypescript(ctx) ? "ts" : "js"}`;

const compatDate = await getWorkerdCompatibilityDate();

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

transformFile(filePath, {
Expand All @@ -46,60 +49,14 @@ const configure = async (ctx: C3Context) => {
b.objectProperty(
b.identifier("server"),
b.objectExpression([
// preset: "cloudflare-pages"
// preset: "cloudflare_module"
b.objectProperty(
b.identifier("preset"),
b.stringLiteral("cloudflare-pages"),
),
// output: {
// dir: "{{ rootDir }}/dist",
// publicDir: "{{ output.dir }}/public",
// serverDir: "{{ output.dir }}/worker",
// },
b.objectProperty(
b.identifier("output"),
b.objectExpression([
b.objectProperty(
b.identifier("dir"),
b.stringLiteral("{{ rootDir }}/dist"),
),
b.objectProperty(
b.identifier("publicDir"),
b.stringLiteral("{{ output.dir }}/public"),
),
b.objectProperty(
b.identifier("serverDir"),
b.stringLiteral("{{ output.dir }}/worker"),
),
]),
),
// rollupConfig: {
// external: ["node:async_hooks"],
// },
b.objectProperty(
b.identifier("rollupConfig"),
b.objectExpression([
b.objectProperty(
b.identifier("external"),
b.arrayExpression([b.stringLiteral("node:async_hooks")]),
),
]),
b.stringLiteral("cloudflare_module"),
),
// hooks: {
// // Prevent the Pages preset from writing the _routes.json etc.
// compiled() {},
// },
b.objectProperty(
b.identifier("hooks"),
b.objectExpression([
b.objectMethod(
"method",
b.identifier("compiled"),
[],
b.blockStatement([]),
false,
),
]),
b.identifier("compatibilityDate"),
b.stringLiteral(compatDate),
),
]),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name = "<TBD>"
compatibility_date = "<TBD>"
compatibility_flags = ["nodejs_compat"]
main = "./dist/worker/index.js"
assets = { directory = "./dist/public", binding = "ASSETS" }
main = "./.output/server/index.mjs"
assets = { directory = "./.output/public", binding = "ASSETS" }

# Workers Logs
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
Expand Down

0 comments on commit a3d5aad

Please sign in to comment.