Skip to content

Expose build mode support from autoconfig - #15593

Draft
edmundhung wants to merge 1 commit into
mainfrom
edmundhung/autoconfig-build-mode
Draft

Expose build mode support from autoconfig#15593
edmundhung wants to merge 1 commit into
mainfrom
edmundhung/autoconfig-build-mode

Conversation

@edmundhung

@edmundhung edmundhung commented Sep 10, 2026

Copy link
Copy Markdown
Member

Fixes cloudflare/cf#180.

Autoconfig resolves the framework commands used by cf build and cf dev, but callers could not tell which commands consume Cloudflare build modes or execute them without reparsing a display string. This adds spawn-ready, command-scoped metadata to autoconfig details and summaries:

commands: {
  build?: {
    executable: string;
    args: string[];
    supportsMode: boolean;
  };
  dev?: {
    executable: string;
    args: string[];
    supportsMode: boolean;
  };
}

Frameworks opt each command into mode forwarding individually. Astro and Vite build and development commands report supportsMode: true; unsupported commands default to false. This keeps Angular ng build unchanged and correctly marks it unsupported even when Wrangler is the configured Cloudflare build tool.

Detected command strings are parsed once into an executable and argument vector. Quoted values remain single arguments, while shell control operators are rejected because they cannot be represented by a direct subprocess spawn.

buildTool?: "vite" | "wrangler" remains available to identify the Cloudflare-aware tool configured by autoconfig. It is deliberately separate from the capabilities of the framework command being executed. Existing buildCommand, deployCommand, and versionCommand string fields are preserved for current output consumers.

The corresponding cf change can append --mode to supported framework invocations and execute both framework and Cloudflare delegates through the shared structured subprocess runner, replacing execaCommand without string concatenation.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this exposes integration metadata consumed by cf and does not add a direct user-facing API workflow.

Verification:

  • pnpm test:ci in packages/autoconfig (208 tests)
  • pnpm check:type in packages/autoconfig
  • pnpm build in packages/autoconfig
  • oxlint --deny-warnings --type-aware on changed TypeScript files
  • oxfmt --check on changed files

@changeset-bot

changeset-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fa1708b

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

This PR includes changesets to release 1 package
Name Type
@cloudflare/autoconfig Minor

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

@ask-bonk

ask-bonk Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15593

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15593

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@15593

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15593

create-cloudflare

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

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15593

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15593

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@15593

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15593

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: fa1708b

@edmundhung
edmundhung force-pushed the edmundhung/autoconfig-build-mode branch 2 times, most recently from d41a7ce to 0d1cc4f Compare September 10, 2026 15:42
`cf` delegates build and development to framework commands when
autoconfig detects them, but not every command can consume Cloudflare
build modes. Return a structured executable and argument vector with
each command's mode capability so callers can append `--mode` safely and
use the same subprocess runner for framework and Cloudflare delegates.

The existing string command fields remain unchanged for output
consumers.

## framework-class.ts

Resolve detected command strings into executable/argument vectors and
reject shell control operators that cannot be represented by a direct
spawn.

### [+L40] Produce spawn-ready commands

Quoted values remain single arguments, while each framework must opt its
build and development commands into mode forwarding independently.

### [+L177..L198] Limit invocations to one process

Control operators are rejected instead of silently changing the
semantics of a structured subprocess invocation.

## details/index.ts

Return resolved build and development command metadata during project
analysis so `cf dev` can make the same forwarding decision as `cf
build`.

## run.ts

Include both commands in the setup summary while preserving the existing
build, deploy, and version command strings.

### [+L537] Keep tool and command support separate

The summary resolves capabilities from the framework command itself
instead of inferring them from `buildTool`.

## astro.ts

Astro build and dev commands accept `--mode` and pass the selected Vite
mode through their Cloudflare integration.

### [+L27] Opt in both Astro commands

Build and development independently advertise support for the same mode
flag.

## vite.ts

Vite build and dev commands expose the same mode capability after
autoconfig installs the Cloudflare Vite plugin.

## run.test.ts

Cover quoted argument parsing, operator rejection, and the boundary
where a Wrangler-backed Angular command remains mode-unaware.

Issue: cloudflare/cf#180
Reviewable-Commit-Version: 1
@edmundhung
edmundhung force-pushed the edmundhung/autoconfig-build-mode branch from 0d1cc4f to fa1708b Compare September 10, 2026 15:53
@petebacondarwin petebacondarwin added this to the Birthday Week 2026 milestone Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

3 participants