chore: check WORKERS_CI env variable to determine if we're building for Cloudflare Workers#13733
chore: check WORKERS_CI env variable to determine if we're building for Cloudflare Workers#13733
WORKERS_CI env variable to determine if we're building for Cloudflare Workers#13733Conversation
🦋 Changeset detectedLatest commit: eb9cf06 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
…ltejs/kit into feat-adapter-auto-workers-ci
|
@benmccann I'm not sure if the adapter-auto case for Workers Builds is very useful with this PR because it doesn't "just work" like the other platforms do (since it fails without a Wrangler config file). Would it be useful to generate a basic Wrangler config during the Workers CI so that it just works? Or is it better that users get a deployment error which forces them to setup a wrangler.jsonc file? |
|
Ah, I guess the PR description is outdated then as it suggests it works without a config What would a basic config contain? Is there anything we might accidentally omit or get wrong by doing that? |
Yeah, I was half-way implementing the generated config but then wasn't sure if it would be a good idea.
The minimum we would need would be: {
// `name` is not required since Cloudflare's dashboard requires the user to enter that before the build
"main": ".svelte-kit/cloudflare/_worker.js",
// this will be based on the current date
"compatibility_date": "2025-04-24",
"assets": {
"binding": "ASSETS",
"directory": ".svelte-kit/cloudflare",
},
// only required if the user uses `getRequestEvent()` asynchronously.
// Enabling this doesn't add any polyfills like `nodejs_compat` does so it could be safe to always have this?
// Otherwise we could only include it if we detect `getRequestEvent()` being used.
"compatibility_flags": ["nodejs_als"]
}Another question is: how should we generate the Wrangler config? There are currently two ways to do this:
|
|
We can only progress on this once we start using the Cloudflare Vite plugin to automatically generate a wrangler config file https://developers.cloudflare.com/workers/vite-plugin/reference/programmatic-configuration/ |
WORKERS_CI env variable when determining if we're building for Cloudflare Workers
WORKERS_CI env variable when determining if we're building for Cloudflare WorkersWORKERS_CI env variable to determine if we're building for Cloudflare Workers
Inspired by unjs/std-env#156
This PR detects theWORKERS_CIenvironment variable so thatadapter-autoandadapter-cloudflarecan work with Cloudflare's Workers Git integration to build the app without requiring a wrangler configuration from the user.I've changed the scope of the PR to focus on only the Cloudflare adapter because we'll may end up deprecating adapter-auto. Also, it doesn't work well with adapter-auto since it requires a wrangler config file.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits