Skip to content

Conversation

@dario-piotrowicz
Copy link
Member

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


  • 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 in v3

@changeset-bot
Copy link

changeset-bot bot commented Nov 16, 2025

🦋 Changeset detected

Latest commit: 8aa1a3b

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

@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Nov 16, 2025
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from e1a384a to 31e5296 Compare November 16, 2025 18:13
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 16, 2025

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 8aa1a3b

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from 31e5296 to 20d1242 Compare November 16, 2025 18:49
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from 20d1242 to a2f24b5 Compare November 17, 2025 10:37
@dario-piotrowicz dario-piotrowicz force-pushed the penalosa/autoconfig-sveltekit branch from b1d0f1b to ba94707 Compare November 17, 2025 11:27
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from a2f24b5 to a087f96 Compare November 17, 2025 11:28
Base automatically changed from penalosa/autoconfig-sveltekit to main November 17, 2025 14:06
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from a087f96 to db411f0 Compare November 17, 2025 14:09
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review November 17, 2025 14:09
@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner November 17, 2025 14:09
@dario-piotrowicz
Copy link
Member Author

Converting to draft since the C3 e2es don't currently run in CI and we should enable them before merging and new C3 autoconfig PR

@dario-piotrowicz dario-piotrowicz marked this pull request as draft November 17, 2025 16:25
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from db411f0 to 9845bde Compare November 17, 2025 23:07
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review November 18, 2025 17:30
@ascorbic
Copy link
Contributor

When I tried this locally, with a new project, I got "✘ [ERROR] The entry-point file at ".open-next/worker.js" was not found.". I needed to do another npm run deploy manually

@ascorbic
Copy link
Contributor

The issue is that it doesn't run opennextjs-cloudflare build. I'm not sure what the best workaround is here.

@ascorbic
Copy link
Contributor

Should it change the build command?

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch 2 times, most recently from 69a48af to 73871b5 Compare November 27, 2025 11:28
@dario-piotrowicz
Copy link
Member Author

Should it change the build command?

oh... yeah I see the issue.... that's annoying.... I don't think we could change the build command since that's for example used by the Vercel CLI and changing it can have some unexpected consequences... 🤔 I think we should ideally let wrangler deploy know the build command that it needs to run? 🤔

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from 73871b5 to 0927724 Compare November 27, 2025 18:43
@dario-piotrowicz
Copy link
Member Author

@ascorbic WDYT?

0927724

@ascorbic
Copy link
Contributor

0927724

I think these changes should be in a separate PR. Will they then override the package.json build command too?

@dario-piotrowicz
Copy link
Member Author

Will they then override the package.json build command too?

No, because as I said I think we likely don't want that since it's just likely going to create issues (and either way we'd need a build script (even if named different) that we can point open-next to).

Here wrangler just builds the app using npx (and analogous) in the wrangler deploy flow, then the user will have appropriate preview and deploy scripts in their package.json from thereon.

This to me sounds like an appropriate first implementation that we can improve later on how/if needed

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch 2 times, most recently from 2a9adfd to abd3263 Compare November 28, 2025 13:55
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from abd3263 to 88b8055 Compare November 28, 2025 14:12
@dario-piotrowicz dario-piotrowicz changed the base branch from main to dario/DEVX-2321/autoconfig-nextjs-refactoring November 28, 2025 14:13
@dario-piotrowicz
Copy link
Member Author

I think these changes should be in a separate PR

#11461

@github-actions
Copy link
Contributor

Failed to automatically backport this PR's changes to Wrangler v3. Please manually create a PR targeting the v3-maintenance branch with your changes. Thank you for helping us keep Wrangler v3 supported!

Depending on your changes, running git rebase --onto v3-maintenance main dario/DEVX-2321/autoconfig-nextjs might be a good starting point.

Notes:

  • your PR branch should be named v3-backport-11301
  • add the skip-v3-pr label to the current PR to stop this workflow from failing

@dario-piotrowicz dario-piotrowicz added the skip-v3-pr Skip validation of presence of a v3 backport PR label Nov 28, 2025
Base automatically changed from dario/DEVX-2321/autoconfig-nextjs-refactoring to main November 28, 2025 15:37
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from 88b8055 to f6f7300 Compare November 28, 2025 15:46
penalosa
penalosa previously approved these changes Nov 28, 2025
directory: ".open-next/assets",
},
},
buildCommand: `${npx} @opennextjs/cloudflare build`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this different to opennextjs-cloudflare?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, the next docs don't recommend changing this: https://opennext.js.org/cloudflare/get-started

Copy link
Member Author

Choose a reason for hiding this comment

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

Why is this different to opennextjs-cloudflare?

Here, having

buildCommand: `opennextjs-cloudflare build`,

doesn't work and it errors that it can't recognize the binary name opennextjs-cloudflare

I think that that is only accessible via scripts in the package.json

Also, the next docs don't recommend changing this: https://opennext.js.org/cloudflare/get-started

opennextjs-cloudflare points to the package binary, so it's an alias for @opennextjs/cloudflare so running one or the other shouldn't make much of a difference... no? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, what I meant is that the open next docs seem to recommend using next build here

Copy link
Member Author

Choose a reason for hiding this comment

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

mh.... ok sorry I think I understood the confusion now... (and my unclear code caused it)

The package.json's build script should definitely remain next build, and I am not changing that in this PR

What I was passing here is a build command, that autoconfig needs to run to build the project (the build command being a completely different concept to the build script, buildCommand !== packageJson.scripts.build)...

did I get it right? is this were the confusion lied here? did you think I was updating the build script?

Comment on lines +10 to +6
/**
* Base class for errors where something in a autoconfig frameworks' configuration goes
* something wrong. These are not reported to Sentry.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this not just a UserError? Why do we need a new class?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it might come in handy to know whether an error comes from the configuration step or not (with a simple instanceof check). This can also be pretty convenient for potential users of the programmatic API.

I also think this will be nicer as part of the programmatic API (e.g. a consumer of the programmatic API providing their own framework object).

If you disagree I'm happy to go with just UserError errors instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fair! What about making it extend UserError instead of re-implementing it?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok sure 🙂 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated 🙂

const { npx } = await getPackageManager();

return {
wranglerConfig: {
Copy link
Contributor

Choose a reason for hiding this comment

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

The open next docs mention a WORKER_SELF_REFERENCE service binding. Do we need that? https://opennext.js.org/cloudflare/get-started

Copy link
Member Author

@dario-piotrowicz dario-piotrowicz Nov 28, 2025

Choose a reason for hiding this comment

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

It's not in the C3 starter template... so I think not? 🤔

@vicb?

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Nov 28, 2025
@penalosa penalosa dismissed their stale review November 28, 2025 17:24

didn't mean to approve, just comment

@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2321/autoconfig-nextjs branch from 07486f2 to 8aa1a3b Compare November 29, 2025 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-v3-pr Skip validation of presence of a v3 backport PR

Projects

Status: Approved

Development

Successfully merging this pull request may close these issues.

4 participants