Skip to content

new config miniflare attempt 3 - #14994

Merged
emily-shen merged 28 commits into
mainfrom
emily/new-config-miniflare
Aug 10, 2026
Merged

new config miniflare attempt 3#14994
emily-shen merged 28 commits into
mainfrom
emily/new-config-miniflare

Conversation

@emily-shen

@emily-shen emily-shen commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Config:

  • cobbled together from the cloudflare config format defined in the @cloudflare/config package.
  • have had to modify the imported config to add miniflare specific options and also make id's required
  • have added a reconstructed (used to be assembled from each plugin options) schema of v4 miniflare options for the v4 to v5 conversion helper.

All plugins now get the full config, and are responsible for filtering down the relevant config themselves - previously miniflare plugins each declared a schema of what config it needed, and then each plugin would only receive that.

There is probably a lot of tidying up we can do in miniflare to strip out more unused bits, but trying to avoid too much in this PR.

A large chunk of the diff is in tests, where we call new Miniflare a lot. Inside miniflare this is migrated to the new config directly, outside miniflare we use the conversion helper.

As discussed the v4 to v5 conversion happens right before passing options to miniflare, meaning the new config format is not exposed in any public APIs (well other than miniflare's obviously).

TODO later:

there are a couple of exports from miniflare that are only used by vitest-pool-workers and not miniflare itself. for example, the config merging helper and compileModuleRules. In a follow up i will probably just move that directly into VPW.


  • 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: miniflare v5 is wip

A picture of a cute animal (not mandatory, but encouraged)

@changeset-bot

changeset-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 73ec8a5

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

This PR includes changesets to release 10 packages
Name Type
@cloudflare/config Minor
miniflare Major
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Minor
wrangler Patch
@cloudflare/build-output-utils Patch
@cloudflare/deploy-helpers Patch
@cloudflare/pages-shared Patch
@cloudflare/remote-bindings Patch
@cloudflare/runtime-types Patch

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 Aug 3, 2026

Copy link
Copy Markdown
Contributor

UnknownError: ProviderInitError

github run

@ask-bonk

ask-bonk Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@emily-shen Bonk workflow failed. Check the logs for details.

View workflow run · To retry, trigger Bonk again.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

✅ All changesets look good

Comment thread packages/miniflare/src/config/schema.ts
@emily-shen
emily-shen force-pushed the emily/new-config-miniflare branch from 17612e4 to 1c14de0 Compare August 3, 2026 22:51
@pkg-pr-new

pkg-pr-new Bot commented Aug 3, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

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

@cloudflare/config

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

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 73ec8a5

Comment thread packages/miniflare/src/config/schema.ts
Comment thread packages/miniflare/src/config/v4-convert.ts
@emily-shen
emily-shen force-pushed the emily/new-config-miniflare branch 3 times, most recently from 8612a3c to e4c796b Compare August 4, 2026 21:44
@emily-shen
emily-shen marked this pull request as ready for review August 4, 2026 21:44
@workers-devprod
workers-devprod requested review from a team and petebacondarwin and removed request for a team August 4, 2026 21:45
@workers-devprod

workers-devprod commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/d1
  • @cloudflare/workers-kv
  • ✅ @cloudflare/wrangler
Show detailed file reviewers
  • packages/miniflare/test/plugins/kv/index.spec.ts: [@cloudflare/workers-kv]
  • packages/miniflare/test/plugins/kv/sites.spec.ts: [@cloudflare/workers-kv]
  • packages/wrangler/src/d1/execute.ts: [@cloudflare/d1]
  • packages/wrangler/src/d1/export.ts: [@cloudflare/d1]
  • packages/wrangler/src/kv/helpers.ts: [@cloudflare/workers-kv]

devin-ai-integration[bot]

This comment was marked as resolved.

@emily-shen
emily-shen force-pushed the emily/new-config-miniflare branch from e4c796b to e8514a8 Compare August 5, 2026 13:56
devin-ai-integration[bot]

This comment was marked as resolved.

@emily-shen
emily-shen requested review from edmundhung, jamesopstad and penalosa and removed request for petebacondarwin August 5, 2026 14:26
@emily-shen
emily-shen force-pushed the emily/new-config-miniflare branch from 45dbce5 to 9a7db84 Compare August 6, 2026 09:40
@emily-shen

Copy link
Copy Markdown
Contributor Author

Assets configuration
The converter drops supported fields from assets.routerConfig and assets.assetConfig, including existing static routing rules and inline headers/redirects.
These values were previously passed to the assets workers, so existing asset routing and response behaviour may change.

The dropped fields are now resolved once in miniflare instead of separately by consumers.

Workflow compatibility flags
The v4 schema and converter omit each workflow’s compatibilityFlags. The workflow plugin instead applies the user Worker’s compatibility flags to every workflow engine.
This both removes explicitly configured workflow flags and introduces unrelated Worker flags into the engine.

the workflow compat flags are the user compat flags, just previously the plugin didn't have access to those options so they were copied over.

Manual module path resolution
Relative paths in manually supplied modules were previously resolved against rootPath; modulesRoot only determined their runtime module names.
The converter now reads those files relative to modulesRoot, which can load the wrong file or fail with ENOENT whenever rootPath and modulesRoot differ.

devin had the same comment, i still don't really understand what the problem is here. what is the expected user facing breakage due to this change?

fixing the rest

devin-ai-integration[bot]

This comment was marked as resolved.

@penalosa

penalosa commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

devin had the same comment, i still don't really understand what the problem is here. what is the expected user facing breakage due to this change?

Example project:

/project/
  src/index.mjs
new Miniflare({
  rootPath: "/project",
  modulesRoot: "src",
  modules: [{ type: "ESModule", path: "src/index.mjs" }],
});

Previously:

  • File lookup: rootPath + path
  • Reads /project/src/index.mjs
  • Runtime module name: path relative to modulesRoot
  • Name becomes index.mjs

Now:

  • File lookup: modulesRoot + path
  • Attempts /project/src/src/index.mjs
  • Fails with ENOENT

@edmundhung edmundhung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some findings from AI review 😅

Comment thread packages/miniflare/src/config/v4-convert.ts
Comment thread packages/miniflare/src/config/v4-convert.ts Outdated
Comment thread packages/miniflare/src/config/v4-schema.ts Outdated
Comment thread packages/miniflare/src/config/v4-convert.ts Outdated
Comment thread packages/miniflare/src/config/v4-convert.ts
Comment thread packages/miniflare/src/config/v4-convert.ts
Comment thread packages/miniflare/src/config/v4-schema.ts
Comment thread packages/miniflare/src/config/v4-schema.ts Outdated
Comment thread packages/miniflare/src/config/v4-convert.ts
Comment thread packages/miniflare/src/config/v4-schema.ts Outdated
devin-ai-integration[bot]

This comment was marked as resolved.

Comment thread packages/miniflare/src/config/v4-convert.ts

@edmundhung edmundhung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We are getting there! Thanks for the hard work. 🙌🏼

Comment thread packages/miniflare/src/config/v4-convert.ts Outdated
devin-ai-integration[bot]

This comment was marked as resolved.

@emily-shen
emily-shen force-pushed the emily/new-config-miniflare branch from c60a2f5 to 73ec8a5 Compare August 7, 2026 15:44
Comment thread packages/miniflare/src/config/schema.ts
Comment thread packages/miniflare/src/config/schema.ts
Comment thread packages/miniflare/src/config/schema.ts
Comment thread packages/miniflare/src/config/schema.ts

@penalosa penalosa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI review of the tests, apologies in advance for any nonsense!

Comment thread packages/miniflare/test/config/v4-convert.spec.ts
Comment thread packages/miniflare/test/plugins/core/errors/index.spec.ts
Comment thread packages/miniflare/test/plugins/do/index.spec.ts
Comment thread packages/miniflare/test/plugins/queues/index.spec.ts
Comment thread packages/miniflare/test/plugins/r2/index.spec.ts
Comment thread packages/miniflare/test/index.spec.ts
Comment thread packages/miniflare/test/index.spec.ts
Comment thread packages/miniflare/test/plugins/core/errors/index.spec.ts
Comment thread fixtures/vitest-pool-workers-examples/misc/vitest.config.ts

@penalosa penalosa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A second pass over the non-test changes found these configuration and runtime gaps. I have omitted the expected module-discovery change and the issues already covered in my earlier review.

Comment thread packages/miniflare/src/plugins/analytics-engine/index.ts
Comment thread packages/miniflare/src/plugins/core/index.ts
Comment thread packages/miniflare/src/config/schema.ts
Comment thread packages/miniflare/src/config/v4-schema.ts
Comment thread packages/miniflare/src/config/schema.ts
Comment thread packages/miniflare/src/config/schema.ts
Comment thread packages/miniflare/src/config/v4-convert.ts
Comment thread packages/miniflare/src/config/v4-convert.ts
Comment thread packages/miniflare/src/config/v4-schema.ts
Comment thread .changeset/vitest-pool-miniflare-modules-rules.md
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/d1
  • @cloudflare/workers-kv
  • ✅ @cloudflare/wrangler
Show detailed file reviewers
  • packages/miniflare/test/plugins/kv/index.spec.ts: [@cloudflare/workers-kv]
  • packages/miniflare/test/plugins/kv/sites.spec.ts: [@cloudflare/workers-kv]
  • packages/wrangler/src/d1/execute.ts: [@cloudflare/d1]
  • packages/wrangler/src/d1/export.ts: [@cloudflare/d1]
  • packages/wrangler/src/kv/helpers.ts: [@cloudflare/workers-kv]

@edmundhung edmundhung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

codeowners bypass

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Aug 10, 2026
@emily-shen
emily-shen merged commit 2194f88 into main Aug 10, 2026
155 of 167 checks passed
@emily-shen
emily-shen deleted the emily/new-config-miniflare branch August 10, 2026 10:43
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Aug 10, 2026
mack-erel added a commit to mack-erel/workers-sdk that referenced this pull request Aug 11, 2026
Two leftovers from rebasing onto the new miniflare config structure (cloudflare#14994):

- `HyperdriveBindingSchema` is a `strictObject`, so `remote: true` was
  rejected at parse time even though the TypeScript interface allowed it.
- The bridge and seed-endpoint tests still built Miniflare with the v4
  top-level worker shape (`name`/`modules`/`hyperdrives`) instead of the
  `workers: [{ config: ... }]` form.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015GDyTfEa62t3bSe5wWn8Mt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:c3-e2e Run C3 E2E tests on a pull request ci:e2e Run wrangler + vite-plugin E2E tests on a pull request ci:run-remote-tests Run remote/E2E tests that require Cloudflare API credentials ci:test-all-node-versions Run the tests on all Node versions for this PR run-c3-frameworks-tests Run all the C3 frameworks tests on this PR

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants