Skip to content

feat(cloudflare/workers): assets-only Workers (no script) - #969

Merged
sam-goodwin merged 2 commits into
mainfrom
claude/cloudflare-worker-assets-only-fa4e70
Jul 28, 2026
Merged

sam-goodwin merged 2 commits into
mainfrom
claude/cloudflare-worker-assets-only-fa4e70

Conversation

@sam-goodwin

Copy link
Copy Markdown
Member

A Worker with only an assets directory — no main, no script, no build — now deploys as a true assets-only Worker, matching an assets-only wrangler deploy:

const site = yield* Cloudflare.Worker("Site", {
  assets: {
    directory: "./public",
    htmlHandling: "drop-trailing-slash",
  },
  domain: "static.example.com",
});

No script is uploaded at all (the PUT carries no main_module and no modules — the same wire shape the Vite assets-only path already uses), so Cloudflare's asset layer serves every request and applies htmlHandling / notFoundHandling (including SPA fallback) itself. Static asset requests are free and never invoke a Worker.

  • prepareAssetsAndBundle skips bundling when main/script/vite are all absent; a Worker with none of main/script/assets dies with a clear error
  • hasChanged gains the matching diff branch (a stored bundle hash means "converting from a script Worker" → deploy)
  • Local dev serves a stub module delegating to the ASSETS binding (the local runtime requires a user worker module); the assets worker applies the routing config itself
  • Website.StaticSite drops its injected passthrough stub and deploys assets-only when no main/script is given
  • Docs: assets-only example on Worker, updated StaticSite JSDoc, and static-site.mdx now shows the plain-Worker form for no-build sites

Live-tested: fresh assets-only deploy (custom 404 page served by the asset layer), asset update, conversion to a script Worker and back (AssetsOnlyWorker.test.ts); all 7 existing StaticSite tests pass with the stub removed.

🤖 Generated with Claude Code

…tory with no script

Omitting both main and script (with assets set) now uploads a script-less
Worker: Cloudflare's asset layer serves every request and applies
htmlHandling/notFoundHandling itself, matching assets-only wrangler deploy.
Local dev serves a stub that delegates to the ASSETS binding.
Website.StaticSite drops its injected passthrough stub and deploys
assets-only when no main/script is given.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@alchemy-version-bot

alchemy-version-bot Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Install the packages built from this commit:

alchemy

bun add alchemy@https://pkg.ing/alchemy/4169d6a

@alchemy.run/better-auth

bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/4169d6a

@alchemy.run/pr-package

bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/4169d6a

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sam-goodwin
sam-goodwin merged commit e922d34 into main Jul 28, 2026
9 checks passed
@sam-goodwin
sam-goodwin deleted the claude/cloudflare-worker-assets-only-fa4e70 branch July 28, 2026 07:49
sam-goodwin added a commit that referenced this pull request Jul 28, 2026
Conflict: main's assets-only Workers (#969) added its dev-mode support
to LocalWorkerProvider's old runInstance structure, which this branch
replaced with LocalProvider.make. Resolved by porting the feature into
the new structure: an `assetsOnly` flag on the resolved (hashed) config
and a runAssetsOnly branch in the start dispatch serving the
ASSETS-delegating stub. Added AssetsOnly.local.test.ts to pin the
dev-mode path (main only covered the live deploy).

Co-authored-by: Cursor <cursoragent@cursor.com>
john-royal added a commit that referenced this pull request Jul 30, 2026
Brings in 94 commits from main (local vs live provider modes #963,
workersDev/domain props #977, Worker.URL self-binding #964, assets-only
Workers #969, Prisma provider #416, version affinity #985, telemetry
#860) while preserving this branch's SourceProvider architecture and
Website framework integrations.

- Worker providers take main's side wholesale; the SourceProvider
  integration is re-grafted as a dispatch: `props.source` routes through
  `resolveSource`/`loadSource` (build, hash slots, and local dev in both
  server and bundle modes via the make-before-break serve path), while
  script/vite/python/prebuilt/assets-only workers keep main's paths.
- Apply.ts: both sides landed the resolved-bindings persistence fix
  (#874 / ef08f4c); merged as the union, keeping `providerMode` and
  `bindings` on replaced-state commits.
- test Utils/Http.ts: keep main's generalized retryResponse machinery
  (expectUrlRedirect/expectUrlHeader) and re-add expectDirectStatus on
  top of it.
- Website tests track main's API: `url`/`subdomain` props fold into
  `workersDev`; dev-mode R2 cleanup skips virtual `dev:` buckets.
- cloudflare-tools submodule bumped to this branch's merge of its own
  upstream main (59c3861); distilled synced to main's pointer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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