Skip to content

Conversation

@penalosa
Copy link
Contributor

@penalosa penalosa commented Nov 12, 2025

Fixes https://jira.cfdata.org/browse/DEVX-2313

This repurposes the existing C3 --experimental flag (which has associated filtering, logging and separate test runs) to configure frameworks with autoconfig (via wrangler setup) instead of using the existing C3 logic. Over time, this will expand to more frameworks, at which point autoconfig will become the default C3 flow


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: tracked elsewhere
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: not a v3 feature

@changeset-bot
Copy link

changeset-bot bot commented Nov 12, 2025

🦋 Changeset detected

Latest commit: 923d457

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

`Running autoconfig with:\n${JSON.stringify(autoConfigDetails, null, 2)}...`
);

startSection("Configuring your application for Cloudflare");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This output was a bit verbose

Comment on lines -19 to -24
logger.log({
hasYarn,
hasNpm,
hasPnpm,
hasBun,
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MattieTK I think this was a stray debugging log that got merged

// check the user agent
if (userAgent === "npm" && hasNpm) {
logger.log("Using npm as package manager.");
logger.debug("Using npm as package manager.");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These being .log() was getting very noisy

// Only run auto config if the project is not already configured
if (!details.configured) {
await runAutoConfig(details);
await runAutoConfig(details, { skipBuild: true });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wrangler setup shouldn't really be running a build, in my opinion.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 12, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@11251

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@11251

miniflare

npm i https://pkg.pr.new/miniflare@11251

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@11251

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@11251

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@11251

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@11251

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@11251

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@11251

wrangler

npm i https://pkg.pr.new/wrangler@11251

commit: 923d457

@penalosa penalosa force-pushed the penalosa/c3-autoconfig branch 2 times, most recently from c91c08f to 40c72d3 Compare November 13, 2025 00:39
@penalosa penalosa force-pushed the penalosa/c3-autoconfig branch from 40c72d3 to f634b16 Compare November 13, 2025 00:43
…meworks we were injecting extra dev commands into package.json files, which meant that generated C3 projects often had both a `start` and a `develop` script.
@penalosa penalosa force-pushed the penalosa/c3-autoconfig branch from ad59ecf to 076b75c Compare November 13, 2025 00:55
@penalosa penalosa marked this pull request as ready for review November 13, 2025 09:55
@penalosa penalosa requested a review from a team as a code owner November 13, 2025 09:55
Comment on lines +177 to +186
deploy:
autoConfigDetails.framework?.deploy ??
(autoConfigDetails.buildCommand
? `${autoConfigDetails.buildCommand} && wrangler deploy`
: `wrangler deploy`),
preview:
autoConfigDetails.framework?.preview ??
(autoConfigDetails.buildCommand
? `${autoConfigDetails.buildCommand} && wrangler dev`
: `wrangler dev`),
Copy link
Member

Choose a reason for hiding this comment

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

mh.... I am not completely sure if we should modify the deploy and preview script for the user... it feels a bit invasive 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is invasive, but I think it's the right behaviour. It matches what C3 does, and (as with all the autconfig settings), a user could roll it back if they wanted to.

Copy link
Member

Choose a reason for hiding this comment

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

a user could roll it back if they wanted to.

Yes for sure 👍

but I think it's the right behaviour

Ok, if you think so I am happy with it 🙂, it does feel a bit off to me... but it also does make sense...

Also including these scripts could be instrumental for handling the Next.js issue you raised (since our open-next adapter has its own preview and deploy commands)

"create-cloudflare": minor
---

When the `--experimental` flag is passed to `create-cloudflare`, use `wrangler setup` for configuring a project to work on Cloudflare rather than the existing `create-cloudflare` logic. Only Gatsby is supported right now, with more frameworks to be added in future. There should be no functional change to applications created via `create-cloudflare` when using the `--experimental` flag.
Copy link
Member

Choose a reason for hiding this comment

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

I think @petebacondarwin introduced the --experimental flag in C3, I'd be keen to hear if he's ok with the flag's repurposing (or if he had in mind other potential uses for it)

Personally I'd prefer a more clear and specific flag, but I'm ok with --experimental if everyone else is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I went with --experimental is that 1) it's currently not used for anything, and 2) it already has a bunch of infra set up (e.g. separate test runs) that's useful. I also think the semantic matches what we're doing here—we're changing the underlying implementation of C3 in an experimental way that we'll eventually turn on by default, which is exactly what we did with Assets.

// so wait up to 3 mins for the dev-server to be ready.
await retry(
{ times: 300, sleepMs: 5000 },
{ times: 30, sleepMs: 5000 },
Copy link
Member

Choose a reason for hiding this comment

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

why such reduction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO 25 minutes is way too long. The comment above mentioned 5 minutes, but I've changed them both to be a consistent 3 minutes, since that seems sufficiently long for a build in CI

Copy link
Member

Choose a reason for hiding this comment

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

30 times 5 seconds, isn't it 150 seconds? so 2.5 minutes?

I did also comment above as the numbers here are not matching up for me 😅

(maybe I would update the comment to say so wait for some time for the dev-server to be ready. so that we don't need to over-analyze be specific on the time?)

Copy link
Member

@dario-piotrowicz dario-piotrowicz Nov 13, 2025

Choose a reason for hiding this comment

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

IMO 25 minutes is way too long. The comment above mentioned 5 minutes

that's another reason as to why I would recommend to be a bit more generic with the comment, so that we avoid this sort of issues when the comment got outdate 🤔

(PS: 25 minutes does feel like a very long time, if reducing it works in CI, I'm totally happy with that)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll update the comment

Copy link
Member

Choose a reason for hiding this comment

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

ok, sorry for the nit 😅👍

Copy link
Member

@dario-piotrowicz dario-piotrowicz left a comment

Choose a reason for hiding this comment

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

Looks great to me! 🤩

@petebacondarwin petebacondarwin merged commit 7035804 into main Nov 13, 2025
30 checks passed
@petebacondarwin petebacondarwin deleted the penalosa/c3-autoconfig branch November 13, 2025 14:45
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants