Skip to content

Conversation

devin-ai-integration[bot]
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Oct 7, 2025

This PR adds a new --write-workerd-config [path] flag to the wrangler build command that generates a workerd capnp configuration file suitable for running the built Worker directly with the workerd binary.

Implementation Overview

  • Architecture: The build command delegates to deploy --dry-run, so the implementation lives in the deploy command and only activates when both flags are present
  • Config generation: Uses Miniflare's existing serializeConfig function to produce the capnp file
  • Scope: Generates a minimal single-worker config with modules and compatibility settings (bindings like KV/R2/DO are not included in this initial version)
  • Path handling: Supports both file and directory paths; defaults to workerd.capnp if a directory is provided

Key Implementation Details

The logic finds the built entry point by:

  1. Checking common names (index.mjs, index.js, worker.mjs, etc.)
  2. Falling back to scanning for any .js/.mjs file in the output directory
  3. Throwing an error if no entry point is found

Human Review Checklist

High Priority:

  • Test coverage: Verify the test adequately covers the feature (current test only checks file existence, not capnp validity)
  • Entry point detection: Review the fallback logic for finding built files - is it robust enough?
  • Path handling: Check edge cases around file vs directory paths, permissions, mkdir behavior

Medium Priority:

  • Error scenarios: What happens if bundling fails or produces unexpected output?
  • Config completeness: Is the minimal config (modules + compatibility only) sufficient for the initial version?
  • Integration stability: Is the build → deploy --dry-run delegation approach sound?

Link to Devin run: https://app.devin.ai/sessions/f95b2210cf2b45788334302cb5ab93f5
Requested by: @petebacondarwin


  • Tests
    • Tests included
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: flag is discoverable via --help; docs can follow in separate PR
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: new feature targeting current Wrangler version

Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link

changeset-bot bot commented Oct 7, 2025

🦋 Changeset detected

Latest commit: 8d0daba

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

Copy link

pkg-pr-new bot commented Oct 7, 2025

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

wrangler

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

commit: 8d0daba

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.

0 participants