Skip to content

Apply declared dependency patches in server builds - #238

Merged
tnkuehne merged 1 commit into
feat/app-keysfrom
feat/builder-patches
Nov 20, 2026
Merged

tnkuehne merged 1 commit into
feat/app-keysfrom
feat/builder-patches

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What changes

  • The app builder reads patchedDependencies from a project's pnpm-workspace.yaml, as pnpm 12 does, and applies each patch to the installed package, both for the bundle and for the declarations service documentation reads.
  • Patches apply exactly. A hunk whose context differs, a patch file that is missing, or a patch for another installed version fails the build with a message. A patch for a package that a phase does not install, such as a development dependency in the bundle, is skipped.
  • Files a patch changes are kept until it is applied, then the package is filtered as before. This is a small hook (patchPackage) in the patched @cloudflare/worker-bundler installer; parsing and applying patches lives in packages/app-builder/src/patches.ts.
  • Unknown top-level keys in wrangler.jsonc now fail the build, as they fail widefleet deploy (deny_unknown_fields). Before, the builder ignored them.

Why

A template that depends on a patched package must install the same contents on the server as pnpm install does locally. pnpm 12 reads patches only from pnpm-workspace.yaml; pnpm.patchedDependencies in package.json is ignored.

Tests

  • packages/app-builder/src/patches.test.ts: changed, added and deleted files, final newlines, differing context, version matching.
  • packages/app-builder/src/builder.test.ts: a patched dependency in the bundle, a patched declaration in the documentation, failing patches and an unknown Wrangler key.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; the previous type-source issue is fixed and no new blocking issues were found.

Summary

The builder now applies patches declared in pnpm-workspace.yaml before bundling code or reading declarations.

  • Server builds use the dependency patches declared by each project.
  • Unknown Wrangler settings now stop a server build.

The previous type-source finding is fixed. No new actionable issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Project files] --> B[Read declared patches]
  B --> C[Install package files]
  C --> D[Keep files needed by patches]
  D --> E[Apply patches]
  E --> F[Filter patched package files]
  F --> G[Check patch results]
  G --> H[Bundle code]
  G --> I[Read declarations]
Loading

Reviews (6) · Last reviewed commit: "Apply declared dependency patches in ser..." · Reviewed by Greptile

@tnkuehne
tnkuehne added this pull request to stack #239 November 20, 2026 11:10
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs 366daa8 Nov 20 2026, 01:54 PM

Comment thread packages/app-builder/src/patches.ts Resolved
Comment thread packages/app-builder/src/patches.ts Resolved
Comment thread packages/app-builder/src/patches.ts Resolved
Comment thread packages/app-builder/src/patches.ts Resolved
Comment thread patches/@[email protected] Resolved
Comment thread packages/app-builder/src/patches.ts Resolved
@tnkuehne
tnkuehne force-pushed the feat/builder-patches branch from 889e855 to b9c149c Compare November 20, 2026 11:38
Comment thread packages/app-builder/src/patches.ts Resolved
Comment thread packages/app-builder/src/patches.ts Resolved
@tnkuehne
tnkuehne force-pushed the feat/builder-patches branch 2 times, most recently from 6f0d22a to b9b7424 Compare November 20, 2026 12:36
Comment thread packages/app-builder/src/patches.ts Resolved
Comment thread packages/app-builder/src/patches.ts Resolved
@tnkuehne
tnkuehne force-pushed the feat/builder-patches branch from b9b7424 to 8228232 Compare November 20, 2026 12:56
The app builder applies the patchedDependencies a project declares in
pnpm-workspace.yaml, as pnpm install does before widefleet deploy, so a
template can ship patches for its dependencies. Patches apply exactly and
before the installer drops files a phase does not read. Unknown top-level
Wrangler keys now fail the build, as they fail widefleet deploy.
@tnkuehne
tnkuehne force-pushed the feat/builder-patches branch from 8228232 to 366daa8 Compare November 20, 2026 13:53
@tnkuehne
tnkuehne merged commit af193a3 into main Nov 20, 2026
17 checks passed
@tnkuehne
tnkuehne deleted the feat/builder-patches branch November 20, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant