Skip to content

Fix build of workers#9

Merged
Jbithell merged 10 commits into
mainfrom
claude/migrate-cloudflare-workers-XxRkB
Mar 9, 2026
Merged

Fix build of workers#9
Jbithell merged 10 commits into
mainfrom
claude/migrate-cloudflare-workers-XxRkB

Conversation

@Jbithell
Copy link
Copy Markdown
Contributor

@Jbithell Jbithell commented Mar 9, 2026

This pull request migrates the project from Cloudflare Pages to Cloudflare Workers, updating deployment workflows, configuration files, and dependencies to match the new platform. It also removes legacy code and updates scripts and settings for improved compatibility and performance.

Cloudflare Workers migration:

  • Updated GitHub Actions workflows (cloudflare-pages-deploy.yml, cloudflare-pages-preview.yml, migrate-preview-d1.yml, reset-preview-d1.yml) to deploy to Cloudflare Workers instead of Pages, including changes to deployment commands, Node version, and removal of wranglerVersion specification. [1] [2] [3] [4]
  • Removed the legacy Pages handler file functions/[[path]].ts and replaced it with a new Worker entrypoint worker.ts using @remix-run/cloudflare. (functions/[[path]].tsL1-L8, worker.tsR1-R23)

Configuration updates:

  • Replaced wrangler.toml with a new wrangler.jsonc configuration file, updating references throughout the codebase and ensuring proper D1 database bindings for production and preview environments. [1] [2] [3]
  • Updated vite.config.ts to use the new Worker entrypoint and reference the correct configuration file.
  • Modified load-context.ts comments to reflect the new configuration file and clarify type generation.

Dependency and script updates:

  • Upgraded dependencies in package.json to latest versions, including @remix-run/cloudflare, miniflare, wrangler, and others for compatibility with Workers. [1] [2] [3]
  • Updated npm scripts to use Worker commands for build, deploy, and start operations.

claude and others added 6 commits March 9, 2026 13:07
Cloudflare Pages is deprecated in favour of Workers. This migrates the
project to use `wrangler deploy` (Workers) instead of `wrangler pages deploy`.

- Replace wrangler.toml with wrangler.jsonc, adding `main` and `assets` config
  for Workers instead of `pages_build_output_dir`
- Remove `functions/[[path]].ts` Pages function handler (no longer needed)
- Remove `@remix-run/cloudflare-pages` and `@remix-run/css-bundle` dependencies
- Update deploy/start scripts to use `wrangler deploy` / `wrangler dev`
- Update GitHub Actions workflows to deploy via Workers
- Bump compatibility_date to 2024-11-18
- Bump wrangler, @cloudflare/workers-types, @remix-run/*, vite, typescript
- Fix trailing quote typo in reset-preview-d1 workflow

https://claude.ai/code/session_018HoDZ4bsqTYLdXLgfZvE7a
The Remix Vite build outputs server modules at build/server/index.js but
doesn't export a default fetch handler. Add worker.ts as the Worker entry
point that wraps the Remix request handler, and point wrangler.jsonc main
to it so Wrangler bundles it correctly.

https://claude.ai/code/session_018HoDZ4bsqTYLdXLgfZvE7a
Use the Remix Vite plugin's `server` option to compile worker.ts as part
of the Remix build. This produces build/server/index.js with a proper
`export default { fetch }` that wrangler detects as ES module format,
fixing the D1 binding error that requires ES module workers.

https://claude.ai/code/session_018HoDZ4bsqTYLdXLgfZvE7a
Signed-off-by: James Bithell <Jbithell@users.noreply.github.com>
Wrangler's bundler was producing service-worker format output despite the
worker entry having `export default`. Fix by pre-bundling worker.ts with
esbuild (--format=esm) as a post-build step, then using `no_bundle: true`
in wrangler.jsonc so wrangler deploys the pre-built ESM file as-is.

Also removes the invalid `server` option from the Remix Vite plugin
config (that option is for the classic Remix compiler, not the Vite
plugin) and adds esbuild as an explicit devDependency.

https://claude.ai/code/session_018HoDZ4bsqTYLdXLgfZvE7a
The --platform=neutral flag ignores `main` fields in package.json,
causing unresolved module errors for dependencies imported by the
Remix server build. Switch to --platform=browser which respects
main/module fields.

https://claude.ai/code/session_018HoDZ4bsqTYLdXLgfZvE7a
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 9, 2026

Built preview on Cloudflare Workers: Logs. Run Migrations or Reset Preview DB

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 9, 2026

Built preview on Cloudflare Workers: Logs. Run Migrations or Reset Preview DB

claude added 3 commits March 9, 2026 13:43
@remix-run/dev@2.x has peerOptional wrangler@^3, which conflicts with
wrangler@4. This is safe since the peer dep is optional.

https://claude.ai/code/session_018HoDZ4bsqTYLdXLgfZvE7a
remix-validated-form declares @remix-run/server-runtime as a peer dep.
With legacy-peer-deps=true, peer deps aren't auto-installed, so the
esbuild worker bundling step can't resolve it. Adding it explicitly
ensures it's always available.

https://claude.ai/code/session_018HoDZ4bsqTYLdXLgfZvE7a
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 9, 2026

Built preview on Cloudflare Workers: Logs. Run Migrations or Reset Preview DB

@Jbithell Jbithell merged commit 000cea8 into main Mar 9, 2026
4 checks passed
@Jbithell Jbithell deleted the claude/migrate-cloudflare-workers-XxRkB branch March 9, 2026 14:32
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.

2 participants